he2802 3 years ago
parent
commit
2bc6b1f57f
20 changed files with 148 additions and 40 deletions
  1. 11 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/ExamController.java
  2. 12 1
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/QuestionChapterController.java
  3. 9 1
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseSectionController.java
  4. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamQueryBo.java
  5. 2 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterQueryBo.java
  6. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionEditBo.java
  7. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IExamService.java
  8. 3 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionChapterService.java
  9. 10 4
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamServiceImpl.java
  10. 13 6
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionChapterServiceImpl.java
  11. 37 19
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java
  12. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseChapterQueryBo.java
  13. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseSectionQueryBo.java
  14. 3 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseSectionService.java
  15. 12 6
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java
  16. 1 0
      zhongzheng-system/src/main/resources/mapper/modules/activity/ActivityRecommendMapper.xml
  17. 6 0
      zhongzheng-system/src/main/resources/mapper/modules/bank/ExamMapper.xml
  18. 6 0
      zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionChapterMapper.xml
  19. 6 0
      zhongzheng-system/src/main/resources/mapper/modules/course/CourseChapterMapper.xml
  20. 6 0
      zhongzheng-system/src/main/resources/mapper/modules/course/CourseSectionMapper.xml

+ 11 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/ExamController.java

@@ -94,6 +94,17 @@ public class ExamController extends BaseController {
         return AjaxResult.success(iExamService.insertByAddBo(bo));
     }
 
+    /**
+     * 新增试卷
+     */
+    @ApiOperation("批量新增试卷")
+    @PreAuthorize("@ss.hasPermi('system:exam:add')")
+    @Log(title = "试卷", businessType = BusinessType.INSERT)
+    @PostMapping("/addMore")
+    public AjaxResult<List<Long>> addMore(@RequestBody List<ExamAddBo> list) {
+        return AjaxResult.success(iExamService.insertByAddBoMore(list));
+    }
+
     /**
      * 修改试卷
      */

+ 12 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/QuestionChapterController.java

