Ver Fonte

增加批量修改题型

mingfu há 1 dia atrás
pai
commit
8e80b7b1ca

+ 16 - 8
ie-admin/src/main/java/com/ruoyi/web/controller/learn/LearnQuestionsController.java

@@ -1,21 +1,18 @@
 package com.ruoyi.web.controller.learn;
 
 import java.util.List;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.enums.CardAction;
 import com.ruoyi.enums.QuestionType;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 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.*;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -112,4 +109,15 @@ public class LearnQuestionsController extends BaseController
     {
         return toAjax(learnQuestionsService.deleteLearnQuestionsByIds(ids));
     }
+
+    @Log(title = "修改题型", businessType = BusinessType.UPDATE)
+    @PostMapping("/changeType")
+    @ApiOperation("修改题型")
+    public AjaxResult updateQuestionType(@RequestBody JSONObject param)
+    {
+        QuestionType qt = QuestionType.of(param.getInteger("type"));
+        List<Long> ids = param.getList ("ids", Long.class);
+        learnQuestionsService.updateQuestionType(qt.name(), ids);
+        return AjaxResult.success();
+    }
 }

+ 2 - 0
ie-system/src/main/java/com/ruoyi/learn/mapper/LearnQuestionsMapper.java

@@ -66,6 +66,8 @@ public interface LearnQuestionsMapper
      */
     public int deleteLearnQuestionsByIds(Long[] ids);
 
+    int updateQuestionType(@Param("qtpye") String qtpye, @Param("ids") Collection<Long> ids);
+
     public List<LearnQuestions> selectQuestionByPaperId(Long paperId);
 
     public List<LearnQuestions> statByKnowledgeType(Map cond);

+ 3 - 0
ie-system/src/main/java/com/ruoyi/learn/service/ILearnQuestionsService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.learn.service;
 
+import java.util.Collection;
 import java.util.List;
 import com.ruoyi.learn.domain.LearnQuestions;
 
@@ -59,6 +60,8 @@ public interface ILearnQuestionsService
      */
     public int deleteLearnQuestionsById(Long id);
 
+    int updateQuestionType(String type, Collection<Long> ids);
+
     public List<LearnQuestions> selectCollectedList(LearnQuestions questions);
 
     public void fillCollectInfo(Long userId, List<LearnQuestions> questions);

+ 8 - 4
ie-system/src/main/java/com/ruoyi/learn/service/impl/LearnQuestionsServiceImpl.java

@@ -1,9 +1,6 @@
 package com.ruoyi.learn.service.impl;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import com.ruoyi.common.utils.DateUtils;
@@ -87,6 +84,13 @@ public class LearnQuestionsServiceImpl implements ILearnQuestionsService
         return learnQuestionsMapper.deleteLearnQuestionsByIds(ids);
     }
 
+    @Override
+    public int updateQuestionType(String type, Collection<Long> ids)
+    {
+        return learnQuestionsMapper.updateQuestionType(type, ids);
+    }
+
+
     /**
      * 删除试题信息
      *

+ 5 - 0
ie-system/src/main/resources/mapper/learn/LearnQuestionsMapper.xml

@@ -264,6 +264,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </update>
 
+    <update id="updateQuestionType">
+        UPDATE learn_questions SET qtpye = #{qtpye}
+        WHERE id IN <foreach item="id" collection="ids" open="(" separator="," close=")">#{id}</foreach>
+    </update>
+
     <delete id="deleteLearnQuestionsById" parameterType="Long">
         delete from learn_questions where id = #{id}
     </delete>