|
@@ -1,6 +1,7 @@
|
|
|
package com.koobietech.eas.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;
|
|
@@ -44,61 +45,24 @@ public class AdminLoginController {
|
|
|
|
|
|
@PostMapping("/verify.get")
|
|
|
@Operation(summary = "获取验证码", description = "前端发起获取验证码请求,后端访问静态资源返回滑动图片")
|
|
|
- public ResponseModel get(@RequestBody CaptchaVO captchaVO) {
|
|
|
- return captchaService.get(captchaVO);
|
|
|
+ public JsonResult get(@RequestBody CaptchaVO captchaVO) {
|
|
|
+ return adminLoginService.verifyToJsonResult(captchaService.get(captchaVO)) ;
|
|
|
}
|
|
|
|
|
|
@PostMapping("/verify.check")
|
|
|
@Operation(summary = "核对验证码轨迹", description = "前端把用户的滑动轨迹转化成字符串传入后端,通过算法判断轨迹是否为真人")
|
|
|
- public ResponseModel check(@RequestBody CaptchaVO captchaVO) {
|
|
|
- return captchaService.check(captchaVO);
|
|
|
+ public JsonResult check(@RequestBody CaptchaVO captchaVO) {
|
|
|
+ return adminLoginService.verifyToJsonResult(captchaService.check(captchaVO));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/verify.judge")
|
|
|
@Operation(summary = "二次校验验证码", description = "校验滑动验证码结果,是否匹配上,传参:captchaVerification")
|
|
|
- public ResponseModel verify(@RequestBody CaptchaVO captchaVO) {
|
|
|
+ public JsonResult verify(@RequestBody CaptchaVO captchaVO) {
|
|
|
ResponseModel response = captchaService.verification(captchaVO);
|
|
|
- //repCode 0000 无异常,代表成功
|
|
|
- //repCode 9999 服务器内部异常
|
|
|
- //repCode 0011 参数不能为空
|
|
|
- //repCode 6110 验证码已失效,请重新获取
|
|
|
- //repCode 6111 验证失败
|
|
|
- //repCode 6112 获取验证码失败,请联系管理员
|
|
|
- //repCode 6113 底图未初始化成功,请检查路径
|
|
|
- //repCode 6201 get接口请求次数超限,请稍后再试!
|
|
|
- //repCode 6206 无效请求,请重新获取验证码
|
|
|
- //repCode 6202 接口验证失败数过多,请稍后再试
|
|
|
- //repCode 6204 check接口请求次数超限,请稍后再试!
|
|
|
if (!response.isSuccess()) {
|
|
|
- String repCode = response.getRepCode();
|
|
|
- switch (repCode) {
|
|
|
- case "9999":
|
|
|
- throw new EasException("服务器内部异常", 9999);
|
|
|
- case "0011":
|
|
|
- throw new EasException("参数不能为空", 0011);
|
|
|
- case "6110":
|
|
|
- throw new EasException("验证码已失效,请重新获取", 6110);
|
|
|
- case "6111":
|
|
|
- throw new EasException("验证失败", 6111);
|
|
|
- case "6112":
|
|
|
- throw new EasException("获取验证码失败,请联系管理员", 6112);
|
|
|
- case "6113":
|
|
|
- throw new EasException("底图未初始化成功,请检查路径", 6113);
|
|
|
- case "6201":
|
|
|
- throw new EasException("get接口请求次数超限,请稍后再试!", 6201);
|
|
|
- case "6206":
|
|
|
- throw new EasException("无效请求,请重新获取验证码", 6206);
|
|
|
- case "6202":
|
|
|
- throw new EasException("接口验证失败数过多,请稍后再试", 6202);
|
|
|
- case "6204":
|
|
|
- throw new EasException("check接口请求次数超限,请稍后再试!", 6204);
|
|
|
- default:
|
|
|
- // 处理未知的 repCode
|
|
|
- throw new EasException("未知错误,你干嘛~哎哟~", -1);
|
|
|
- }
|
|
|
+ throw new EasException( response.getRepMsg() , Integer.parseInt(response.getRepCode()));
|
|
|
}
|
|
|
-
|
|
|
- return response;
|
|
|
+ return adminLoginService.verifyToJsonResult(response);
|
|
|
}
|
|
|
|
|
|
|