package com.ruoyi.controller;

import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.code.Token;
import com.ruoyi.controller.req.OrdinaryAuthReq;
import com.ruoyi.controller.req.UpscaleAuthReq;
import com.ruoyi.frequency.auth.entity.Auth;
import com.ruoyi.frequency.auth.service.AuthService;
import com.ruoyi.frequency.highendauth.service.HighendAuthService;
import com.ruoyi.response.ResponseData;
import com.ruoyi.vo.RyController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 认证
 */
@CrossOrigin
@RestController
@RequestMapping("/api/auth")
@Api(tags = "认证")
public class ApiAuthController extends RyController {

    @Autowired
    private AuthService authService;

    @Autowired
    private HighendAuthService highendAuthService;


    @PostMapping("/ordinaryAuth")
    @ApiOperation(value = "普通认证", notes = "普通认证")
    @UserLoginToken(userTokenPre = {Token.store})
    public ResponseData ordinaryAuth(@RequestBody OrdinaryAuthReq req) {
        return authService.ordinaryAuth(req, getUserVo());
    }


    @PostMapping("/highendAuth")
    @ApiOperation(value = "高端认证", notes = "高端认证")
    @UserLoginToken(userTokenPre = {Token.store})
    public ResponseData highendAuth(@RequestBody UpscaleAuthReq req) {
        return highendAuthService.highendAuth(req, getUserVo());
    }

    @PostMapping("/ordinaryAuthDetail/{type}")
    @ApiOperation(value = "普通认证详情", notes = "普通认证详情")
    @UserLoginToken
    public ResponseData<Auth> ordinaryAuthDetail(@PathVariable Integer type) {
        return authService.ordinaryAuthDetail(type,getUserVo());
    }
}
