添加禁言逻辑
This commit is contained in:
parent
14587dceaa
commit
f5941c8570
@ -1,11 +1,13 @@
|
|||||||
package com.example.controller;
|
package com.example.controller;
|
||||||
|
|
||||||
import com.example.entity.RestBean;
|
import com.example.entity.RestBean;
|
||||||
|
import com.example.entity.dto.Account;
|
||||||
import com.example.entity.dto.Interact;
|
import com.example.entity.dto.Interact;
|
||||||
import com.example.entity.vo.request.AddCommentVO;
|
import com.example.entity.vo.request.AddCommentVO;
|
||||||
import com.example.entity.vo.request.TopicCreateVO;
|
import com.example.entity.vo.request.TopicCreateVO;
|
||||||
import com.example.entity.vo.request.TopicUpdateVO;
|
import com.example.entity.vo.request.TopicUpdateVO;
|
||||||
import com.example.entity.vo.response.*;
|
import com.example.entity.vo.response.*;
|
||||||
|
import com.example.service.AccountService;
|
||||||
import com.example.service.TopicService;
|
import com.example.service.TopicService;
|
||||||
import com.example.service.WeatherService;
|
import com.example.service.WeatherService;
|
||||||
import com.example.utils.Const;
|
import com.example.utils.Const;
|
||||||
@ -29,6 +31,9 @@ public class ForumController {
|
|||||||
@Resource
|
@Resource
|
||||||
TopicService topicService;
|
TopicService topicService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
AccountService accountService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
ControllerUtils utils;
|
ControllerUtils utils;
|
||||||
|
|
||||||
@ -51,6 +56,10 @@ public class ForumController {
|
|||||||
@PostMapping("/create-topic")
|
@PostMapping("/create-topic")
|
||||||
public RestBean<Void> createTopic(@Valid @RequestBody TopicCreateVO vo,
|
public RestBean<Void> createTopic(@Valid @RequestBody TopicCreateVO vo,
|
||||||
@RequestAttribute(Const.ATTR_USER_ID) int id) {
|
@RequestAttribute(Const.ATTR_USER_ID) int id) {
|
||||||
|
Account account = accountService.findAccountById(id);
|
||||||
|
if (account.isMute()) {
|
||||||
|
return RestBean.forbidden("您已被禁言,无法创建新的主题");
|
||||||
|
}
|
||||||
return utils.messageHandle(() -> topicService.createTopic(id, vo));
|
return utils.messageHandle(() -> topicService.createTopic(id, vo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +103,10 @@ public class ForumController {
|
|||||||
@PostMapping("/add-comment")
|
@PostMapping("/add-comment")
|
||||||
public RestBean<Void> addComment(@Valid @RequestBody AddCommentVO vo,
|
public RestBean<Void> addComment(@Valid @RequestBody AddCommentVO vo,
|
||||||
@RequestAttribute(Const.ATTR_USER_ID) int id){
|
@RequestAttribute(Const.ATTR_USER_ID) int id){
|
||||||
|
Account account = accountService.findAccountById(id);
|
||||||
|
if (account.isMute()) {
|
||||||
|
return RestBean.forbidden("您已被禁言,无法创建新的回复");
|
||||||
|
}
|
||||||
return utils.messageHandle(() -> topicService.createComment(id, vo));
|
return utils.messageHandle(() -> topicService.createComment(id, vo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user