|
|
@@ -8,10 +8,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -39,7 +36,7 @@ public class UpdateUserController extends BaseController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/CheckType", method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/checkType", method = RequestMethod.GET)
|
|
|
public ModelMap getCheckType() {
|
|
|
// 获取用户信息
|
|
|
UserAccount userAccount = SystemSession.getUserAccount();
|
|
|
@@ -49,9 +46,9 @@ public class UpdateUserController extends BaseController {
|
|
|
ModelMap data = new ModelMap();
|
|
|
data.put("mobile", Status.AUTHENTICATED.getCode() == user.getMobileValidCode() ? user.getMobile() : null);
|
|
|
data.put("email", Status.AUTHENTICATED.getCode() == user.getEmailValidCode() ? user.getEmail() : null);
|
|
|
- data.put("question", CollectionUtils.isEmpty(user.getQuestions()) ? user.getQuestions() : null);
|
|
|
+ data.put("questions", !CollectionUtils.isEmpty(user.getQuestions()) ? user.getQuestions() : null);
|
|
|
request.getSession().setAttribute("user", user);
|
|
|
- return success();
|
|
|
+ return success(data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -120,7 +117,7 @@ public class UpdateUserController extends BaseController {
|
|
|
public ModelMap checkByEmail(String operate, @RequestParam String email) {
|
|
|
// 校验空参数
|
|
|
if (StringUtils.isEmpty(email)) {
|
|
|
- return error("手机号不能为空");
|
|
|
+ return error("邮箱不能为空");
|
|
|
}
|
|
|
|
|
|
// 根据邮箱找到用户
|
|
|
@@ -135,6 +132,8 @@ public class UpdateUserController extends BaseController {
|
|
|
data.put("url", "http://192.168.253.66:8081/update/user/setMobile?token=" + token);
|
|
|
} else if ("email".equals(operate)) {
|
|
|
data.put("url", "http://192.168.253.66:8081/update/user/setMail?token=" + token);
|
|
|
+ } else if ("question".equals(operate)) {
|
|
|
+ data.put("url", "http://192.168.253.66:8081/update/user//setQuestion?token=" + token);
|
|
|
}
|
|
|
|
|
|
// 发送邮件
|
|
|
@@ -327,6 +326,7 @@ public class UpdateUserController extends BaseController {
|
|
|
return success();
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/setQuestion", method = RequestMethod.POST)
|
|
|
public ModelMap updateQuestion(@RequestParam String token, List<UserQuestion> userQuestions) {
|
|
|
// 校验空参数
|
|
|
if (CollectionUtils.isEmpty(userQuestions)) {
|
|
|
@@ -344,4 +344,25 @@ public class UpdateUserController extends BaseController {
|
|
|
userService.save(user);
|
|
|
return success();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验验证码(只用于简单的校验,token不删除)
|
|
|
+ * @param type 校验接收验证码类型(mobile or email)
|
|
|
+ * @param token 验证码token
|
|
|
+ * @param code 验证码
|
|
|
+ * @param account 接收验证码账号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/checkCode/{type}", method = RequestMethod.POST)
|
|
|
+ public ModelMap checkCode(@PathVariable String type, @RequestParam String token, String code, String account) {
|
|
|
+ // 校验验证码
|
|
|
+ if ("mobile".equals(type)) {
|
|
|
+ checkMobileCode(token, account, code);
|
|
|
+ } else if ("email".equals(type)) {
|
|
|
+ checkEmailCode(token, account, code);
|
|
|
+ }
|
|
|
+
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|