package org.jeecg.modules.xcx.auth.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.modules.xcx.auth.req.ApplyAuthReq;
import org.jeecg.modules.xcx.auth.service.IAuthService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Api(tags = "实名认证接口")
@Slf4j
@RestController
@RequestMapping("/auth")
public class AuthController {

    @Resource
    private IAuthService authService;

    @ApiOperation(value = "实名认证")
    @PostMapping("/apply")
    public Result<?> applyAuth(HttpServletRequest request , ApplyAuthReq applyAuthReq){
        applyAuthReq.setToken(TokenUtils.getTokenByRequest(request));
        return authService.applyAuth(applyAuthReq);
    }

    @ApiOperation(value = "实名认证详情")
    @GetMapping("/info")
    public Result<?> authInfo(HttpServletRequest request){
        return authService.authInfo(TokenUtils.getTokenByRequest(request));
    }

}
