-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestSensitiveWordController.java
More file actions
75 lines (67 loc) · 2.83 KB
/
RestSensitiveWordController.java
File metadata and controls
75 lines (67 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.zyd.blog.controller;
import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.annotation.BussinessLog;
import com.zyd.blog.business.entity.SensitiveWord;
import com.zyd.blog.business.enums.ResponseStatus;
import com.zyd.blog.business.service.BizSensitiveWordService;
import com.zyd.blog.business.vo.SensitiveWordConditionVO;
import com.zyd.blog.framework.object.PageResult;
import com.zyd.blog.framework.object.ResponseVO;
import com.zyd.blog.util.ResultUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/sensitive/word")
public class RestSensitiveWordController {
@Autowired
private BizSensitiveWordService sensitiveWordService;
@RequiresPermissions("sensitive:words")
@PostMapping("/list")
public PageResult list(SensitiveWordConditionVO vo) {
PageInfo<SensitiveWord> pageInfo = sensitiveWordService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo);
}
@RequiresPermissions("sensitive:word:add")
@PostMapping(value = "/add")
@BussinessLog("添加敏感词")
public ResponseVO add(SensitiveWord sensitiveWord) {
if (StringUtils.isEmpty(sensitiveWord.getWord())) {
return ResultUtil.error("敏感词不能为空");
}
sensitiveWordService.insert(sensitiveWord);
return ResultUtil.success("成功");
}
@RequiresPermissions("sensitive:word:edit")
@PostMapping("/edit")
@BussinessLog("编辑敏感词")
public ResponseVO edit(SensitiveWord sensitiveWord) {
if (StringUtils.isEmpty(sensitiveWord.getWord())) {
return ResultUtil.error("敏感词不能为空");
}
sensitiveWordService.updateSelective(sensitiveWord);
return ResultUtil.success(ResponseStatus.SUCCESS);
}
@RequiresPermissions("sensitive:word:delete")
@PostMapping("/remove")
@BussinessLog("删除敏感词")
public ResponseVO remove(Long[] ids) {
if (null == ids) {
return ResultUtil.error("请至少选择一条记录");
}
for (Long id : ids) {
sensitiveWordService.removeByPrimaryKey(id);
}
return ResultUtil.success("成功删除 [" + ids.length + "] 条敏感词");
}
@RequiresPermissions("sensitive:words")
@PostMapping("/get/{id}")
@BussinessLog("获取敏感词详情")
public ResponseVO get(@PathVariable Long id) {
return ResultUtil.success(null, sensitiveWordService.getByPrimaryKey(id));
}
}