|
@@ -0,0 +1,157 @@
|
|
1
|
+package com.yunzhi.marketing.controller;
|
|
2
|
+
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
4
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
5
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
6
|
+import com.yunzhi.marketing.base.BaseController;
|
|
7
|
+import com.yunzhi.marketing.base.ResponseBean;
|
|
8
|
+import com.yunzhi.marketing.common.StringUtils;
|
|
9
|
+import io.swagger.annotations.Api;
|
|
10
|
+import io.swagger.annotations.ApiOperation;
|
|
11
|
+import io.swagger.annotations.ApiParam;
|
|
12
|
+import org.slf4j.Logger;
|
|
13
|
+import org.slf4j.LoggerFactory;
|
|
14
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
15
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
16
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
17
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
18
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
19
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
20
|
+import com.yunzhi.marketing.service.ITaMiniappMessagePersonService;
|
|
21
|
+import com.yunzhi.marketing.entity.TaMiniappMessagePerson;
|
|
22
|
+import org.springframework.web.bind.annotation.RestController;
|
|
23
|
+
|
|
24
|
+import javax.servlet.http.HttpServletRequest;
|
|
25
|
+import java.time.LocalDateTime;
|
|
26
|
+
|
|
27
|
+/**
|
|
28
|
+ * <p>
|
|
29
|
+ * 消息订阅人员 前端控制器
|
|
30
|
+ * </p>
|
|
31
|
+ *
|
|
32
|
+ * @author yansen
|
|
33
|
+ * @since 2021-08-13
|
|
34
|
+ */
|
|
35
|
+
|
|
36
|
+@Api(tags = "消息订阅人员")
|
|
37
|
+@RestController
|
|
38
|
+@RequestMapping("/api")
|
|
39
|
+public class TaMiniappMessagePersonController extends BaseController {
|
|
40
|
+
|
|
41
|
+ private final Logger logger = LoggerFactory.getLogger(TaMiniappMessagePersonController.class);
|
|
42
|
+
|
|
43
|
+ @Autowired
|
|
44
|
+ public ITaMiniappMessagePersonService iTaMiniappMessagePersonService;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+ /**
|
|
48
|
+ * 分页查询列表
|
|
49
|
+ * @param pageNum
|
|
50
|
+ * @param pageSize
|
|
51
|
+ * @return
|
|
52
|
+ */
|
|
53
|
+ @RequestMapping(value="/wx/miniapp-message",method= RequestMethod.GET)
|
|
54
|
+ @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
|
55
|
+ public ResponseBean taMiniappMessagePersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
56
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
57
|
+ @ApiParam("人员") @RequestParam(value ="personId", required = false) String personId,
|
|
58
|
+ @ApiParam("楼盘") @RequestParam(value ="buildingId", required = false) String buildingId,
|
|
59
|
+ @ApiParam("消息类型") @RequestParam(value ="messageType", required = false) String messageType,
|
|
60
|
+ HttpServletRequest request) throws Exception{
|
|
61
|
+ Integer orgId = getOrgId(request);
|
|
62
|
+
|
|
63
|
+ IPage<TaMiniappMessagePerson> pg = new Page<>(pageNum, pageSize);
|
|
64
|
+ QueryWrapper<TaMiniappMessagePerson> queryWrapper = new QueryWrapper<>();
|
|
65
|
+ queryWrapper.eq("org_id", orgId);
|
|
66
|
+ queryWrapper.eq(!StringUtils.isEmpty(personId), "person_id", personId);
|
|
67
|
+ queryWrapper.eq(!StringUtils.isEmpty(buildingId), "building_id", buildingId);
|
|
68
|
+ queryWrapper.eq(!StringUtils.isEmpty(messageType), "message_type", messageType);
|
|
69
|
+ queryWrapper.orderByDesc("create_date");
|
|
70
|
+
|
|
71
|
+ IPage<TaMiniappMessagePerson> result = iTaMiniappMessagePersonService.page(pg, queryWrapper);
|
|
72
|
+ return ResponseBean.success(result);
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ /**
|
|
76
|
+ * 保存对象
|
|
77
|
+ * @param taMiniappMessagePerson 实体对象
|
|
78
|
+ * @return
|
|
79
|
+ */
|
|
80
|
+ @RequestMapping(value="/wx/miniapp-message",method= RequestMethod.POST)
|
|
81
|
+ @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
|
82
|
+ public ResponseBean taMiniappMessagePersonAdd(@ApiParam("保存内容") @RequestBody TaMiniappMessagePerson taMiniappMessagePerson,
|
|
83
|
+ HttpServletRequest request) throws Exception {
|
|
84
|
+ Integer orgId = getOrgId(request);
|
|
85
|
+ String personId = getPersonId(request);
|
|
86
|
+ String buildingId = taMiniappMessagePerson.getBuildingId();
|
|
87
|
+ String messageType = taMiniappMessagePerson.getMessageType();
|
|
88
|
+
|
|
89
|
+ if (StringUtils.isEmpty(messageType)) {
|
|
90
|
+ return ResponseBean.error("请设置订阅消息类型", ResponseBean.ERROR_UNAVAILABLE);
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ QueryWrapper<TaMiniappMessagePerson> queryWrapper = new QueryWrapper<>();
|
|
94
|
+ queryWrapper.eq("org_id", orgId);
|
|
95
|
+ queryWrapper.eq("person_id", personId);
|
|
96
|
+ queryWrapper.eq(StringUtils.isEmpty(buildingId),"building_id", buildingId);
|
|
97
|
+ queryWrapper.eq("message_type", messageType);
|
|
98
|
+
|
|
99
|
+ int count = iTaMiniappMessagePersonService.count(queryWrapper);
|
|
100
|
+ if (count > 0) {
|
|
101
|
+ // 如果已经订阅过改消息类型, 则不处理
|
|
102
|
+ return ResponseBean.success("");
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ taMiniappMessagePerson.setOrgId(orgId);
|
|
106
|
+ taMiniappMessagePerson.setPersonId(personId);
|
|
107
|
+ taMiniappMessagePerson.setCreateDate(LocalDateTime.now());
|
|
108
|
+
|
|
109
|
+ if (iTaMiniappMessagePersonService.save(taMiniappMessagePerson)){
|
|
110
|
+ return ResponseBean.success("");
|
|
111
|
+ }else {
|
|
112
|
+ return ResponseBean.error("订阅失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
113
|
+ }
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+// /**
|
|
117
|
+// * 根据id删除对象
|
|
118
|
+// * @param id 实体ID
|
|
119
|
+// */
|
|
120
|
+// @RequestMapping(value="/taMiniappMessagePerson/{id}", method= RequestMethod.DELETE)
|
|
121
|
+// @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
|
122
|
+// public ResponseBean taMiniappMessagePersonDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
123
|
+// if(iTaMiniappMessagePersonService.removeById(id)){
|
|
124
|
+// return ResponseBean.success("success");
|
|
125
|
+// }else {
|
|
126
|
+// return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
127
|
+// }
|
|
128
|
+// }
|
|
129
|
+//
|
|
130
|
+// /**
|
|
131
|
+// * 修改对象
|
|
132
|
+// * @param id 实体ID
|
|
133
|
+// * @param taMiniappMessagePerson 实体对象
|
|
134
|
+// * @return
|
|
135
|
+// */
|
|
136
|
+// @RequestMapping(value="/taMiniappMessagePerson/{id}",method= RequestMethod.PUT)
|
|
137
|
+// @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
138
|
+// public ResponseBean taMiniappMessagePersonUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
|
139
|
+// @ApiParam("更新内容") @RequestBody TaMiniappMessagePerson taMiniappMessagePerson) throws Exception{
|
|
140
|
+//
|
|
141
|
+// if (iTaMiniappMessagePersonService.updateById(taMiniappMessagePerson)){
|
|
142
|
+// return ResponseBean.success(iTaMiniappMessagePersonService.getById(id));
|
|
143
|
+// }else {
|
|
144
|
+// return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
145
|
+// }
|
|
146
|
+// }
|
|
147
|
+//
|
|
148
|
+// /**
|
|
149
|
+// * 根据id查询对象
|
|
150
|
+// * @param id 实体ID
|
|
151
|
+// */
|
|
152
|
+// @RequestMapping(value="/taMiniappMessagePerson/{id}",method= RequestMethod.GET)
|
|
153
|
+// @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
|
154
|
+// public ResponseBean taMiniappMessagePersonGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
155
|
+// return ResponseBean.success(iTaMiniappMessagePersonService.getById(id));
|
|
156
|
+// }
|
|
157
|
+}
|