Pārlūkot izejas kodu

收藏错题接口修改

小么熊🐻 2 gadi atpakaļ
vecāks
revīzija
134990f8e7

+ 24 - 33
nbjk-admin/src/main/java/com/miaxis/app/controller/question/QuestionWrongController.java

@@ -2,39 +2,26 @@ package com.miaxis.app.controller.question;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.miaxis.common.constant.Constants;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Arrays;
-import java.util.stream.Collectors;
-
-import com.miaxis.common.exception.CustomException;
+import com.miaxis.common.core.controller.BaseController;
+import com.miaxis.common.core.domain.Response;
 import com.miaxis.common.utils.SecurityUtils;
-import com.miaxis.question.domain.QuestionCollection;
 import com.miaxis.question.domain.QuestionInfo;
-import com.miaxis.question.dto.*;
-import com.miaxis.score.domain.ScoreInfo;
-import io.swagger.annotations.*;
-import com.miaxis.common.core.domain.Response;
-import org.springframework.beans.BeanUtils;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import com.miaxis.common.annotation.Log;
-import com.miaxis.common.core.controller.BaseController;
-import com.miaxis.common.enums.BusinessTypeEnum;
 import com.miaxis.question.domain.QuestionWrong;
+import com.miaxis.question.dto.QuestionWrongDTO;
+import com.miaxis.question.dto.QuestionWrongDelDTO;
+import com.miaxis.question.dto.QuestionWrongListDTO;
+import com.miaxis.question.dto.QuestionWrongYunDTO;
 import com.miaxis.question.service.IQuestionWrongService;
-import com.miaxis.common.utils.poi.ExcelUtil;
-import com.miaxis.common.core.page.ResponsePageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 【wrong】Controller
@@ -63,7 +50,9 @@ public class QuestionWrongController extends BaseController{
         List<QuestionWrong> list = questionWrongService.selectQuestionWrongList(dto);
         long count = list.stream().filter(o -> questionWrongDTO.getQuestionId().equals(o.getQuestionId()) &&  questionWrongDTO.getKm().equals(o.getKm())).count();
         if (count > 0) {
-            throw new CustomException("该错已加入错题集");
+            //throw new CustomException("该错已加入错题集");
+            Response response = new Response(200,"该错已加入错题集");
+            return response;
         }
         QuestionWrong questionWrong = new QuestionWrong();
         BeanUtils.copyProperties(questionWrongDTO,questionWrong);
@@ -92,7 +81,8 @@ public class QuestionWrongController extends BaseController{
             qlist.add(questionWrong);
         }
         if (qlist.isEmpty()) {
-            throw new CustomException("选中的错题都已添加!");
+            Response response = new Response(200,"选中的错题都已添加!");
+            return response;
         }
         return toResponse(questionWrongService.saveBatch(qlist) ? 1 : 0);
     }
@@ -100,7 +90,7 @@ public class QuestionWrongController extends BaseController{
 
     @PostMapping("bakWrongs")
     @ApiOperation("备份本机错题到云端")
-    public Response<Integer> bakWrongs(@RequestBody QuestionWrongYunDTO wrong){
+    public Response bakWrongs(@RequestBody QuestionWrongYunDTO wrong){
         //首先删除云端数据
         Long userId = SecurityUtils.getLoginUser().getStudent().getId();
         QueryWrapper<QuestionWrong> queryWrapper = new QueryWrapper<QuestionWrong>();
@@ -118,7 +108,8 @@ public class QuestionWrongController extends BaseController{
             qlist.add(questionWrong);
         }
         if (qlist.isEmpty()) {
-            throw new CustomException("选中的错题都已添加!");
+            Response response = new Response(200,"该错已加入错题集(无须提示给用户)");
+            return response;
         }
         return toResponse(questionWrongService.saveBatch(qlist) ? 1 : 0);
     }

+ 1 - 1
nbjk-common/src/main/java/com/miaxis/common/core/domain/Response.java

@@ -42,7 +42,7 @@ public class Response<T> {
         this.msg = responseEnum.getMessage();
     }
 
-    private Response(Integer code,String msg){
+    public Response(Integer code, String msg){
         this.code = code;
         this.msg = msg;
     }