Search in sources :

Example 1 with ApiJsonDTO

use of org.neusoft.neubbs.dto.ApiJsonDTO 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 ApiJsonDTO

use of org.neusoft.neubbs.dto.ApiJsonDTO 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 ApiJsonDTO

use of org.neusoft.neubbs.dto.ApiJsonDTO 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 ApiJsonDTO

use of org.neusoft.neubbs.dto.ApiJsonDTO in project neubbs by nuitcoder.

the class AccountController method validateCaptcha.

/**
 * 校验验证码
 *      - 比较用户输入验证,是否匹配 session 中储存 5 位随机验证码
 *
 * @param captcha 用户输入验证码
 * @return ApiJsonDTO 接口 JSON 传输对象
 */
@RequestMapping(value = "/validate-captcha", method = RequestMethod.GET)
public ApiJsonDTO validateCaptcha(@RequestParam(value = "captcha", required = false) String captcha) {
    validationService.check(ParamConst.CAPTCHA, captcha);
    captchaService.validate(captcha, httpService.getCaptchaText());
    return new ApiJsonDTO().success();
}
Also used : ApiJsonDTO(org.neusoft.neubbs.dto.ApiJsonDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with ApiJsonDTO

use of org.neusoft.neubbs.dto.ApiJsonDTO 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)

Aggregations

ApiJsonDTO (org.neusoft.neubbs.dto.ApiJsonDTO)23 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)23 LoginAuthorization (org.neusoft.neubbs.controller.annotation.LoginAuthorization)16 UserDO (org.neusoft.neubbs.entity.UserDO)15 AccountActivation (org.neusoft.neubbs.controller.annotation.AccountActivation)14 LinkedHashMap (java.util.LinkedHashMap)3 AdminRank (org.neusoft.neubbs.controller.annotation.AdminRank)2 HashMap (java.util.HashMap)1