Search in sources :

Example 1 with AccountActivation

use of org.neusoft.neubbs.controller.annotation.AccountActivation in project neubbs by nuitcoder.

the class TopicController method updateTopic.

/**
 * 编辑话题
 *
 * @param requestBodyParamsMap request-body 内 JSON 数据
 * @return ApiJsonDTO 接口 JSON 传输对象
 */
@LoginAuthorization
@AccountActivation
@RequestMapping(value = "/topic-update", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO updateTopic(@RequestBody Map<String, Object> requestBodyParamsMap) {
    Integer topicId = (Integer) requestBodyParamsMap.get(ParamConst.TOPIC_ID);
    String newCategoryNick = (String) requestBodyParamsMap.get(ParamConst.CATEGORY);
    String newTitle = (String) requestBodyParamsMap.get(ParamConst.TITLE);
    String newTopicContent = (String) requestBodyParamsMap.get(ParamConst.CONTENT);
    validationService.check(ParamConst.ID, String.valueOf(topicId)).check(ParamConst.TOPIC_CATEGORY_NICK, newCategoryNick).check(ParamConst.TOPIC_TITLE, newTitle).check(ParamConst.TOPIC_CONTENT, newTopicContent);
    topicService.alterTopicContent(topicId, newCategoryNick, newTitle, newTopicContent);
    return new ApiJsonDTO().success();
}
Also used : ApiJsonDTO(org.neusoft.neubbs.dto.ApiJsonDTO) AccountActivation(org.neusoft.neubbs.controller.annotation.AccountActivation) LoginAuthorization(org.neusoft.neubbs.controller.annotation.LoginAuthorization) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with AccountActivation

use of org.neusoft.neubbs.controller.annotation.AccountActivation in project neubbs by nuitcoder.

the class TopicController method attentionTopic.

/**
 * 关注话题
 *
 * @param requestBodyParamsMap request-body 内 JSON 数据
 * @return ApiJsonDTO 接口 JSON 传输对象
 */
@LoginAuthorization
@AccountActivation
@RequestMapping(value = "/topic/attention", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO attentionTopic(@RequestBody Map<String, Object> requestBodyParamsMap) {
    Integer topicId = (Integer) requestBodyParamsMap.get(ParamConst.TOPIC_ID);
    validationService.check(ParamConst.TOPIC_ID, String.valueOf(topicId));
    UserDO cookieUser = secretService.getUserInfoByAuthentication(httpService.getAuthenticationCookieValue());
    return new ApiJsonDTO().success().model(topicService.operateAttentionTopic(cookieUser.getId(), topicId));
}
Also used : UserDO(org.neusoft.neubbs.entity.UserDO) ApiJsonDTO(org.neusoft.neubbs.dto.ApiJsonDTO) AccountActivation(org.neusoft.neubbs.controller.annotation.AccountActivation) LoginAuthorization(org.neusoft.neubbs.controller.annotation.LoginAuthorization) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with AccountActivation

use of org.neusoft.neubbs.controller.annotation.AccountActivation in project neubbs by nuitcoder.

the class TopicController method removeTopicReply.

/**
 * 删除回复
 *
 * @param requestBodyParamsMap request-body 内 JSON 数据
 * @return ApiJsonDTO 接口 JSON 传输对象
 */
@LoginAuthorization
@AccountActivation
@AdminRank
@RequestMapping(value = "/topic/reply-remove", method = RequestMethod.POST, consumes = "application/json")
public ApiJsonDTO removeTopicReply(@RequestBody Map<String, Object> requestBodyParamsMap) {
    Integer replyId = (Integer) requestBodyParamsMap.get(ParamConst.REPLY_ID);
    validationService.check(ParamConst.ID, String.valueOf(replyId));
    topicService.removeReply(replyId);
    return new ApiJsonDTO().success();
}
Also used : ApiJsonDTO(org.neusoft.neubbs.dto.ApiJsonDTO) AccountActivation(org.neusoft.neubbs.controller.annotation.AccountActivation) AdminRank(org.neusoft.neubbs.controller.annotation.AdminRank) LoginAuthorization(org.neusoft.neubbs.controller.annotation.LoginAuthorization) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with AccountActivation

use of org.neusoft.neubbs.controller.annotation.AccountActivation in project neubbs by nuitcoder.

the class AccountController method followingUser.

/**
 * 关注用户
 *      - 主动关注其余用户
 *      - 自动切换:有 -> 无, 无 -> 有
 *
 * @param requestBodyParams request-body 内 JSON数据
 * @return ApiJsonDTO 页面 JSON 传输对象
 */
@RequestMapping(value = "/following", method = RequestMethod.POST, consumes = "application/json")
@LoginAuthorization
@AccountActivation
public ApiJsonDTO followingUser(@RequestBody Map<String, Object> requestBodyParams) {
    Integer followingUserId = (Integer) requestBodyParams.get(ParamConst.USER_ID);
    validationService.check(ParamConst.USER_ID, String.valueOf(followingUserId));
    UserDO cookieUser = secretService.getUserInfoByAuthentication(httpService.getAuthenticationCookieValue());
    return new ApiJsonDTO().success().buildMap(ParamConst.FOLLOWING_USER_ID, userService.operateFollowUser(cookieUser.getId(), followingUserId));
}
Also used : UserDO(org.neusoft.neubbs.entity.UserDO) ApiJsonDTO(org.neusoft.neubbs.dto.ApiJsonDTO) AccountActivation(org.neusoft.neubbs.controller.annotation.AccountActivation) LoginAuthorization(org.neusoft.neubbs.controller.annotation.LoginAuthorization) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with AccountActivation

use of org.neusoft.neubbs.controller.annotation.AccountActivation 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();
}
Also used : UserDO(org.neusoft.neubbs.entity.UserDO) ApiJsonDTO(org.neusoft.neubbs.dto.ApiJsonDTO) AccountActivation(org.neusoft.neubbs.controller.annotation.AccountActivation) LoginAuthorization(org.neusoft.neubbs.controller.annotation.LoginAuthorization) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AccountActivation (org.neusoft.neubbs.controller.annotation.AccountActivation)15 LoginAuthorization (org.neusoft.neubbs.controller.annotation.LoginAuthorization)14 ApiJsonDTO (org.neusoft.neubbs.dto.ApiJsonDTO)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)14 UserDO (org.neusoft.neubbs.entity.UserDO)11 AdminRank (org.neusoft.neubbs.controller.annotation.AdminRank)2 LinkedHashMap (java.util.LinkedHashMap)1 PermissionException (org.neusoft.neubbs.exception.PermissionException)1 HandlerMethod (org.springframework.web.method.HandlerMethod)1