package com.loan.system.controller.wechat;

import com.loan.system.domain.pojo.Result;
import com.loan.system.service.CustomerService;
import com.loan.system.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/wechat/customers")
@Api(tags = "微信客户接口")
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    @GetMapping
    @ApiOperation("查询所有客户")
    public Result findAllCustomers(Integer pageNum, Integer pageSize){
        return ResultUtil.success("success", customerService.getAllCustomers(pageNum, pageSize,false));
    }

    @GetMapping("/{id}")
    @ApiOperation("按id选择客户")
    public Result findCustomerById(@PathVariable Long id){
        return ResultUtil.success("success", customerService.findByCustomerIdAndIsDelete( id, false));
    }

    @GetMapping("/{key}")
    @ApiOperation("按关键字（姓名/手机号）选择客户")
    @PreAuthorize("@pms.hasAnyRoles('SYSTEM_ADMIN','LEAD_SALES', 'ASSIST_SALES')")
    public Result findCustomerByKey(@PathVariable("key") String key,Integer pageNum, Integer pageSize){
        return ResultUtil.success("success", customerService.getCustomerByKey(key,false , pageNum, pageSize));
    }

    @PostMapping("/confirm/main")
    @ApiOperation("手机号与身份证鉴权")
    public Result confirm(@RequestBody String mobile){
        return ResultUtil.success("success");
    }

    @PostMapping("/confirm/faceAuth")
    @ApiOperation("人脸识别鉴权")
    public Result faceAuth(@RequestBody String mobile){
        return ResultUtil.success("success");
    }

    @PostMapping("/confirm/bankAccount")
    @ApiOperation("银行账号鉴权")
    public Result bankAccount(@RequestBody String mobile){
        return ResultUtil.success("success");
    }
}
