package org.springblade.modules.app.web;

import com.wn.common.controller.BaseController;
import com.wn.common.datamodel.ResultDTO;
import org.springblade.modules.app.dto.InnerCaptchaReqDTO;
import org.springblade.modules.app.dto.InnerCaptchaResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.auth.permission.DisableLoginVerify;
import org.springblade.modules.app.manager.CaptchaManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("app/inner/captcha")
public class InnerCaptchaController extends BaseController {

    @Autowired
    private CaptchaManager captchaManager;

    @DisableLoginVerify
    @ResponseBody
    @PostMapping("/check")
    public ResponseEntity<ResultDTO<InnerCaptchaResultDTO>> checkCaptcha(@RequestBody InnerCaptchaReqDTO innerCaptchaReqDTO) {
        return success(captchaManager.checkCaptcha(innerCaptchaReqDTO));
    }

    @DisableLoginVerify
    @ResponseBody
    @PostMapping("/verify")
    public ResponseEntity<ResultDTO<InnerCaptchaResultDTO>> verifyCaptcha(@RequestBody InnerCaptchaReqDTO innerCaptchaReqDTO) {
        return success(captchaManager.verificationCaptcha(innerCaptchaReqDTO));
    }
}
