java110
2021-02-07 3c49bec79445e2bb5dcec92fed2a0e27690de387
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
package com.java110.user.api;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.dto.questionAnswer.QuestionAnswerDto;
import com.java110.dto.questionAnswerTitle.QuestionAnswerTitleDto;
import com.java110.dto.questionAnswerTitleValue.QuestionAnswerTitleValueDto;
import com.java110.po.questionAnswer.QuestionAnswerPo;
import com.java110.po.questionAnswerTitle.QuestionAnswerTitlePo;
import com.java110.po.questionAnswerTitleValue.QuestionAnswerTitleValuePo;
import com.java110.user.bmo.questionAnswer.IDeleteQuestionAnswerBMO;
import com.java110.user.bmo.questionAnswer.IGetQuestionAnswerBMO;
import com.java110.user.bmo.questionAnswer.ISaveQuestionAnswerBMO;
import com.java110.user.bmo.questionAnswer.IUpdateQuestionAnswerBMO;
import com.java110.user.bmo.questionAnswerTitle.IDeleteQuestionAnswerTitleBMO;
import com.java110.user.bmo.questionAnswerTitle.IGetQuestionAnswerTitleBMO;
import com.java110.user.bmo.questionAnswerTitle.ISaveQuestionAnswerTitleBMO;
import com.java110.user.bmo.questionAnswerTitle.IUpdateQuestionAnswerTitleBMO;
import com.java110.user.bmo.questionAnswerTitleValue.IDeleteQuestionAnswerTitleValueBMO;
import com.java110.user.bmo.questionAnswerTitleValue.IGetQuestionAnswerTitleValueBMO;
import com.java110.user.bmo.questionAnswerTitleValue.ISaveQuestionAnswerTitleValueBMO;
import com.java110.user.bmo.questionAnswerTitleValue.IUpdateQuestionAnswerTitleValueBMO;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
 
@RestController
@RequestMapping(value = "/questionAnswer")
public class QuestionAnswerApi {
 
    @Autowired
    private ISaveQuestionAnswerBMO saveQuestionAnswerBMOImpl;
    @Autowired
    private IUpdateQuestionAnswerBMO updateQuestionAnswerBMOImpl;
    @Autowired
    private IDeleteQuestionAnswerBMO deleteQuestionAnswerBMOImpl;
 
    @Autowired
    private IGetQuestionAnswerBMO getQuestionAnswerBMOImpl;
 
    @Autowired
    private ISaveQuestionAnswerTitleBMO saveQuestionAnswerTitleBMOImpl;
    @Autowired
    private IUpdateQuestionAnswerTitleBMO updateQuestionAnswerTitleBMOImpl;
    @Autowired
    private IDeleteQuestionAnswerTitleBMO deleteQuestionAnswerTitleBMOImpl;
 
    @Autowired
    private IGetQuestionAnswerTitleBMO getQuestionAnswerTitleBMOImpl;
 
    @Autowired
    private ISaveQuestionAnswerTitleValueBMO saveQuestionAnswerTitleValueBMOImpl;
    @Autowired
    private IUpdateQuestionAnswerTitleValueBMO updateQuestionAnswerTitleValueBMOImpl;
    @Autowired
    private IDeleteQuestionAnswerTitleValueBMO deleteQuestionAnswerTitleValueBMOImpl;
 
    @Autowired
    private IGetQuestionAnswerTitleValueBMO getQuestionAnswerTitleValueBMOImpl;
 
 
    /**
     * 微信保存消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/saveQuestionAnswer
     * @path /app/questionAnswer/saveQuestionAnswer
     */
    @RequestMapping(value = "/saveQuestionAnswer", method = RequestMethod.POST)
    public ResponseEntity<String> saveQuestionAnswer(@RequestHeader(value = "store-id", required = false) String storeId,
                                                     @RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "qaType", "请求报文中未包含qaType");
        Assert.hasKeyAndValue(reqJson, "qaName", "请求报文中未包含qaName");
        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
        Assert.hasKeyAndValue(reqJson, "objType", "请求报文中未包含objType");
 
        if (QuestionAnswerDto.QA_TYPE_STORE.equals(reqJson.getString("objType"))) {
            reqJson.put("objId", storeId);
        }
        Assert.hasKeyAndValue(reqJson, "objId", "请求报文中未包含objId");
 
