package com.sqx.modules.app.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.app.entity.UserCertification;
import com.sqx.modules.app.service.UserCertificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@AllArgsConstructor
@RequestMapping("/app/userCertification")
@Api("app实 名 认 证")
public class AppUserCertificationController {

    private UserCertificationService userCertificationService;

    /**
     * 实名认证
     **/
    @RequestMapping("/insert")
    @Login
    @ApiOperation("实名认证")
    public Result insert(@RequestAttribute Long userId, @ApiParam("真实姓名") String name,
                         @ApiParam("身份证号") String idNumber, @ApiParam("正面") String front,
                         @ApiParam("反面") String back,Integer classify,String phone,String address,
                         Integer sex,String infantImg,String infantImgs,String birthdate) {
        return userCertificationService.insert(userId, name, idNumber, front, back,classify,phone,address,sex,infantImg,infantImgs,birthdate,null);
    }

    /**
     * 是否进行实名
     */
    @RequestMapping("/isInsert")
    @Login
    @ApiOperation("是否进行实名")
    public Result isInsert(@RequestAttribute Long userId) {
        return userCertificationService.isInsert(userId);
    }

    /**
     * 查询自己的实名信息
     */
    @RequestMapping("/queryInsert")
    @Login
    @ApiOperation("查询自己的实名信息")
    public Result queryInsert(@RequestAttribute Long userId,Integer classify) {

        return userCertificationService.queryInsert(userId,classify);
    }



    @PostMapping("/exitMoney")
    @ApiOperation("退保证金")
    @Login
    public Result exitMoney(@RequestAttribute Long userId){
        return userCertificationService.exitMoney(userId);
    }


}