@@ -92,7 +92,18 @@ public class QuestionChapterController extends BaseController {
     @Log(title = "章卷", businessType = BusinessType.INSERT)
     @PostMapping()
     public AjaxResult<Void> add(@RequestBody QuestionChapterAddBo bo) {
-        return toAjax(iQuestionChapterService.insertByAddBo(bo) ? 1 : 0);
+        return toAjax(iQuestionChapterService.insertByAddBo(bo)>0 ? 1 : 0);
+    }
+
+    /**
+     * 新增章卷
+     */
+    @ApiOperation("批量新增章卷")
+    @PreAuthorize("@ss.hasPermi('system:chapter:add')")
+    @Log(title = "章卷", businessType = BusinessType.INSERT)
+    @PostMapping("/addMore")
+    public AjaxResult<List<Long>> addMore(@RequestBody List<QuestionChapterAddBo> list) {
+        return AjaxResult.success(iQuestionChapterService.insertByAddBoMore(list));
     }
 
     /**

+ 9 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseSectionController.java

@@ -101,7 +101,15 @@ public class CourseSectionController extends BaseController {
     @Log(title = "课程小节", businessType = BusinessType.INSERT)
     @PostMapping()
     public AjaxResult<Void> add(@RequestBody CourseSectionAddBo bo) {
-        return toAjax(iCourseSectionService.insertByAddBo(bo) ? 1 : 0);
+        return toAjax(iCourseSectionService.insertByAddBo(bo)>0? 1 : 0);
+    }
+
+    @ApiOperation("批量新增课程小节")
+    @PreAuthorize("@ss.hasPermi('system:section:add')")
+    @Log(title = "课程小节", businessType = BusinessType.INSERT)
+    @PostMapping("/addMore")
+    public AjaxResult<List<Long>> addMore(@RequestBody List<CourseSectionAddBo> list) {
+        return AjaxResult.success(iCourseSectionService.insertByAddBoMore(list));
     }
 
     /**

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamQueryBo.java

@@ -85,4 +85,6 @@ public class ExamQueryBo extends BaseEntity {
 	private Long projectId;
 	@ApiModelProperty("关键词")
 	private String searchKey;
+	@ApiModelProperty("试卷IDs")
+	private List<Long> examIds;
 }

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterQueryBo.java

@@ -70,5 +70,6 @@ public class QuestionChapterQueryBo extends BaseEntity {
 	/** 项目ID */
 	@ApiModelProperty("项目ID")
 	private Long projectId;
-
+	@ApiModelProperty("章卷IDs")
+	private Long chapterExamIds;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionEditBo.java

@@ -80,4 +80,7 @@ public class QuestionEditBo {
     /** 导入顺序 */
     @ApiModelProperty("导入顺序")
     private Integer importSort;
+
+    @ApiModelProperty("题目ID")
+    private List<Long> questionIds;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IExamService.java

@@ -37,6 +37,8 @@ public interface IExamService extends IService<Exam> {
 	 */
 	ExamVo insertByAddBo(ExamAddBo bo);
 
+	List<Long> insertByAddBoMore(List<ExamAddBo> list);
+
 	/**
 	 * 根据编辑业务对象修改试卷
 	 * @param bo 试卷编辑业务对象

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionChapterService.java

@@ -34,7 +34,9 @@ public interface IQuestionChapterService extends IService<QuestionChapter> {
 	 * @param bo 章卷新增业务对象
 	 * @return
 	 */
-	Boolean insertByAddBo(QuestionChapterAddBo bo);
+	Long insertByAddBo(QuestionChapterAddBo bo);
+
+	List<Long> insertByAddBoMore(List<QuestionChapterAddBo> list);
 
 	/**
 	 * 根据编辑业务对象修改章卷

+ 10 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamServiceImpl.java

@@ -33,10 +33,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -152,6 +149,15 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
         return examVo;
     }
 
+    @Override
+    public List<Long> insertByAddBoMore(List<ExamAddBo> list) {
+        List<Long> ids = new ArrayList<>();
+        for(ExamAddBo bo : list){
+            ids.add(insertByAddBo(bo).getExamId());
+        }
+        return ids;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateByEditBo(ExamEditBo bo) {

+ 13 - 6
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionChapterServiceImpl.java

@@ -16,6 +16,7 @@ import com.zhongzheng.modules.bank.service.IQuestionChapterExamService;
 import com.zhongzheng.modules.bank.service.IQuestionChapterService;
 import com.zhongzheng.modules.bank.service.IQuestionModuleChapterService;
 import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
+import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,10 +27,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -100,7 +98,7 @@ public class QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMappe
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean insertByAddBo(QuestionChapterAddBo bo) {
+    public Long insertByAddBo(QuestionChapterAddBo bo) {
         QuestionChapter add = BeanUtil.toBean(bo, QuestionChapter.class);
         add.setCode(ServletUtils.getEncoded("ZJ"));
         validEntityBeforeSave(add);
@@ -128,7 +126,16 @@ public class QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMappe
             }
             iQuestionChapterExamService.saveBatch(coll);
         }
-        return result;
+        return add.getChapterExamId();
+    }
+
+    @Override
+    public List<Long> insertByAddBoMore(List<QuestionChapterAddBo> list) {
+        List<Long> ids = new ArrayList<>();
+        for(QuestionChapterAddBo bo : list){
+            ids.add(insertByAddBo(bo));
+        }
+        return ids;
     }
 
     @Override

+ 37 - 19
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -180,27 +180,45 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateByEditBo(QuestionEditBo bo) {
-        Question update = BeanUtil.toBean(bo, Question.class);
-        if (bo.getOptionsList() != null) {
-            update.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
-        }
-        validEntityBeforeSave(update);
-        update.setUpdateTime(DateUtils.getNowTime());
-        if (bo.getBusinessList() != null) {
-            iQuestionBusinessService.remove(new LambdaQueryWrapper<QuestionBusiness>()
-                    .eq(QuestionBusiness::getMajorId, bo.getQuestionId())
-                    .eq(QuestionBusiness::getType, QuestionBusiness.TYPE_QUESTION));
-            Collection<QuestionBusiness> coll = new HashSet<>();
-            for (int i = 0; i < bo.getBusinessList().size(); i++) {
-                QuestionBusinessEditBo item = bo.getBusinessList().get(i);
-                QuestionBusiness addItem = BeanUtil.toBean(item, QuestionBusiness.class);
-                addItem.setMajorId(bo.getQuestionId());
-                addItem.setType(QuestionBusiness.TYPE_QUESTION);
-                coll.add(addItem);
+        if(bo.getStatus()==-1){
+            //删除
+            if(Validator.isNotEmpty(bo.getQuestionIds())&&bo.getQuestionIds().size()>0){
+                for(Long id : bo.getQuestionIds()){
+                    Question update = new Question();
+                    update.setQuestionId(id);
+                    update.setStatus(-1);
+                }
             }
-            iQuestionBusinessService.saveBatch(coll);
+            if(Validator.isNotEmpty(bo.getQuestionId())){
+                Question update = new Question();
+                update.setQuestionId(bo.getQuestionId());
+                update.setStatus(-1);
+                return this.updateById(update);
+            }
+        }else{
+            Question update = BeanUtil.toBean(bo, Question.class);
+            if (bo.getOptionsList() != null) {
+                update.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
+            }
+            validEntityBeforeSave(update);
+            update.setUpdateTime(DateUtils.getNowTime());
+            if (bo.getBusinessList() != null) {
+                iQuestionBusinessService.remove(new LambdaQueryWrapper<QuestionBusiness>()
+                        .eq(QuestionBusiness::getMajorId, bo.getQuestionId())
+                        .eq(QuestionBusiness::getType, QuestionBusiness.TYPE_QUESTION));
+                Collection<QuestionBusiness> coll = new HashSet<>();
+                for (int i = 0; i < bo.getBusinessList().size(); i++) {
+                    QuestionBusinessEditBo item = bo.getBusinessList().get(i);
+                    QuestionBusiness addItem = BeanUtil.toBean(item, QuestionBusiness.class);
+                    addItem.setMajorId(bo.getQuestionId());
+                    addItem.setType(QuestionBusiness.TYPE_QUESTION);
+                    coll.add(addItem);
+                }
+                iQuestionBusinessService.saveBatch(coll);
+            }
+            return this.updateById(update);
         }
-        return this.updateById(update);
+        return true;
     }
 
     /**

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseChapterQueryBo.java

@@ -69,4 +69,6 @@ public class CourseChapterQueryBo extends BaseEntity {
 	/** 科目id */
 	@ApiModelProperty("科目id")
 	private Long subjectId;
+
+	private List<Long> chapterIds;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseSectionQueryBo.java

@@ -83,4 +83,6 @@ public class CourseSectionQueryBo extends BaseEntity {
 	private Long subjectId;
 	@ApiModelProperty("导入编号")
 	private String importNo;
+	@ApiModelProperty("节ID数组")
+	private List<Long> sectionIds;
 }

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseSectionService.java

@@ -41,7 +41,9 @@ public interface ICourseSectionService extends IService<CourseSection> {
 	 * @param bo 课程小节新增业务对象
 	 * @return
 	 */
-	Boolean insertByAddBo(CourseSectionAddBo bo);
+	Long insertByAddBo(CourseSectionAddBo bo);
+
+	List<Long> insertByAddBoMore(List<CourseSectionAddBo> list);
 
 	/**
 	 * 根据编辑业务对象修改课程小节

+ 12 - 6
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

@@ -14,10 +14,7 @@ import com.zhongzheng.modules.bank.bo.QuestionBusinessAddBo;
 import com.zhongzheng.modules.bank.domain.Question;
 import com.zhongzheng.modules.bank.domain.QuestionBusiness;
 import com.zhongzheng.modules.bank.vo.QuestionImport;
-import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
-import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
-import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
-import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
+import com.zhongzheng.modules.course.bo.*;
 import com.zhongzheng.modules.course.domain.*;
 import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
 import com.zhongzheng.modules.course.service.*;
@@ -127,7 +124,7 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
     }
 
     @Override
-    public Boolean insertByAddBo(CourseSectionAddBo bo) {
+    public Long insertByAddBo(CourseSectionAddBo bo) {
         CourseSection add = BeanUtil.toBean(bo, CourseSection.class);
         add.setCode(ServletUtils.getEncoded("J"));
         validEntityBeforeSave(add);
@@ -141,7 +138,16 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                 iCourseSectionBusinessService.insertByAddBo(item);
             }
         }
-        return result;
+        return add.getSectionId();
+    }
+
+    @Override
+    public List<Long> insertByAddBoMore(List<CourseSectionAddBo> list) {
+        List<Long> ids = new ArrayList<>();
+        for(CourseSectionAddBo bo : list){
+            ids.add(insertByAddBo(bo));
+        }
+        return ids;
     }
 
     @Override

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/activity/ActivityRecommendMapper.xml

@@ -58,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN goods g ON rg.goods_id = g.goods_id
         WHERE
             rg.recommend_id = #{recommend_id}
+        and g.goods_status = 1 and g.`status` = 1
         order by rg.sort asc
     </select>
 

+ 6 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/ExamMapper.xml

@@ -97,6 +97,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 #{item}
             </foreach>
         </if>
+        <if test="examIds != null and examIds.size()!=0 ">
+            AND e.exam_id in
+            <foreach collection="examIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="educationTypeId != null and educationTypeId != ''">
             AND cet.id = #{educationTypeId}
         </if>

+ 6 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionChapterMapper.xml

@@ -75,6 +75,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN course_business cb ON qb.business_id = cb.id AND cb.status =1
         LEFT JOIN course_subject cs ON cs.id = qb.subject_id  AND cs.status =1
         where 1=1
+        <if test="chapterExamIds != null and chapterExamIds.size()!=0 ">
+            AND qc.chapter_exam_id in
+            <foreach collection="chapterExamIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="status != null and status.size()!=0 ">
             AND qc.status in
             <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">

+ 6 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseChapterMapper.xml

@@ -149,6 +149,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="prefixName != null and prefixName != ''">
             AND c.prefix_name like concat('%', #{prefixName}, '%')
         </if>
+        <if test="chapterIds != null and chapterIds.size()!=0 ">
+            AND c.chapter_id in
+            <foreach collection="chapterIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         GROUP BY
         c.chapter_id
         ORDER BY c.chapter_id DESC

+ 6 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseSectionMapper.xml

@@ -149,6 +149,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 #{item}
             </foreach>
         </if>
+        <if test="sectionIds != null and sectionIds.size()!=0 ">
+            AND c.section_id in
+            <foreach collection="sectionIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="importNo != null and importNo != ''">
             AND c.import_no = #{importNo}
         </if>