use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.
the class AccountController method updateUserPassword.
/**
* 修改密码
*
* @param requestBodyParamsMap request-body 内 JSON数据
* @return ApiJsonDTO 页面 JSON 传输对象
*/
@LoginAuthorization
@AccountActivation
@RequestMapping(value = "/update-password", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO updateUserPassword(@RequestBody Map<String, Object> requestBodyParamsMap) {
String username = (String) requestBodyParamsMap.get(ParamConst.USERNAME);
String newPassword = (String) requestBodyParamsMap.get(ParamConst.PASSWORD);
validationService.check(ParamConst.USERNAME, username).check(ParamConst.PASSWORD, newPassword);
// confirm input username, can to match cookie user
UserDO cookieUser = secretService.getUserInfoByAuthentication(httpService.getAuthenticationCookieValue());
userService.confirmUserMatchCookieUser(username, cookieUser);
userService.alterUserPasswordByName(username, newPassword);
return new ApiJsonDTO().success();
}
use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.
the class TopicController method removeTopic.
/**
* 删除话题
*
* @param requestBodyParamsMap request-body 内 JSON 数据
* @return ApiJsonDTO 接口 Json 传输对象
*/
@LoginAuthorization
@AccountActivation
@AdminRank
@RequestMapping(value = "/topic-remove", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO removeTopic(@RequestBody Map<String, Object> requestBodyParamsMap) {
Integer topicId = (Integer) requestBodyParamsMap.get(ParamConst.TOPIC_ID);
validationService.check(ParamConst.ID, String.valueOf(topicId));
topicService.removeTopic(topicId);
return new ApiJsonDTO().success();
}
use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.
the class AccountController method updateUserEmail.
/**
* 修改邮箱
*
* @param requestBodyParamsMap request-body 内 JSON 数据
* @return ApiJsonDTO 接口 JSON 传输对象
*/
@LoginAuthorization
@RequestMapping(value = "/update-email", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO updateUserEmail(@RequestBody Map<String, Object> requestBodyParamsMap) {
String username = (String) requestBodyParamsMap.get(ParamConst.USERNAME);
String newEmail = (String) requestBodyParamsMap.get(ParamConst.EMAIL);
validationService.check(ParamConst.USERNAME, username).check(ParamConst.EMAIL, newEmail);
UserDO cookieUser = secretService.getUserInfoByAuthentication(httpService.getAuthenticationCookieValue());
userService.confirmUserMatchCookieUser(username, cookieUser);
userService.alterUserEmail(username, newEmail);
return new ApiJsonDTO().success();
}
use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.
the class AccountController method forgetPassword.
/**
* 忘记密码
* - 验证邮箱存在性
* - 生成随机临时密码,修改邮箱用户密码 - > 临时密码
* - 发送临时密码到指定 email
*
* @param requestBodyParamsMap request-body 内 JSON 数据
* @return ApiJsonDTO 接口 JSON 传输对象
*/
@RequestMapping(value = "/forget-password", method = RequestMethod.POST)
public ApiJsonDTO forgetPassword(@RequestBody Map<String, Object> requestBodyParamsMap) {
String email = (String) requestBodyParamsMap.get(ParamConst.EMAIL);
validationService.check(ParamConst.EMAIL, email);
String temporaryRandomPassword = randomService.generateSixDigitsRandomPassword();
userService.alterUserPasswordByEmail(email, temporaryRandomPassword);
// send warn account reset temporary password mail
emailService.sendResetTemporaryPasswordMail(email, temporaryRandomPassword);
return new ApiJsonDTO().success();
}
use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.
the class AccountController method updateUserInfo.
/**
* 修改用户基本信息
* - sex 不能为空,且只能为 0 or 1
* - birthday, position, description 允许 "",但是不能为 null
*
* @param requestBodyParamsMap request-body 内 JSON 数据
* @return ApiJsonDTO 接口 JSON 传输对象
*/
@LoginAuthorization
@AccountActivation
@RequestMapping(value = "/update-profile", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO updateUserInfo(@RequestBody Map<String, Object> requestBodyParamsMap) {
Integer newSex = (Integer) requestBodyParamsMap.get(ParamConst.SEX);
String newBirthday = (String) requestBodyParamsMap.get(ParamConst.BIRTHDAY);
String newPosition = (String) requestBodyParamsMap.get(ParamConst.POSITION);
String newDescription = (String) requestBodyParamsMap.get(ParamConst.DESCRIPTION);
validationService.checkCommand(String.valueOf(newSex), "0", "1");
validationService.checkParamsNotAllNull(newBirthday, newPosition, newDescription);
validationService.check(ParamConst.BIRTHDAY, newBirthday).check(ParamConst.POSITION, newPosition).check(ParamConst.DESCRIPTION, newDescription);
// get user information in client cookie
UserDO user = secretService.getUserInfoByAuthentication(httpService.getAuthenticationCookieValue());
return new ApiJsonDTO().success().model(userService.alterUserProfile(user.getName(), newSex, newBirthday, newPosition, newDescription));
}
Aggregations