        QuestionAnswerPo questionAnswerPo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerPo.class);
        return saveQuestionAnswerBMOImpl.save(questionAnswerPo);
    }
 
    /**
     * 微信修改消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/updateQuestionAnswer
     * @path /app/questionAnswer/updateQuestionAnswer
     */
    @RequestMapping(value = "/updateQuestionAnswer", method = RequestMethod.POST)
    public ResponseEntity<String> updateQuestionAnswer(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "qaType", "请求报文中未包含qaType");
        Assert.hasKeyAndValue(reqJson, "qaName", "请求报文中未包含qaName");
        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
        Assert.hasKeyAndValue(reqJson, "qaId", "qaId不能为空");
 
 
        QuestionAnswerPo questionAnswerPo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerPo.class);
        return updateQuestionAnswerBMOImpl.update(questionAnswerPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/deleteQuestionAnswer
     * @path /app/questionAnswer/deleteQuestionAnswer
     */
    @RequestMapping(value = "/deleteQuestionAnswer", method = RequestMethod.POST)
    public ResponseEntity<String> deleteQuestionAnswer(@RequestBody JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
 
        Assert.hasKeyAndValue(reqJson, "qaId", "qaId不能为空");
 
 
        QuestionAnswerPo questionAnswerPo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerPo.class);
        return deleteQuestionAnswerBMOImpl.delete(questionAnswerPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param communityId 小区ID
     * @return
     * @serviceCode /questionAnswer/queryQuestionAnswer
     * @path /app/questionAnswer/queryQuestionAnswer
     */
    @RequestMapping(value = "/queryQuestionAnswer", method = RequestMethod.GET)
    public ResponseEntity<String> queryQuestionAnswer(
            @RequestHeader(value = "store-id", required = false) String storeId,
            @RequestParam(value = "communityId", required = false) String communityId,
            @RequestParam(value = "objType", required = false) String objType,
            @RequestParam(value = "page") int page,
            @RequestParam(value = "row") int row) {
        QuestionAnswerDto questionAnswerDto = new QuestionAnswerDto();
        questionAnswerDto.setPage(page);
        questionAnswerDto.setRow(row);
        if (!StringUtil.isEmpty(objType)) {
            questionAnswerDto.setObjType(objType);
            questionAnswerDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.equals(objType) ? communityId : storeId);
        } else {
            questionAnswerDto.setObjIds(new String[]{storeId, communityId});
        }
        return getQuestionAnswerBMOImpl.get(questionAnswerDto);
    }
 
    /**
     * 微信保存消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/saveQuestionAnswerTitle
     * @path /app/questionAnswer/saveQuestionAnswerTitle
     */
    @RequestMapping(value = "/saveQuestionAnswerTitle", method = RequestMethod.POST)
    public ResponseEntity<String> saveQuestionAnswerTitle(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "qaId", "请求报文中未包含qaId");
        Assert.hasKeyAndValue(reqJson, "qaTitle", "请求报文中未包含qaTitle");
        Assert.hasKeyAndValue(reqJson, "titleType", "请求报文中未包含titleType");
        Assert.hasKeyAndValue(reqJson, "objId", "请求报文中未包含objId");
        Assert.hasKeyAndValue(reqJson, "objType", "请求报文中未包含objType");
        Assert.hasKeyAndValue(reqJson, "seq", "请求报文中未包含seq");
 
        JSONArray titleValues = null;
        if (!QuestionAnswerTitleDto.TITLE_TYPE_QUESTIONS.equals(reqJson.getString("titleType"))) {
            titleValues = reqJson.getJSONArray("titleValues");
 
            if (titleValues.size() < 1) {
                throw new IllegalArgumentException("未包含选项");
            }
        }
 
 
        QuestionAnswerTitlePo questionAnswerTitlePo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerTitlePo.class);
        return saveQuestionAnswerTitleBMOImpl.save(questionAnswerTitlePo,titleValues);
    }
 
    /**
     * 微信修改消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/updateQuestionAnswerTitle
     * @path /app/questionAnswer/updateQuestionAnswerTitle
     */
    @RequestMapping(value = "/updateQuestionAnswerTitle", method = RequestMethod.POST)
    public ResponseEntity<String> updateQuestionAnswerTitle(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "qaId", "请求报文中未包含qaId");
        Assert.hasKeyAndValue(reqJson, "qaTitle", "请求报文中未包含qaTitle");
        Assert.hasKeyAndValue(reqJson, "titleType", "请求报文中未包含titleType");
        Assert.hasKeyAndValue(reqJson, "objType", "请求报文中未包含objType");
        Assert.hasKeyAndValue(reqJson, "seq", "请求报文中未包含seq");
        Assert.hasKeyAndValue(reqJson, "titleId", "titleId不能为空");
        JSONArray titleValues = null;
        if (!QuestionAnswerTitleDto.TITLE_TYPE_QUESTIONS.equals(reqJson.getString("titleType"))) {
            titleValues = reqJson.getJSONArray("titleValues");
 
            if (titleValues.size() < 1) {
                throw new IllegalArgumentException("未包含选项");
            }
        }
 
        QuestionAnswerTitlePo questionAnswerTitlePo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerTitlePo.class);
        return updateQuestionAnswerTitleBMOImpl.update(questionAnswerTitlePo,titleValues);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/deleteQuestionAnswerTitle
     * @path /app/questionAnswer/deleteQuestionAnswerTitle
     */
    @RequestMapping(value = "/deleteQuestionAnswerTitle", method = RequestMethod.POST)
    public ResponseEntity<String> deleteQuestionAnswerTitle(@RequestBody JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
 
        Assert.hasKeyAndValue(reqJson, "titleId", "titleId不能为空");
 
 
        QuestionAnswerTitlePo questionAnswerTitlePo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerTitlePo.class);
        return deleteQuestionAnswerTitleBMOImpl.delete(questionAnswerTitlePo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param communityId 小区ID
     * @return
     * @serviceCode /questionAnswer/queryQuestionAnswerTitle
     * @path /app/questionAnswer/queryQuestionAnswerTitle
     */
    @RequestMapping(value = "/queryQuestionAnswerTitle", method = RequestMethod.GET)
    public ResponseEntity<String> queryQuestionAnswerTitle(@RequestHeader(value = "store-id", required = false) String storeId,
                                                           @RequestParam(value = "communityId", required = false) String communityId,
                                                           @RequestParam(value = "objType") String objType,
                                                           @RequestParam(value = "qaId") String qaId,
                                                           @RequestParam(value = "page") int page,
                                                           @RequestParam(value = "row") int row) {
        QuestionAnswerTitleDto questionAnswerTitleDto = new QuestionAnswerTitleDto();
        questionAnswerTitleDto.setPage(page);
        questionAnswerTitleDto.setRow(row);
        questionAnswerTitleDto.setQaId(qaId);
        if (!StringUtil.isEmpty(objType)) {
            questionAnswerTitleDto.setObjType(objType);
            questionAnswerTitleDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.equals(objType) ? communityId : storeId);
        } else {
            questionAnswerTitleDto.setObjIds(new String[]{storeId, communityId});
        }
 
        return getQuestionAnswerTitleBMOImpl.get(questionAnswerTitleDto);
    }
 
    /**
     * 微信保存消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/saveQuestionAnswerTitleValue
     * @path /app/questionAnswer/saveQuestionAnswerTitleValue
     */
    @RequestMapping(value = "/saveQuestionAnswerTitleValue", method = RequestMethod.POST)
    public ResponseEntity<String> saveQuestionAnswerTitleValue(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "titleId", "请求报文中未包含titleId");
        Assert.hasKeyAndValue(reqJson, "qaValue", "请求报文中未包含qaValue");
        Assert.hasKeyAndValue(reqJson, "objType", "请求报文中未包含objType");
        Assert.hasKeyAndValue(reqJson, "seq", "请求报文中未包含seq");
 
 
        QuestionAnswerTitleValuePo questionAnswerTitleValuePo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerTitleValuePo.class);
        return saveQuestionAnswerTitleValueBMOImpl.save(questionAnswerTitleValuePo);
    }
 
    /**
     * 微信修改消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/updateQuestionAnswerTitleValue
     * @path /app/questionAnswer/updateQuestionAnswerTitleValue
     */
    @RequestMapping(value = "/updateQuestionAnswerTitleValue", method = RequestMethod.POST)
    public ResponseEntity<String> updateQuestionAnswerTitleValue(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "titleId", "请求报文中未包含titleId");
        Assert.hasKeyAndValue(reqJson, "qaValue", "请求报文中未包含qaValue");
        Assert.hasKeyAndValue(reqJson, "objType", "请求报文中未包含objType");
        Assert.hasKeyAndValue(reqJson, "seq", "请求报文中未包含seq");
        Assert.hasKeyAndValue(reqJson, "valueId", "valueId不能为空");
 
 
        QuestionAnswerTitleValuePo questionAnswerTitleValuePo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerTitleValuePo.class);
        return updateQuestionAnswerTitleValueBMOImpl.update(questionAnswerTitleValuePo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /questionAnswer/deleteQuestionAnswerTitleValue
     * @path /app/questionAnswer/deleteQuestionAnswerTitleValue
     */
    @RequestMapping(value = "/deleteQuestionAnswerTitleValue", method = RequestMethod.POST)
    public ResponseEntity<String> deleteQuestionAnswerTitleValue(@RequestBody JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
 
        Assert.hasKeyAndValue(reqJson, "valueId", "valueId不能为空");
 
 
        QuestionAnswerTitleValuePo questionAnswerTitleValuePo = BeanConvertUtil.covertBean(reqJson, QuestionAnswerTitleValuePo.class);
        return deleteQuestionAnswerTitleValueBMOImpl.delete(questionAnswerTitleValuePo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param communityId 小区ID
     * @return
     * @serviceCode /questionAnswer/queryQuestionAnswerTitleValue
     * @path /app/questionAnswer/queryQuestionAnswerTitleValue
     */
    @RequestMapping(value = "/queryQuestionAnswerTitleValue", method = RequestMethod.GET)
    public ResponseEntity<String> queryQuestionAnswerTitleValue(@RequestHeader(value = "store-id") String storeId,
                                                                @RequestParam(value = "communityId", required = false) String communityId,
                                                                @RequestParam(value = "objType") String objType,
                                                                @RequestParam(value = "page") int page,
                                                                @RequestParam(value = "row") int row) {
        QuestionAnswerTitleValueDto questionAnswerTitleValueDto = new QuestionAnswerTitleValueDto();
        questionAnswerTitleValueDto.setPage(page);
        questionAnswerTitleValueDto.setRow(row);
        questionAnswerTitleValueDto.setObjType(objType);
        questionAnswerTitleValueDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.equals(objType) ? communityId : storeId);
        return getQuestionAnswerTitleValueBMOImpl.get(questionAnswerTitleValueDto);
    }
}