java110
2021-02-05 18e0135569cfdf07354cb5efd8dcc951f9f5af47
service-user/src/main/java/com/java110/user/api/QuestionAnswerApi.java
@@ -3,8 +3,10 @@
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;
@@ -13,6 +15,10 @@
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 org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +50,17 @@
    @Autowired
    private IGetQuestionAnswerTitleBMO getQuestionAnswerTitleBMOImpl;
    @Autowired
    private ISaveQuestionAnswerTitleValueBMO saveQuestionAnswerTitleValueBMOImpl;
    @Autowired
    private IUpdateQuestionAnswerTitleValueBMO updateQuestionAnswerTitleValueBMOImpl;
    @Autowired
    private IDeleteQuestionAnswerTitleValueBMO deleteQuestionAnswerTitleValueBMOImpl;
    @Autowired
    private IGetQuestionAnswerTitleValueBMO getQuestionAnswerTitleValueBMOImpl;
    /**
     * 微信保存消息模板
     *
@@ -53,7 +70,8 @@
     * @path /app/questionAnswer/saveQuestionAnswer
     */
    @RequestMapping(value = "/saveQuestionAnswer", method = RequestMethod.POST)
    public ResponseEntity<String> saveQuestionAnswer(@RequestBody JSONObject reqJson) {
    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");
@@ -61,6 +79,10 @@
        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);
@@ -120,14 +142,14 @@
    public ResponseEntity<String> queryQuestionAnswer(
            @RequestHeader(value = "store-id") String storeId,
            @RequestParam(value = "communityId", required = false) String communityId,
            @RequestParam(value = "objType") String objType,
            @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);
        questionAnswerDto.setObjType(objType);
        questionAnswerDto.setObjTd(QuestionAnswerDto.QA_TYPE_COMMUNITY.endsWith(objType) ? communityId : storeId);
        questionAnswerDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.endsWith(objType) ? communityId : storeId);
        return getQuestionAnswerBMOImpl.get(questionAnswerDto);
    }
@@ -216,4 +238,88 @@
        questionAnswerTitleDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.endsWith(objType) ? communityId : storeId);
        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.endsWith(objType) ? communityId : storeId);
        return getQuestionAnswerTitleValueBMOImpl.get(questionAnswerTitleValueDto);
    }
}