java110
2021-08-26 468042c516adb6da5684a2d9f95a5d1e130553dc
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
package com.java110.report.api;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.dto.reportInfoAnswerValue.ReportInfoAnswerValueDto;
import com.java110.po.reportInfoAnswerValue.ReportInfoAnswerValuePo;
import com.java110.report.bmo.reportInfoAnswerValue.IDeleteReportInfoAnswerValueBMO;
import com.java110.report.bmo.reportInfoAnswerValue.IGetReportInfoAnswerValueBMO;
import com.java110.report.bmo.reportInfoAnswerValue.ISaveReportInfoAnswerValueBMO;
import com.java110.report.bmo.reportInfoAnswerValue.IUpdateReportInfoAnswerValueBMO;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
 
@RestController
@RequestMapping(value = "/reportInfoAnswerValue")
public class ReportInfoAnswerValueApi {
 
    @Autowired
    private ISaveReportInfoAnswerValueBMO saveReportInfoAnswerValueBMOImpl;
    @Autowired
    private IUpdateReportInfoAnswerValueBMO updateReportInfoAnswerValueBMOImpl;
    @Autowired
    private IDeleteReportInfoAnswerValueBMO deleteReportInfoAnswerValueBMOImpl;
 
    @Autowired
    private IGetReportInfoAnswerValueBMO getReportInfoAnswerValueBMOImpl;
 
    /**
     * 微信保存消息模板
     * @serviceCode /reportInfoAnswerValue/saveReportInfoAnswerValue
     * @path /app/reportInfoAnswerValue/saveReportInfoAnswerValue
     * @param reqJson
     * @return
     */
    @RequestMapping(value = "/saveReportInfoAnswerValue", method = RequestMethod.POST)
    public ResponseEntity<String> saveReportInfoAnswerValue(@RequestHeader(value = "user-id") String userId,@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "questionAnswerTitles", "请求报文中未包含回答项");
        Assert.hasKeyAndValue(reqJson, "settingId", "请求报文中未包含settingId");
        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
 
        JSONArray questionAnswerTitles = reqJson.getJSONArray("questionAnswerTitles");
 
        if (questionAnswerTitles == null || questionAnswerTitles.size() < 1) {
            throw new IllegalArgumentException("未包含题目及答案");
        }
        JSONObject titleObj = null;
        for (int questionAnswerTitleIndex = 0; questionAnswerTitleIndex < questionAnswerTitles.size(); questionAnswerTitleIndex++) {
            titleObj = questionAnswerTitles.getJSONObject(questionAnswerTitleIndex);
            Assert.hasKeyAndValue(titleObj, "valueContent", titleObj.getString("title") + ",未填写答案");
        }
 
        return saveReportInfoAnswerValueBMOImpl.save(reqJson,userId);
    }
 
    /**
     * 微信修改消息模板
     * @serviceCode /reportInfoAnswerValue/updateReportInfoAnswerValue
     * @path /app/reportInfoAnswerValue/updateReportInfoAnswerValue
     * @param reqJson
     * @return
     */
    @RequestMapping(value = "/updateReportInfoAnswerValue", method = RequestMethod.POST)
    public ResponseEntity<String> updateReportInfoAnswerValue(@RequestBody JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "anValueId", "请求报文中未包含anValueId");
        Assert.hasKeyAndValue(reqJson, "userAnId", "请求报文中未包含userAnId");
        Assert.hasKeyAndValue(reqJson, "settingId", "请求报文中未包含settingId");
        Assert.hasKeyAndValue(reqJson, "titleId", "请求报文中未包含titleId");
        Assert.hasKeyAndValue(reqJson, "valueId", "请求报文中未包含valueId");
        Assert.hasKeyAndValue(reqJson, "valueContent", "请求报文中未包含valueContent");
        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
        Assert.hasKeyAndValue(reqJson, "anValueId", "anValueId不能为空");
 
 
        ReportInfoAnswerValuePo reportInfoAnswerValuePo = BeanConvertUtil.covertBean(reqJson, ReportInfoAnswerValuePo.class);
        return updateReportInfoAnswerValueBMOImpl.update(reportInfoAnswerValuePo);
    }
 
    /**
     * 微信删除消息模板
     * @serviceCode /reportInfoAnswerValue/deleteReportInfoAnswerValue
     * @path /app/reportInfoAnswerValue/deleteReportInfoAnswerValue
     * @param reqJson
     * @return
     */
    @RequestMapping(value = "/deleteReportInfoAnswerValue", method = RequestMethod.POST)
    public ResponseEntity<String> deleteReportInfoAnswerValue(@RequestBody JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
 
        Assert.hasKeyAndValue(reqJson, "anValueId", "anValueId不能为空");
 
 
        ReportInfoAnswerValuePo reportInfoAnswerValuePo = BeanConvertUtil.covertBean(reqJson, ReportInfoAnswerValuePo.class);
        return deleteReportInfoAnswerValueBMOImpl.delete(reportInfoAnswerValuePo);
    }
 
    /**
     * 微信删除消息模板
     * @serviceCode /reportInfoAnswerValue/queryReportInfoAnswerValue
     * @path /app/reportInfoAnswerValue/queryReportInfoAnswerValue
     * @param communityId 小区ID
     * @return
     */
    @RequestMapping(value = "/queryReportInfoAnswerValue", method = RequestMethod.GET)
    public ResponseEntity<String> queryReportInfoAnswerValue(@RequestParam(value = "communityId") String communityId,
                                                             @RequestParam(value = "userName",required = false) String userName,
                                                             @RequestParam(value = "repName",required = false) String repName,
                                                             @RequestParam(value = "repTitle",required = false) String repTitle,
                                                             @RequestParam(value = "valueContent",required = false) String valueContent,
                                                      @RequestParam(value = "page") int page,
                                                      @RequestParam(value = "row") int row) {
        ReportInfoAnswerValueDto reportInfoAnswerValueDto = new ReportInfoAnswerValueDto();
        reportInfoAnswerValueDto.setPage(page);
        reportInfoAnswerValueDto.setRow(row);
        reportInfoAnswerValueDto.setCommunityId(communityId);
        reportInfoAnswerValueDto.setUserName(userName);
        reportInfoAnswerValueDto.setRepName(repName);
        reportInfoAnswerValueDto.setRepTitle(repTitle);
        reportInfoAnswerValueDto.setValueContent(valueContent);
        return getReportInfoAnswerValueBMOImpl.get(reportInfoAnswerValueDto);
    }
}