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

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.artificer.entity.Certification;
import com.sqx.modules.artificer.service.RealNameService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/realname")
@Api(value = "技师端-技师实名认证", tags = {"技师端-技师实名认证"})
public class AppRealNameController {

    @Autowired
    private RealNameService realNameService;

    @Login
    @ApiOperation("回显实名认证信息")
    @GetMapping(value = "selectRealName")
    public Result selectRealName(@RequestAttribute Long userId){

        return realNameService.selectRealName(userId);
    }

    @Login
    @ApiOperation("修改实名认证信息")
    @PostMapping(value = "updateRealName")
    public Result updateRealName(@RequestAttribute Long userId, @RequestBody Certification certification){
        certification.setUserId(userId);
        return realNameService.updateRealName(certification);
    }

    //申请退还保证金
    @Login
    @ApiOperation("申请退还保证金")
    @PostMapping(value = "retreatCashDeposit")
    public Result retreatCashDeposit(@RequestAttribute Long userId){

        return realNameService.retreatCashDeposit(userId);
    }

    @Login
    @ApiOperation("实名认证")
    @PostMapping("/auditRealName")
    public Result auditRealName(@RequestAttribute Long userId,@RequestBody Certification certification){
        certification.setUserId(userId);
        return realNameService.updateRealName(certification);
    }



}
