|
|
@@ -351,21 +351,29 @@ public class UpdateUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/setQuestion", method = RequestMethod.POST)
|
|
|
- public ModelMap updateQuestion(@RequestParam String token, List<UserQuestion> userQuestions) {
|
|
|
- // 校验空参数
|
|
|
- if (CollectionUtils.isEmpty(userQuestions)) {
|
|
|
- return error("密保不能为空");
|
|
|
+ public ModelMap updateQuestion(@RequestParam String token, @RequestParam String userQuestions) {
|
|
|
+ List<UserQuestion> questions = JSON.parseArray(userQuestions, UserQuestion.class);
|
|
|
+
|
|
|
+ // 校验token
|
|
|
+ if (StringUtils.isEmpty(token)) {
|
|
|
+ return error("请求超时");
|
|
|
+ }
|
|
|
+ Token existToken = tokenService.findOne(token);
|
|
|
+ // 拿出userUU,并删除token
|
|
|
+ if (existToken.getBind() == null || !(existToken.getBind() instanceof Long)) {
|
|
|
+ // token错误,跳转到失败页面
|
|
|
+ tokenService.delete(token);
|
|
|
+ return error("请求错误");
|
|
|
}
|
|
|
+ Long userUU = (Long) existToken.getBind();
|
|
|
|
|
|
- // 从session中获取用户信息
|
|
|
- User user = (User) request.getSession().getAttribute("user");
|
|
|
- if (user == null) {
|
|
|
- return error("请求超时,请刷新重试");
|
|
|
+ // 校验空参数
|
|
|
+ if (CollectionUtils.isEmpty(questions)) {
|
|
|
+ return error("密保不能为空");
|
|
|
}
|
|
|
|
|
|
// 设置密保
|
|
|
- user.setQuestions(userQuestions);
|
|
|
- userService.save(user);
|
|
|
+ userService.setQuestion(userUU, questions);
|
|
|
return success();
|
|
|
}
|
|
|
|