From b4e6c4c1d5c8b887de5f2101cdb3522d75a45842 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 24 五月 2021 08:15:07 +0800
Subject: [PATCH] 加入结果
---
service-user/src/main/java/com/java110/user/api/QuestionAnswerApi.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 92 insertions(+), 22 deletions(-)
diff --git a/service-user/src/main/java/com/java110/user/api/QuestionAnswerApi.java b/service-user/src/main/java/com/java110/user/api/QuestionAnswerApi.java
old mode 100644
new mode 100755
index f77c464..90d2349
--- a/service-user/src/main/java/com/java110/user/api/QuestionAnswerApi.java
+++ b/service-user/src/main/java/com/java110/user/api/QuestionAnswerApi.java
@@ -1,5 +1,6 @@
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;
@@ -21,9 +22,15 @@
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.*;
+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
@@ -70,7 +77,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");
@@ -78,6 +86,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);
@@ -98,7 +110,6 @@
Assert.hasKeyAndValue(reqJson, "qaName", "璇锋眰鎶ユ枃涓湭鍖呭惈qaName");
Assert.hasKeyAndValue(reqJson, "startTime", "璇锋眰鎶ユ枃涓湭鍖呭惈startTime");
Assert.hasKeyAndValue(reqJson, "endTime", "璇锋眰鎶ユ枃涓湭鍖呭惈endTime");
- Assert.hasKeyAndValue(reqJson, "objType", "璇锋眰鎶ユ枃涓湭鍖呭惈objType");
Assert.hasKeyAndValue(reqJson, "qaId", "qaId涓嶈兘涓虹┖");
@@ -135,16 +146,22 @@
*/
@RequestMapping(value = "/queryQuestionAnswer", method = RequestMethod.GET)
public ResponseEntity<String> queryQuestionAnswer(
- @RequestHeader(value = "store-id") String storeId,
+ @RequestHeader(value = "store-id", required = false) String storeId,
+ @RequestHeader(value = "user-id", required = false) String userId,
@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.setUserId(userId);
+ 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);
}
@@ -162,12 +179,22 @@
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);
+ return saveQuestionAnswerTitleBMOImpl.save(questionAnswerTitlePo, titleValues);
}
/**
@@ -181,16 +208,23 @@
@RequestMapping(value = "/updateQuestionAnswerTitle", method = RequestMethod.POST)
public ResponseEntity<String> updateQuestionAnswerTitle(@RequestBody JSONObject reqJson) {
- Assert.hasKeyAndValue(reqJson, "qaId", "璇锋眰鎶ユ枃涓湭鍖呭惈qaId");
+// 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);
+ return updateQuestionAnswerTitleBMOImpl.update(questionAnswerTitlePo, titleValues);
}
/**
@@ -221,25 +255,35 @@
* @path /app/questionAnswer/queryQuestionAnswerTitle
*/
@RequestMapping(value = "/queryQuestionAnswerTitle", method = RequestMethod.GET)
- public ResponseEntity<String> queryQuestionAnswerTitle(@RequestHeader(value = "store-id") String storeId,
+ public ResponseEntity<String> queryQuestionAnswerTitle(@RequestHeader(value = "store-id", required = false) String storeId,
+ // @RequestHeader(value = "user-id", required = false) String userId,
@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.setObjType(objType);
- questionAnswerTitleDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.endsWith(objType) ? communityId : storeId);
+ questionAnswerTitleDto.setQaId(qaId);
+ //questionAnswerTitleDto.setUserId(userId);
+ 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);
}
/**
* 寰俊淇濆瓨娑堟伅妯℃澘
- * @serviceCode /questionAnswer/saveQuestionAnswerTitleValue
- * @path /app/questionAnswer/saveQuestionAnswerTitleValue
+ *
* @param reqJson
* @return
+ * @serviceCode /questionAnswer/saveQuestionAnswerTitleValue
+ * @path /app/questionAnswer/saveQuestionAnswerTitleValue
*/
@RequestMapping(value = "/saveQuestionAnswerTitleValue", method = RequestMethod.POST)
public ResponseEntity<String> saveQuestionAnswerTitleValue(@RequestBody JSONObject reqJson) {
@@ -256,10 +300,11 @@
/**
* 寰俊淇敼娑堟伅妯℃澘
- * @serviceCode /questionAnswer/updateQuestionAnswerTitleValue
- * @path /app/questionAnswer/updateQuestionAnswerTitleValue
+ *
* @param reqJson
* @return
+ * @serviceCode /questionAnswer/updateQuestionAnswerTitleValue
+ * @path /app/questionAnswer/updateQuestionAnswerTitleValue
*/
@RequestMapping(value = "/updateQuestionAnswerTitleValue", method = RequestMethod.POST)
public ResponseEntity<String> updateQuestionAnswerTitleValue(@RequestBody JSONObject reqJson) {
@@ -277,10 +322,11 @@
/**
* 寰俊鍒犻櫎娑堟伅妯℃澘
- * @serviceCode /questionAnswer/deleteQuestionAnswerTitleValue
- * @path /app/questionAnswer/deleteQuestionAnswerTitleValue
+ *
* @param reqJson
* @return
+ * @serviceCode /questionAnswer/deleteQuestionAnswerTitleValue
+ * @path /app/questionAnswer/deleteQuestionAnswerTitleValue
*/
@RequestMapping(value = "/deleteQuestionAnswerTitleValue", method = RequestMethod.POST)
public ResponseEntity<String> deleteQuestionAnswerTitleValue(@RequestBody JSONObject reqJson) {
@@ -295,10 +341,11 @@
/**
* 寰俊鍒犻櫎娑堟伅妯℃澘
- * @serviceCode /questionAnswer/queryQuestionAnswerTitleValue
- * @path /app/questionAnswer/queryQuestionAnswerTitleValue
+ *
* @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,
@@ -310,7 +357,30 @@
questionAnswerTitleValueDto.setPage(page);
questionAnswerTitleValueDto.setRow(row);
questionAnswerTitleValueDto.setObjType(objType);
- questionAnswerTitleValueDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.endsWith(objType) ? communityId : storeId);
+ questionAnswerTitleValueDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.equals(objType) ? communityId : storeId);
return getQuestionAnswerTitleValueBMOImpl.get(questionAnswerTitleValueDto);
}
+
+
+ /**
+ * 寰俊鍒犻櫎娑堟伅妯℃澘
+ *
+ * @param communityId 灏忓尯ID
+ * @return
+ * @serviceCode /questionAnswer/queryTitleValueResult
+ * @path /app/questionAnswer/queryTitleValueResult
+ */
+ @RequestMapping(value = "/queryTitleValueResult", method = RequestMethod.GET)
+ public ResponseEntity<String> queryTitleValueResult(@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.queryQuestionAnswerTitleValueResult(questionAnswerTitleValueDto);
+ }
}
--
Gitblit v1.8.0