use of org.neusoft.neubbs.controller.annotation.AccountActivation 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.controller.annotation.AccountActivation 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));
}
use of org.neusoft.neubbs.controller.annotation.AccountActivation in project neubbs by nuitcoder.
the class FileController method uploadUserAvatar.
/**
* 上传用户头像
* - 上传文件类型需满足 MediaType.MULTIPART_FORM_DATA_VALUE(multipart/form-data)
* - 执行流程
* - 检查上传头像规范(空,类型,文件大小)
* - Cookie 内获取用户信息
* - ftp 服务上传用户头像
* - 修改数据库用户个人信息(头像名)
*
* @param avatarFile 用户上传的文件对象
* @return ApiJsonDTO 接口 JSON 传输对象
*/
@LoginAuthorization
@AccountActivation
@RequestMapping(value = "/avatar", method = RequestMethod.POST, consumes = "multipart/form-data")
public ApiJsonDTO uploadUserAvatar(@RequestParam("avatarImageFile") MultipartFile avatarFile) {
validationService.checkUserUploadAvatarNorm(avatarFile);
UserDO cookieUser = secretService.getUserInfoByAuthentication(httpService.getAuthenticationCookieValue());
ftpService.uploadUserAvatar(cookieUser, avatarFile);
userService.alterUserAvatar(cookieUser.getName(), ftpService.generateServerAvatarFileName(avatarFile));
return new ApiJsonDTO().success().message(ApiMessage.UPLOAD_SUCCESS);
}
use of org.neusoft.neubbs.controller.annotation.AccountActivation in project neubbs by nuitcoder.
the class TopicController method updateTopicReply.
/**
* 编辑回复
*
* @param requestBodyParamsMap request-body 内 JSON 数据
* @return ApiJsonDTO 接口 JSON 传输对象
*/
@LoginAuthorization
@AccountActivation
@RequestMapping(value = "/topic/reply-update", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO updateTopicReply(@RequestBody Map<String, Object> requestBodyParamsMap) {
Integer replyId = (Integer) requestBodyParamsMap.get(ParamConst.REPLY_ID);
String newReplyContent = (String) requestBodyParamsMap.get(ParamConst.CONTENT);
validationService.check(ParamConst.ID, String.valueOf(replyId)).check(ParamConst.REPLY_CONTENT, newReplyContent);
topicService.alterReplyContent(replyId, newReplyContent);
return new ApiJsonDTO().success();
}
use of org.neusoft.neubbs.controller.annotation.AccountActivation in project neubbs by nuitcoder.
the class TopicController method releaseTopic.
/**
* 发布话题
*
* @param requestBodyParamsMap request-body 内 JSON 数据
* @return ApiJsonDTO 接口 JSON 传输数据
*/
@LoginAuthorization
@AccountActivation
@RequestMapping(value = "/topic", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO releaseTopic(@RequestBody Map<String, Object> requestBodyParamsMap) {
String category = (String) requestBodyParamsMap.get(ParamConst.CATEGORY);
String title = (String) requestBodyParamsMap.get(ParamConst.TITLE);
String topicContent = (String) requestBodyParamsMap.get(ParamConst.CONTENT);
validationService.check(ParamConst.TOPIC_CATEGORY_NICK, category).check(ParamConst.TOPIC_TITLE, title).check(ParamConst.TOPIC_CONTENT, topicContent);
UserDO cookieUser = secretService.getUserInfoByAuthentication(httpService.getAuthenticationCookieValue());
return new ApiJsonDTO().success().model(topicService.saveTopic(cookieUser.getId(), category, title, topicContent));
}
Aggregations