|
@@ -1,7 +1,10 @@
|
|
|
package boot.modules.manage.controller;
|
|
|
|
|
|
+import boot.common.bean.LocalUser;
|
|
|
import boot.common.constant.SchoolConstant;
|
|
|
import boot.common.enums.SmsTypeEnum;
|
|
|
+import boot.common.interceptor.AuthCheck;
|
|
|
+import boot.common.interceptor.ManageCheck;
|
|
|
import boot.common.respond.ApiCode;
|
|
|
import boot.common.respond.ApiResult;
|
|
|
import boot.common.respond.EException;
|
|
@@ -9,6 +12,7 @@ import boot.common.utils.JwtToken;
|
|
|
import boot.common.utils.RedisUtils;
|
|
|
import boot.modules.manage.pojo.Manage;
|
|
|
import boot.modules.manage.service.ManageService;
|
|
|
+import boot.modules.user.param.ForgetParam;
|
|
|
import boot.modules.user.param.HLoginParam;
|
|
|
import boot.modules.user.param.RegParam;
|
|
|
import boot.modules.user.param.VerityParam;
|
|
@@ -127,4 +131,38 @@ public class ManageController {
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @ManageCheck
|
|
|
+ @ApiOperation(value = "退出登录", notes = "退出登录")
|
|
|
+ @PostMapping(value = "/logout")
|
|
|
+ public ApiResult<String> logout(HttpServletRequest request) {
|
|
|
+ String bearerToken = request.getHeader("Authorization");
|
|
|
+ String[] tokens = bearerToken.split(" ");
|
|
|
+ String token = tokens[1];
|
|
|
+ authService.logout(LocalUser.getUser().getUsername(), token);
|
|
|
+ return ApiResult.ok("退出成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "忘记密码", notes = "忘记密码")
|
|
|
+ @PostMapping(value = "/forget")
|
|
|
+ public ApiResult<String> forget(@Validated @RequestBody ForgetParam param) {
|
|
|
+ Object codeObj = redisUtil.get("code_" + param.getAccount());
|
|
|
+ if (codeObj == null) {
|
|
|
+ return ApiResult.fail("请先获取验证码");
|
|
|
+ }
|
|
|
+ String code = codeObj.toString();
|
|
|
+ if (!StrUtil.equals(code, param.getCaptcha())) {
|
|
|
+ return ApiResult.fail("验证码错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ Manage manage = manageService.getOne(Wrappers.<Manage>lambdaQuery()
|
|
|
+ .eq(Manage::getPhone, param.getAccount()), false);
|
|
|
+ if (ObjectUtil.isNull(manage)) {
|
|
|
+ return ApiResult.fail("该用户不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ manage.setPassword(SecureUtil.md5(param.getPassword()));
|
|
|
+ manageService.updateById(manage);
|
|
|
+ return ApiResult.ok("密码重置成功");
|
|
|
+ }
|
|
|
}
|