java110
2021-09-03 cddcf22a61489ee9c2dfee169d817ccd66f95430
service-report/src/main/java/com/java110/report/api/ReportInfoAnswerValueApi.java
@@ -1,5 +1,6 @@
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;
@@ -35,19 +36,24 @@
     * @return
     */
    @RequestMapping(value = "/saveReportInfoAnswerValue", method = RequestMethod.POST)
    public ResponseEntity<String> saveReportInfoAnswerValue(@RequestBody JSONObject reqJson) {
    public ResponseEntity<String> saveReportInfoAnswerValue(@RequestHeader(value = "user-id") String userId,@RequestBody JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "anValueId", "请求报文中未包含anValueId");
        Assert.hasKeyAndValue(reqJson, "userAnId", "请求报文中未包含userAnId");
        Assert.hasKeyAndValue(reqJson, "questionAnswerTitles", "请求报文中未包含回答项");
        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");
        JSONArray questionAnswerTitles = reqJson.getJSONArray("questionAnswerTitles");
        ReportInfoAnswerValuePo reportInfoAnswerValuePo = BeanConvertUtil.covertBean(reqJson, ReportInfoAnswerValuePo.class);
        return saveReportInfoAnswerValueBMOImpl.save(reportInfoAnswerValuePo);
        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);
    }
    /**
@@ -101,14 +107,20 @@
     */
    @RequestMapping(value = "/queryReportInfoAnswerValue", method = RequestMethod.GET)
    public ResponseEntity<String> queryReportInfoAnswerValue(@RequestParam(value = "communityId") String communityId,
                                                             @RequestParam(value = "titleId") String titleId,
                                                             @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.setTitleId(titleId);
        reportInfoAnswerValueDto.setUserName(userName);
        reportInfoAnswerValueDto.setRepName(repName);
        reportInfoAnswerValueDto.setRepTitle(repTitle);
        reportInfoAnswerValueDto.setValueContent(valueContent);
        return getReportInfoAnswerValueBMOImpl.get(reportInfoAnswerValueDto);
    }
}