|
|
@@ -0,0 +1,51 @@
|
|
|
+package com.nb.app.assistant.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.nb.app.assistant.controller.vo.ResetPswVo;
|
|
|
+import com.nb.app.assistant.service.LocalAssistantUserService;
|
|
|
+import com.nb.app.assistant.utils.ResetPswUtil;
|
|
|
+import com.nb.core.annotation.IgnoreToken;
|
|
|
+import com.nb.core.exception.CustomException;
|
|
|
+import com.nb.core.result.R;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author lifang
|
|
|
+ * @version 1.0.0
|
|
|
+ * @ClassName UserController.java
|
|
|
+ * @Description TODO
|
|
|
+ * @createTime 2022年09月14日 15:16:00
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/assist/phone")
|
|
|
+@Api(tags = "忘记密码")
|
|
|
+@Slf4j
|
|
|
+public class AssistUserController {
|
|
|
+ private final LocalAssistantUserService userService;
|
|
|
+ private final ResetPswUtil resetPswUtil;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/psw/reset")
|
|
|
+ @ApiOperation(value = "重置密码",notes = "请先调用【验证码】相关接口/api/assist/captcha/reset/validate进行密码校验并获取token")
|
|
|
+ public R<Boolean> reset(@RequestBody@Validated ResetPswVo resource){
|
|
|
+ String token = resetPswUtil.getToken(resource.getPhone(), resource.getCaptcha());
|
|
|
+ if (StrUtil.isEmpty(token)) {
|
|
|
+ throw new CustomException("该请求已失效,请刷新后重试");
|
|
|
+ }
|
|
|
+ if(ObjectUtil.equal(token,resource.getResetToken())){
|
|
|
+ throw new CustomException("token错误,请刷新后重试");
|
|
|
+ }
|
|
|
+ return R.success(userService.resetPsw(resource.getPhone(),resource.getNewPsw()));
|
|
|
+ }
|
|
|
+}
|