|
@@ -2,17 +2,27 @@ package org.dromara.system.controller.common;
|
|
|
|
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaIgnore;
|
|
import cn.dev33.satoken.annotation.SaIgnore;
|
|
|
|
+import cn.dev33.satoken.secure.BCrypt;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
import org.dromara.common.core.domain.AjaxResult;
|
|
import org.dromara.common.core.domain.AjaxResult;
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
|
|
+import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
|
|
|
+import org.dromara.common.redis.utils.RedisUtils;
|
|
import org.dromara.common.web.core.BaseController;
|
|
import org.dromara.common.web.core.BaseController;
|
|
import org.dromara.system.domain.FormalTeacherClass;
|
|
import org.dromara.system.domain.FormalTeacherClass;
|
|
|
|
+import org.dromara.system.domain.SysUser;
|
|
|
|
+import org.dromara.system.service.ISysUserService;
|
|
import org.dromara.system.service.Task;
|
|
import org.dromara.system.service.Task;
|
|
import org.dromara.system.service.common.IAppletService;
|
|
import org.dromara.system.service.common.IAppletService;
|
|
|
|
+import org.dromara.system.utils.SendSmsUtils;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import java.time.Duration;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
+
|
|
/**小程序公共接口
|
|
/**小程序公共接口
|
|
* @Author: tjf
|
|
* @Author: tjf
|
|
* @Date: 2023/5/25 11:46
|
|
* @Date: 2023/5/25 11:46
|
|
@@ -25,9 +35,11 @@ import org.springframework.web.bind.annotation.*;
|
|
public class AppletController extends BaseController {
|
|
public class AppletController extends BaseController {
|
|
|
|
|
|
private final IAppletService appletService;
|
|
private final IAppletService appletService;
|
|
|
|
+ private final ISysUserService sysUserService;
|
|
|
|
|
|
private final Task task;
|
|
private final Task task;
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 准备下课
|
|
* 准备下课
|
|
*/
|
|
*/
|
|
@@ -92,6 +104,37 @@ public class AppletController extends BaseController {
|
|
task.afterClass();
|
|
task.afterClass();
|
|
return AjaxResult.success("成功");
|
|
return AjaxResult.success("成功");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ *忘记密码发送验证短信
|
|
|
|
+ */
|
|
|
|
+ @SaIgnore
|
|
|
|
+ @RepeatSubmit(interval = 1,timeUnit = TimeUnit.MINUTES)
|
|
|
|
+ @GetMapping("/appForgetPW/{photo}")
|
|
|
|
+ public AjaxResult appForgetPW(@PathVariable String photo)
|
|
|
|
+ {
|
|
|
|
+ String code = SendSmsUtils.getCode(4);
|
|
|
|
+ SendSmsUtils.sendSms(photo,"SMS_232893584","{\"code\":\"" + code + "\"}");
|
|
|
|
+ String key = "SMS_CODE:"+photo;
|
|
|
|
+ RedisUtils.setCacheObject(key,code, Duration.ofMinutes(5));
|
|
|
|
+ return AjaxResult.success(code);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ *忘记密码校验验证码,修改密码
|
|
|
|
+ */
|
|
|
|
+ @SaIgnore
|
|
|
|
+ @RepeatSubmit
|
|
|
|
+ @GetMapping("/appCheck")
|
|
|
|
+ public R<Void> appCheck(@RequestParam("code") String code,@RequestParam("photo") String photo,@RequestParam("password") String password)
|
|
|
|
+ {
|
|
|
|
+ String key = "SMS_CODE:"+photo;
|
|
|
|
+ Object cacheObject = RedisUtils.getCacheObject(key);
|
|
|
|
+ if (ObjectUtils.isNotEmpty(cacheObject)){
|
|
|
|
+ if (code.equals(String.valueOf(cacheObject))){
|
|
|
|
+ //修改密码
|
|
|
|
+ return toAjax(sysUserService.resetUserPwdByUserName(photo,BCrypt.hashpw(password)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.fail();
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|