Sfoglia il codice sorgente

优化编辑题目

java110 5 anni fa
parent
commit
3c49bec794

+ 1 - 1
java110-db/src/main/resources/mapper/user/QuestionAnswerTitleValueServiceDaoImplMapper.xml

@@ -49,7 +49,7 @@
         <if test="seq !=null and seq != ''">
             and t.seq= #{seq}
         </if>
-        order by t.create_time desc
+        order by t.seq
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>

+ 8 - 1
service-user/src/main/java/com/java110/user/api/QuestionAnswerApi.java

@@ -212,10 +212,17 @@ public class QuestionAnswerApi {
         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);
     }
 
     /**

+ 4 - 1
service-user/src/main/java/com/java110/user/bmo/questionAnswerTitle/IUpdateQuestionAnswerTitleBMO.java

@@ -1,4 +1,6 @@
 package com.java110.user.bmo.questionAnswerTitle;
+
+import com.alibaba.fastjson.JSONArray;
 import com.java110.po.questionAnswerTitle.QuestionAnswerTitlePo;
 import org.springframework.http.ResponseEntity;
 
@@ -8,10 +10,11 @@ public interface IUpdateQuestionAnswerTitleBMO {
     /**
      * 修改答卷
      * add by wuxw
+     *
      * @param questionAnswerTitlePo
      * @return
      */
-    ResponseEntity<String> update(QuestionAnswerTitlePo questionAnswerTitlePo);
+    ResponseEntity<String> update(QuestionAnswerTitlePo questionAnswerTitlePo, JSONArray titleValues);
 
 
 }

+ 10 - 5
service-user/src/main/java/com/java110/user/bmo/questionAnswerTitle/impl/SaveQuestionAnswerTitleBMOImpl.java

@@ -1,6 +1,7 @@
 package com.java110.user.bmo.questionAnswerTitle.impl;
 
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.dto.questionAnswerTitle.QuestionAnswerTitleDto;
@@ -47,20 +48,24 @@ public class SaveQuestionAnswerTitleBMOImpl implements ISaveQuestionAnswerTitleB
             return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
         }
         QuestionAnswerTitleValuePo questionAnswerTitleValuePo = null;
+        JSONObject value = null;
         for (int titleValueIndex = 0; titleValueIndex < titleValues.size(); titleValueIndex++) {
             questionAnswerTitleValuePo = new QuestionAnswerTitleValuePo();
+            value = titleValues.getJSONObject(titleValueIndex);
             questionAnswerTitleValuePo.setQaValue(titleValues.getJSONObject(titleValueIndex).getString("qaValue"));
             questionAnswerTitleValuePo.setSeq(titleValues.getJSONObject(titleValueIndex).getString("seq"));
             questionAnswerTitleValuePo.setTitleId(questionAnswerTitlePo.getTitleId());
-            questionAnswerTitleValuePo.setValueId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_valueId));
             questionAnswerTitleValuePo.setObjId(questionAnswerTitlePo.getObjId());
             questionAnswerTitleValuePo.setObjType(questionAnswerTitlePo.getObjType());
-            questionAnswerTitleValueInnerServiceSMOImpl.saveQuestionAnswerTitleValue(questionAnswerTitleValuePo);
+            if(value.containsKey("valueId") && !value.getString("valueId").startsWith("-")){
+                questionAnswerTitleValuePo.setValueId(value.getString("valueId"));
+                questionAnswerTitleValueInnerServiceSMOImpl.updateQuestionAnswerTitleValue(questionAnswerTitleValuePo);
+            }else{
+                questionAnswerTitleValuePo.setValueId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_valueId));
+                questionAnswerTitleValueInnerServiceSMOImpl.saveQuestionAnswerTitleValue(questionAnswerTitleValuePo);
+            }
         }
-
         return ResultVo.createResponseEntity(ResultVo.CODE_OK, "保存成功");
-
-
     }
 
 }

+ 2 - 1
service-user/src/main/java/com/java110/user/bmo/questionAnswerTitle/impl/UpdateQuestionAnswerTitleBMOImpl.java

@@ -1,5 +1,6 @@
 package com.java110.user.bmo.questionAnswerTitle.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.intf.user.IQuestionAnswerTitleInnerServiceSMO;
 import com.java110.po.questionAnswerTitle.QuestionAnswerTitlePo;
@@ -20,7 +21,7 @@ public class UpdateQuestionAnswerTitleBMOImpl implements IUpdateQuestionAnswerTi
      * @return 订单服务能够接受的报文
      */
     @Java110Transactional
-    public ResponseEntity<String> update(QuestionAnswerTitlePo questionAnswerTitlePo) {
+    public ResponseEntity<String> update(QuestionAnswerTitlePo questionAnswerTitlePo, JSONArray titleValues) {
 
         int flag = questionAnswerTitleInnerServiceSMOImpl.updateQuestionAnswerTitle(questionAnswerTitlePo);