|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.yunzhi.marketing.base.BaseController;
|
7
|
7
|
import com.yunzhi.marketing.base.ResponseBean;
|
|
8
|
+import com.yunzhi.marketing.common.CommConstant;
|
8
|
9
|
import io.swagger.annotations.Api;
|
9
|
10
|
import io.swagger.annotations.ApiOperation;
|
10
|
11
|
import io.swagger.annotations.ApiParam;
|
|
@@ -20,6 +21,9 @@ import com.yunzhi.marketing.borker.service.IBkNoticeService;
|
20
|
21
|
import com.yunzhi.marketing.borker.entity.BkNotice;
|
21
|
22
|
import org.springframework.web.bind.annotation.RestController;
|
22
|
23
|
|
|
24
|
+import javax.servlet.http.HttpServletRequest;
|
|
25
|
+import java.util.List;
|
|
26
|
+
|
23
|
27
|
/**
|
24
|
28
|
* <p>
|
25
|
29
|
* 通知公告 前端控制器
|
|
@@ -31,7 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
|
31
|
35
|
|
32
|
36
|
@Api(tags = "通知公告")
|
33
|
37
|
@RestController
|
34
|
|
-@RequestMapping("/")
|
|
38
|
+@RequestMapping("/api")
|
35
|
39
|
public class BkNoticeController extends BaseController {
|
36
|
40
|
|
37
|
41
|
private final Logger logger = LoggerFactory.getLogger(BkNoticeController.class);
|
|
@@ -46,74 +50,89 @@ public class BkNoticeController extends BaseController {
|
46
|
50
|
* @param pageSize
|
47
|
51
|
* @return
|
48
|
52
|
*/
|
49
|
|
- @RequestMapping(value="/bkNotice",method= RequestMethod.GET)
|
|
53
|
+ @RequestMapping(value="/{client}/bkNotice",method= RequestMethod.GET)
|
50
|
54
|
@ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
51
|
|
- public ResponseBean bkNoticeList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
52
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
53
|
|
-
|
54
|
|
- IPage<BkNotice> pg = new Page<>(pageNum, pageSize);
|
55
|
|
- QueryWrapper<BkNotice> queryWrapper = new QueryWrapper<>();
|
56
|
|
- queryWrapper.orderByDesc("create_date");
|
|
55
|
+ public ResponseBean bkNoticeList(@ApiParam("客户端") @PathVariable String client,
|
|
56
|
+ @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
57
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
58
|
+ HttpServletRequest request) throws Exception{
|
57
|
59
|
|
58
|
|
- IPage<BkNotice> result = iBkNoticeService.page(pg, queryWrapper);
|
59
|
|
- return ResponseBean.success(result);
|
60
|
|
- }
|
|
60
|
+ IPage<BkNotice> pg = new Page<>(pageNum, pageSize);
|
|
61
|
+ QueryWrapper<BkNotice> queryWrapper = new QueryWrapper<>();
|
|
62
|
+ queryWrapper.gt("status", CommConstant.STATUS_DELETE);
|
61
|
63
|
|
62
|
|
- /**
|
63
|
|
- * 保存对象
|
64
|
|
- * @param bkNotice 实体对象
|
65
|
|
- * @return
|
66
|
|
- */
|
67
|
|
- @RequestMapping(value="/bkNotice",method= RequestMethod.POST)
|
68
|
|
- @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
69
|
|
- public ResponseBean bkNoticeAdd(@ApiParam("保存内容") @RequestBody BkNotice bkNotice) throws Exception{
|
70
|
|
-
|
71
|
|
- if (iBkNoticeService.save(bkNotice)){
|
72
|
|
- return ResponseBean.success(bkNotice);
|
73
|
|
- }else {
|
74
|
|
- return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
75
|
|
- }
|
76
|
|
- }
|
77
|
|
-
|
78
|
|
- /**
|
79
|
|
- * 根据id删除对象
|
80
|
|
- * @param id 实体ID
|
81
|
|
- */
|
82
|
|
- @RequestMapping(value="/bkNotice/{id}", method= RequestMethod.DELETE)
|
83
|
|
- @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
84
|
|
- public ResponseBean bkNoticeDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
85
|
|
- if(iBkNoticeService.removeById(id)){
|
86
|
|
- return ResponseBean.success("success");
|
87
|
|
- }else {
|
88
|
|
- return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
64
|
+ if ("admin".equals(client)) {
|
|
65
|
+ List<String> institutionIds = getInstitutionIds(request);
|
|
66
|
+ queryWrapper.in(null != institutionIds, "institution_id", institutionIds);
|
89
|
67
|
}
|
90
|
|
- }
|
91
|
68
|
|
92
|
|
- /**
|
93
|
|
- * 修改对象
|
94
|
|
- * @param id 实体ID
|
95
|
|
- * @param bkNotice 实体对象
|
96
|
|
- * @return
|
97
|
|
- */
|
98
|
|
- @RequestMapping(value="/bkNotice/{id}",method= RequestMethod.PUT)
|
99
|
|
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
100
|
|
- public ResponseBean bkNoticeUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
101
|
|
- @ApiParam("更新内容") @RequestBody BkNotice bkNotice) throws Exception{
|
|
69
|
+ queryWrapper.orderByDesc("create_date");
|
102
|
70
|
|
103
|
|
- if (iBkNoticeService.updateById(bkNotice)){
|
104
|
|
- return ResponseBean.success(iBkNoticeService.getById(id));
|
105
|
|
- }else {
|
106
|
|
- return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
107
|
|
- }
|
|
71
|
+ IPage<BkNotice> result = iBkNoticeService.page(pg, queryWrapper);
|
|
72
|
+ return ResponseBean.success(result);
|
108
|
73
|
}
|
109
|
74
|
|
|
75
|
+// /**
|
|
76
|
+// * 保存对象
|
|
77
|
+// * @param bkNotice 实体对象
|
|
78
|
+// * @return
|
|
79
|
+// */
|
|
80
|
+// @RequestMapping(value="/bkNotice",method= RequestMethod.POST)
|
|
81
|
+// @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
|
82
|
+// public ResponseBean bkNoticeAdd(@ApiParam("保存内容") @RequestBody BkNotice bkNotice) throws Exception{
|
|
83
|
+//
|
|
84
|
+// if (iBkNoticeService.save(bkNotice)){
|
|
85
|
+// return ResponseBean.success(bkNotice);
|
|
86
|
+// }else {
|
|
87
|
+// return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
88
|
+// }
|
|
89
|
+// }
|
|
90
|
+//
|
|
91
|
+// /**
|
|
92
|
+// * 根据id删除对象
|
|
93
|
+// * @param id 实体ID
|
|
94
|
+// */
|
|
95
|
+// @RequestMapping(value="/bkNotice/{id}", method= RequestMethod.DELETE)
|
|
96
|
+// @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
|
97
|
+// public ResponseBean bkNoticeDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
98
|
+// if(iBkNoticeService.removeById(id)){
|
|
99
|
+// return ResponseBean.success("success");
|
|
100
|
+// }else {
|
|
101
|
+// return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
102
|
+// }
|
|
103
|
+// }
|
|
104
|
+//
|
|
105
|
+// /**
|
|
106
|
+// * 修改对象
|
|
107
|
+// * @param id 实体ID
|
|
108
|
+// * @param bkNotice 实体对象
|
|
109
|
+// * @return
|
|
110
|
+// */
|
|
111
|
+// @RequestMapping(value="/bkNotice/{id}",method= RequestMethod.PUT)
|
|
112
|
+// @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
113
|
+// public ResponseBean bkNoticeUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
|
114
|
+// @ApiParam("更新内容") @RequestBody BkNotice bkNotice) throws Exception{
|
|
115
|
+//
|
|
116
|
+// if (iBkNoticeService.updateById(bkNotice)){
|
|
117
|
+// return ResponseBean.success(iBkNoticeService.getById(id));
|
|
118
|
+// }else {
|
|
119
|
+// return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
120
|
+// }
|
|
121
|
+// }
|
|
122
|
+
|
110
|
123
|
/**
|
111
|
124
|
* 根据id查询对象
|
112
|
125
|
* @param id 实体ID
|
113
|
126
|
*/
|
114
|
|
- @RequestMapping(value="/bkNotice/{id}",method= RequestMethod.GET)
|
|
127
|
+ @RequestMapping(value="/{client}/bkNotice/{id}",method= RequestMethod.GET)
|
115
|
128
|
@ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
116
|
|
- public ResponseBean bkNoticeGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
117
|
|
- return ResponseBean.success(iBkNoticeService.getById(id));
|
|
129
|
+ public ResponseBean bkNoticeGet(@ApiParam("客户端") @PathVariable String client,
|
|
130
|
+ @ApiParam("对象ID") @PathVariable Integer id) throws Exception {
|
|
131
|
+ BkNotice bkNotice = iBkNoticeService.getById(id);
|
|
132
|
+ if (null == bkNotice || CommConstant.STATUS_DELETE.equals(bkNotice.getStatus())) {
|
|
133
|
+ return ResponseBean.error("未找到数据", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ return ResponseBean.success(bkNotice);
|
118
|
137
|
}
|
119
|
138
|
}
|