|
@@ -1,7 +1,10 @@
|
|
|
package com.koobietech.eas.controller;
|
|
|
|
|
|
|
|
|
-import com.koobietech.eas.common.pojo.JwtUserDto;
|
|
|
+import com.anji.captcha.model.common.ResponseModel;
|
|
|
+import com.anji.captcha.model.vo.CaptchaVO;
|
|
|
+import com.anji.captcha.service.CaptchaService;
|
|
|
+import com.koobietech.eas.common.exception.EasException;
|
|
|
import com.koobietech.eas.common.result.JsonResult;
|
|
|
import com.koobietech.eas.dao.Pojo.AdminPojo;
|
|
|
import com.koobietech.eas.dao.dto.LoginToken;
|
|
@@ -18,6 +21,10 @@ public class AdminLoginController {
|
|
|
@Resource
|
|
|
private AdminLoginService adminLoginService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CaptchaService captchaService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@PostMapping("/adminLogin")
|
|
|
@Operation(summary = "管理员登录", description = "用户名和密码为请求载荷,若登录成功,返回两token")
|
|
@@ -29,11 +36,71 @@ public class AdminLoginController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/refreshToken")
|
|
|
- @Operation(summary = "刷新token", description = "当token过期,在请求头中携带refresh token,若刷新成功,返回新的token和refresh token")
|
|
|
+ @Operation(summary = "刷新token", description = "当token过期,在请求头中携带refresh token,若刷新成功,返回新的token和refresh token")
|
|
|
public JsonResult refreshToken(@RequestHeader("Authorization") String refreshToken) {
|
|
|
// 返回新的token和refresh token
|
|
|
return JsonResult.data(adminLoginService.refreshToken(refreshToken));
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/verify.get")
|
|
|
+ @Operation(summary = "获取验证码", description = "前端发起获取验证码请求,后端访问静态资源返回滑动图片")
|
|
|
+ public ResponseModel get(@RequestBody CaptchaVO captchaVO) {
|
|
|
+ return captchaService.get(captchaVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/verify.check")
|
|
|
+ @Operation(summary = "核对验证码轨迹", description = "前端把用户的滑动轨迹转化成字符串传入后端,通过算法判断轨迹是否为真人")
|
|
|
+ public ResponseModel check(@RequestBody CaptchaVO captchaVO) {
|
|
|
+ return captchaService.check(captchaVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/verify.judge")
|
|
|
+ @Operation(summary = "二次校验验证码", description = "校验滑动验证码结果,是否匹配上,传参:captchaVerification")
|
|
|
+ public ResponseModel 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|