|
@@ -1,7 +1,11 @@
|
|
|
package com.koobietech.eas.controller;
|
|
|
|
|
|
|
|
|
-import com.koobietech.eas.common.pojo.JwtUserDto;
|
|
|
+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 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 +22,10 @@ public class AdminLoginController {
|
|
|
@Resource
|
|
|
private AdminLoginService adminLoginService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CaptchaService captchaService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@PostMapping("/adminLogin")
|
|
|
@Operation(summary = "管理员登录", description = "用户名和密码为请求载荷,若登录成功,返回两token")
|
|
@@ -29,11 +37,34 @@ 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 JsonResult get(@RequestBody CaptchaVO captchaVO) {
|
|
|
+ return adminLoginService.verifyToJsonResult(captchaService.get(captchaVO)) ;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/verify.check")
|
|
|
+ @Operation(summary = "核对验证码轨迹", description = "前端把用户的滑动轨迹转化成字符串传入后端,通过算法判断轨迹是否为真人")
|
|
|
+ public JsonResult check(@RequestBody CaptchaVO captchaVO) {
|
|
|
+ return adminLoginService.verifyToJsonResult(captchaService.check(captchaVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/verify.judge")
|
|
|
+ @Operation(summary = "二次校验验证码", description = "校验滑动验证码结果,是否匹配上,传参:captchaVerification")
|
|
|
+ public JsonResult verify(@RequestBody CaptchaVO captchaVO) {
|
|
|
+ ResponseModel response = captchaService.verification(captchaVO);
|
|
|
+ if (!response.isSuccess()) {
|
|
|
+ throw new EasException( response.getRepMsg() , Integer.parseInt(response.getRepCode()));
|
|
|
+ }
|
|
|
+ return adminLoginService.verifyToJsonResult(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|