package com.bonus.core.customer.v4.mobile.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.core.account.v4.web.service.CardInfoV4Service;
import com.bonus.core.customer.v4.mobile.dto.ProfilePhotoDTO;
import com.bonus.core.customer.v4.mobile.service.CustomerMobileService;
import com.bonus.core.customer.v4.mobile.vo.FacePhotoVO;
import com.bonus.core.customer.v4.mobile.vo.ProfilePhotoVO;
import com.bonus.core.customer.v4.web.dto.CardInfoDTO;
import com.bonus.core.customer.v4.web.vo.CardInfoDetailVO;
import com.bonus.encrypt.RequiresGuest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@Api(
   value = "人员模块V4/移动端",
   tags = {"人员模块V4/移动端"}
)
@RequestMapping({"/api/v4/app/custInfo"})
public class CustomerMobileController extends BaseController {
   private static final Logger log = LoggerFactory.getLogger(CustomerMobileController.class);
   @Resource
   CustomerMobileService customerMobileService;
   @Resource
   CardInfoV4Service cardInfoV4Service;

   @ApiOperation(
           value = "移动端查询头像地址",
           notes = "移动端查询头像地址"
   )
   @PostMapping({"/query/profile/photo"})
   @RequiresGuest
   public ProfilePhotoVO queryProfilePhoto(@RequestBody ProfilePhotoDTO request) {
      return this.customerMobileService.queryProfilePhoto(request);
   }

   @ApiOperation("查询人脸照片地址和状态")
   @PostMapping({"/queryFacePhoto"})
   @RequiresGuest
   public FacePhotoVO facePhotoStatus(@RequestBody ProfilePhotoDTO dto) {
      return this.customerMobileService.facePhotoStatus(dto);
   }

   @ApiOperation(
           value = "移动端卡片管理",
           notes = "web端卡片管理"
   )
   @PostMapping({"/card/list"})
   @RequiresGuest
   public CardInfoDetailVO queryCardsByByCustId(@RequestBody @Valid CardInfoDTO dto) {
      return this.cardInfoV4Service.queryCardsByCustId(dto);
   }

   @ApiOperation(
           value = "v4移动端挂失卡",
           notes = "v4挂失卡"
   )
   @PostMapping({"/loss/card"})
   @RequiresGuest
   public AjaxResult lossReportingCard(@RequestBody CardInfoDTO request) {
      this.cardInfoV4Service.lossReportingCard(request);
      return AjaxResult.success();
   }

   @ApiOperation(
           value = "v4移动端解除挂失",
           notes = "v4解除挂失"
   )
   @PostMapping({"/cancel/loss/card"})
   @RequiresGuest
   public AjaxResult cancelLossReportingCard(@RequestBody CardInfoDTO request) {
      this.cardInfoV4Service.cancelLossReportingCard(request);
      return AjaxResult.success();
   }


   @ApiOperation(
           value = "移动端保存头像地址",
           notes = "移动端保存头像地址"
   )
   @PostMapping({"/save/profile/photo"})
   @RequiresGuest
   public AjaxResult saveProfilePhoto(@RequestBody @Valid ProfilePhotoDTO dto) {
      this.customerMobileService.saveProfilePhoto(dto);
      return AjaxResult.success("上传成功");
   }

}
