LiiuZeYu_branch
lzy 10 months ago
parent dbd0ce95f8
commit cab494a012

@ -0,0 +1,79 @@
/*
* Copyright (c) 2018-2999 广 All rights reserved.
*
* https://www.mall4j.com/
*
*
*
*
*/
package com.yami.shop.security.common.controller;
import com.anji.captcha.model.common.RepCodeEnum;
import com.anji.captcha.model.common.ResponseModel;
import com.anji.captcha.model.vo.CaptchaVO;
import com.anji.captcha.service.CaptchaService;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yami.shop.common.response.ServerResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* CaptchaControllerSpring RESTful@RestController
* HTTP
* "/captcha"@RequestMappingSwagger"验证码"@Tag便
*
* @author
* @date 2022/3/25 17:33
*/
@RestController
@RequestMapping("/captcha")
@Tag(name = "验证码")
public class CaptchaController {
// 通过构造函数注入的方式引入CaptchaService用于后续调用验证码相关的业务逻辑方法比如生成验证码、验证验证码有效性等操作
private final CaptchaService captchaService;
public CaptchaController(CaptchaService captchaService) {
this.captchaService = captchaService;
}
/**
* getHTTP POST
* CaptchaVO@RequestBodyCaptchaVO
* captchaServicegetServerResponseEntity
*
*
* @param captchaVO
* @return ServerResponseEntityResponseModel
*/
@PostMapping({ "/get" })
public ServerResponseEntity<ResponseModel> get(@RequestBody CaptchaVO captchaVO) {
return ServerResponseEntity.success(captchaService.get(captchaVO));
}
/**
* checkHTTP POST
* CaptchaVOCaptchaVO
* captchaServicecheckServerResponseEntity
*
* ResponseModel.errorMsgResponseModel
* ServerResponseEntity
*
* @param captchaVO
* @return ServerResponseEntityResponseModel
*/
@PostMapping({ "/check" })
public ServerResponseEntity<ResponseModel> check(@RequestBody CaptchaVO captchaVO) {
ResponseModel responseModel;
try {
responseModel = captchaService.check(captchaVO);
} catch (Exception e) {
return ServerResponseEntity.success(ResponseModel.errorMsg(RepCodeEnum.API_CAPTCHA_COORDINATE_ERROR));
}
return ServerResponseEntity.success(responseModel);
}
}
Loading…
Cancel
Save