package com.yn.bftl.thirdparty.modules.baiduai.controller;

import com.yn.bftl.thirdparty.modules.baiduai.service.ClassCardService;
import com.yn.bftl.thirdparty.modules.baiduai.vo.BankcardInfoVO;
import com.yn.bftl.thirdparty.modules.baiduai.vo.BusinessLicenseInfoVO;
import com.yn.bftl.thirdparty.modules.baiduai.vo.IdcardInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

/**
 * @Author：Vance
 * @Description：卡证识别控制层
 * @Date：2022/12/20 11:17
 */
@Api(value = "ClassCardController", tags = "卡证识别控制层")
@RestController
@RequestMapping("/baiduai/class_card")
@Validated
@RequiredArgsConstructor
public class ClassCardController {

    @Resource
    private final ClassCardService classCardService;

    @ApiOperation("身份证识别")
    @PostMapping("/idcard")
    @ApiImplicitParams({
            @ApiImplicitParam(required = true, name = "idcardSide", value = "front：身份证含照片的一面 back：身份证带国徽的一面")
    })
    public IdcardInfoVO idcard(@RequestPart MultipartFile file, @RequestParam @NotBlank String idcardSide) {
        return classCardService.idcard(file, idcardSide);
    }

    @ApiOperation("营业执照识别")
    @PostMapping("/business_license")
    public BusinessLicenseInfoVO businessLicense(@RequestPart MultipartFile file, String type) {
        return classCardService.businessLicense(file, false, !"lock".equals(type));
    }

    @ApiOperation("银行卡识别")
    @PostMapping("/bankcard")
    public BankcardInfoVO bankcard(@RequestPart MultipartFile file) {
        return classCardService.bankcard(file);
    }
}
