package cn.stylefeng.roses.kernel.system.modular.user.controller;
|
|
import cn.stylefeng.roses.kernel.rule.enums.ResBizTypeEnum;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
import cn.stylefeng.roses.kernel.security.api.DragCaptchaApi;
|
import cn.stylefeng.roses.kernel.security.api.ImageCaptchaApi;
|
import cn.stylefeng.roses.kernel.security.api.pojo.DragCaptchaImageDTO;
|
import cn.stylefeng.roses.kernel.security.api.pojo.ImageCaptcha;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
|
import static cn.stylefeng.roses.kernel.rule.constants.RuleConstants.BASE64_IMG_PREFIX;
|
|
/**
|
* 图形验证码
|
*
|
* @author chenjinlong
|
* @date 2021/1/15 15:11
|
*/
|
@Api(tags = "图形验证码")
|
@RestController
|
@ApiResource(name = "用户登录图形验证码", resBizType = ResBizTypeEnum.SYSTEM)
|
public class KaptchaController {
|
|
@Resource
|
private ImageCaptchaApi captchaApi;
|
|
@Resource
|
private DragCaptchaApi dragCaptchaApi;
|
|
/**
|
* 获取图形验证码
|
*
|
* @author fengshuonan
|
* @date 2021/7/5 12:00
|
*/
|
@ApiOperation(value = "获取图形验证码")
|
@GetResource(name = "获取图形验证码", path = "/captcha", requiredPermission = false, requiredLogin = false)
|
public ResponseData<ImageCaptcha> captcha() {
|
return new SuccessResponseData<>(captchaApi.captcha());
|
}
|
|
/**
|
* 获取拖拽验证码
|
*
|
* @author fengshuonan
|
* @date 2021/7/5 12:00
|
*/
|
@ApiOperation(value = "获取拖拽验证码")
|
@GetResource(name = "获取图形验证码", path = "/dragCaptcha", requiredPermission = false, requiredLogin = false)
|
public ResponseData<DragCaptchaImageDTO> dragCaptcha() {
|
DragCaptchaImageDTO captcha = dragCaptchaApi.createCaptcha();
|
captcha.setSrcImage(BASE64_IMG_PREFIX + captcha.getSrcImage());
|
captcha.setCutImage(BASE64_IMG_PREFIX + captcha.getCutImage());
|
return new SuccessResponseData<>(captcha);
|
}
|
|
}
|