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 | 73 ++++++++++++++++++++++++++++++++----
1 files changed, 65 insertions(+), 8 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 83b4465..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;
@@ -24,7 +25,12 @@
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
@@ -140,7 +146,8 @@
*/
@RequestMapping(value = "/queryQuestionAnswer", method = RequestMethod.GET)
public ResponseEntity<String> queryQuestionAnswer(
- @RequestHeader(value = "store-id",required = false) 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", required = false) String objType,
@RequestParam(value = "page") int page,
@@ -148,6 +155,7 @@
QuestionAnswerDto questionAnswerDto = new QuestionAnswerDto();
questionAnswerDto.setPage(page);
questionAnswerDto.setRow(row);
+ questionAnswerDto.setUserId(userId);
if (!StringUtil.isEmpty(objType)) {
questionAnswerDto.setObjType(objType);
questionAnswerDto.setObjId(QuestionAnswerDto.QA_TYPE_COMMUNITY.equals(objType) ? communityId : storeId);
@@ -171,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);
}
/**
@@ -190,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);
}
/**
@@ -230,16 +255,25 @@
* @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.equals(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);
}
@@ -326,4 +360,27 @@
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