|
|
@@ -23,9 +23,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import com.goafanti.admin.service.AftFileService;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
+import com.goafanti.common.enums.MobileCodeCheckOverTimeSign;
|
|
|
+import com.goafanti.common.enums.UserType;
|
|
|
+import com.goafanti.common.model.User;
|
|
|
import com.goafanti.common.service.IndustryCategoryService;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.MobileMessageUtils;
|
|
|
+import com.goafanti.common.utils.PasswordUtil;
|
|
|
import com.goafanti.common.utils.PictureUtils;
|
|
|
import com.goafanti.common.utils.TimeUtils;
|
|
|
import com.goafanti.common.utils.VerifyCodeUtils;
|
|
|
@@ -70,6 +74,9 @@ public class PublicController extends BaseController {
|
|
|
@Value(value = "${patentTemplate}")
|
|
|
private String patentTemplate = null;
|
|
|
|
|
|
+ @Resource(name = "passwordUtil")
|
|
|
+ private PasswordUtil passwordUtil;
|
|
|
+
|
|
|
/**
|
|
|
* 获取验证码
|
|
|
*
|
|
|
@@ -123,7 +130,6 @@ public class PublicController extends BaseController {
|
|
|
}
|
|
|
if (!VerifyCodeUtils.verifyCode(verificationCode)) {
|
|
|
res.getError().add(buildError(ErrorConstants.VCODE_ERROR, "", "图形验证码输入错误!"));
|
|
|
-
|
|
|
return res;
|
|
|
}
|
|
|
}
|
|
|
@@ -132,8 +138,8 @@ public class PublicController extends BaseController {
|
|
|
|| TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE_TIME) == "") {
|
|
|
sendMessage(mobile, res);
|
|
|
} else if (TimeUtils.checkOverTime("getMCode")) {
|
|
|
- TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE);
|
|
|
- TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE_TIME);
|
|
|
+ VerifyCodeUtils.clearMobileCode();
|
|
|
+ VerifyCodeUtils.clearMobileCodeTime();
|
|
|
sendMessage(mobile, res);
|
|
|
} else {
|
|
|
res.getError().add(buildError(ErrorConstants.MCODE_FREQUENCY_ERROR, "", "手机验证码发送频繁!"));
|
|
|
@@ -289,7 +295,7 @@ public class PublicController extends BaseController {
|
|
|
if (!StringUtils.isBlank(path)) {
|
|
|
return handleDownloadFile(response, fileName, path, res);
|
|
|
} else {
|
|
|
- res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "下载文件不存在!"));
|
|
|
+ res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "下载文件不存在!"));
|
|
|
return res;
|
|
|
}
|
|
|
}
|
|
|
@@ -378,10 +384,10 @@ public class PublicController extends BaseController {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- if (TimeUtils.checkOverTime("register")) {
|
|
|
+ if (TimeUtils.checkOverTime(MobileCodeCheckOverTimeSign.REGISTER.getCode())) {
|
|
|
res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "", "手机验证码超时失效!"));
|
|
|
- TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE);
|
|
|
- TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE_TIME);
|
|
|
+ VerifyCodeUtils.clearMobileCode();
|
|
|
+ VerifyCodeUtils.clearMobileCodeTime();
|
|
|
return res;
|
|
|
}
|
|
|
if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.M_CODE).equals(mobileCode)) {
|
|
|
@@ -392,4 +398,62 @@ public class PublicController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 重置密码
|
|
|
+ *
|
|
|
+ * @param resetCode
|
|
|
+ * @param mobile
|
|
|
+ * @param type
|
|
|
+ * @param newPwd
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
|
|
|
+ public Result resetPwd(String resetCode, String mobile, Integer type, String newPwd) {
|
|
|
+ Result res = new Result();
|
|
|
+ if (TimeUtils.checkOverTime(MobileCodeCheckOverTimeSign.RESETCODE.getCode())) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.RESET_CODE_OVERTIME, "", "页面超时失效,请重新获取验证码!"));
|
|
|
+ cleanCodeSession();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.RESET_CODE).equals(resetCode)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.RESET_CODE_ERROR, "", "页面失效,请重新获取验证码!"));
|
|
|
+ cleanCodeSession();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(newPwd)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新密码"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(mobile)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "mobile"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!UserType.ORGANIZATION.getCode().equals(type) || !UserType.PERSONAL.getCode().equals(type)) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "type"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = userService.selectByMobieAndType(mobile, type);
|
|
|
+ if (null == user) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "mobile"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ user.setPassword(newPwd);
|
|
|
+ user.setPassword(passwordUtil.getEncryptPwd(user));
|
|
|
+ userService.updateByPrimaryKey(user);
|
|
|
+ VerifyCodeUtils.clearResetCode();
|
|
|
+ VerifyCodeUtils.clearResetCodeTime();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void cleanCodeSession() {
|
|
|
+ VerifyCodeUtils.clearResetCode();
|
|
|
+ VerifyCodeUtils.clearResetCodeTime();
|
|
|
+ VerifyCodeUtils.clearMobileCode();
|
|
|
+ VerifyCodeUtils.clearMobileCodeTime();
|
|
|
+ }
|
|
|
+
|
|
|
}
|