Pārlūkot izejas kodu

fix 试卷题目

he2802 4 gadi atpakaļ
vecāks
revīzija
1e09a7bbeb

+ 36 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterBusinessAddBo.java

@@ -0,0 +1,36 @@
+package com.zhongzheng.modules.bank.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import java.util.Date;
+
+
+
+/**
+ * 题目章卷业务层次关系添加对象 question_chapter_business
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@ApiModel("题目章卷业务层次关系添加对象")
+public class QuestionChapterBusinessAddBo {
+
+    /** 教育类型id */
+    @ApiModelProperty("教育类型id")
+    private Long educationTypeId;
+    /** 业务层次id */
+    @ApiModelProperty("业务层次id")
+    private Long businessId;
+    /** 项目ID */
+    @ApiModelProperty("项目ID")
+    private Long projectId;
+    /** 科目id */
+    @ApiModelProperty("科目id")
+    private Long subjectId;
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long chapterExamId;
+}

+ 45 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterBusinessEditBo.java

@@ -0,0 +1,45 @@
+package com.zhongzheng.modules.bank.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import java.util.Date;
+
+
+/**
+ * 题目章卷业务层次关系编辑对象 question_chapter_business
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@ApiModel("题目章卷业务层次关系编辑对象")
+public class QuestionChapterBusinessEditBo {
+
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long id;
+
+    /** 教育类型id */
+    @ApiModelProperty("教育类型id")
+    private Long educationTypeId;
+
+    /** 业务层次id */
+    @ApiModelProperty("业务层次id")
+    private Long businessId;
+
+
+    /** 项目ID */
+    @ApiModelProperty("项目ID")
+    private Long projectId;
+
+    /** 科目id */
+    @ApiModelProperty("科目id")
+    private Long subjectId;
+
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long chapterExamId;
+
+}

+ 54 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterBusinessQueryBo.java

@@ -0,0 +1,54 @@
+package com.zhongzheng.modules.bank.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
+
+import com.zhongzheng.common.core.domain.BaseEntity;
+
+/**
+ * 题目章卷业务层次关系分页查询对象 question_chapter_business
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel("题目章卷业务层次关系分页查询对象")
+public class QuestionChapterBusinessQueryBo extends BaseEntity {
+
+	/** 分页大小 */
+	@ApiModelProperty("分页大小")
+	private Integer pageSize;
+	/** 当前页数 */
+	@ApiModelProperty("当前页数")
+	private Integer pageNum;
+	/** 排序列 */
+	@ApiModelProperty("排序列")
+	private String orderByColumn;
+	/** 排序的方向desc或者asc */
+	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
+	private String isAsc;
+
+
+	/** 教育类型id */
+	@ApiModelProperty("教育类型id")
+	private Long educationTypeId;
+	/** 业务层次id */
+	@ApiModelProperty("业务层次id")
+	private Long businessId;
+	/** 项目ID */
+	@ApiModelProperty("项目ID")
+	private Long projectId;
+	/** 科目id */
+	@ApiModelProperty("科目id")
+	private Long subjectId;
+	/** $column.columnComment */
+	@ApiModelProperty("$column.columnComment")
+	private Long chapterExamId;
+}

+ 39 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/QuestionChapterBusiness.java

@@ -0,0 +1,39 @@
+package com.zhongzheng.modules.bank.domain;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.util.Date;
+import java.math.BigDecimal;
+import com.zhongzheng.common.annotation.Excel;
+
+/**
+ * 题目章卷业务层次关系对象 question_chapter_business
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("question_chapter_business")
+public class QuestionChapterBusiness implements Serializable {
+
+private static final long serialVersionUID=1L;
+
+    /** $column.columnComment */
+    @TableId(value = "id")
+    private Long id;
+    /** 教育类型id */
+    private Long educationTypeId;
+    /** 业务层次id */
+    private Long businessId;
+    /** 项目ID */
+    private Long projectId;
+    /** 科目id */
+    private Long subjectId;
+    /** $column.columnComment */
+    private Long chapterExamId;
+}

+ 14 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/QuestionChapterBusinessMapper.java

@@ -0,0 +1,14 @@
+package com.zhongzheng.modules.bank.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.bank.domain.QuestionChapterBusiness;
+
+/**
+ * 题目章卷业务层次关系Mapper接口
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+public interface QuestionChapterBusinessMapper extends BaseMapper<QuestionChapterBusiness> {
+
+}

+ 52 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionChapterBusinessService.java

@@ -0,0 +1,52 @@
+package com.zhongzheng.modules.bank.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.bank.bo.QuestionChapterBusinessAddBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterBusinessEditBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterBusinessQueryBo;
+import com.zhongzheng.modules.bank.domain.QuestionChapterBusiness;
+import com.zhongzheng.modules.bank.vo.QuestionChapterBusinessVo;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 题目章卷业务层次关系Service接口
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+public interface IQuestionChapterBusinessService extends IService<QuestionChapterBusiness> {
+	/**
+	 * 查询单个
+	 * @return
+	 */
+	QuestionChapterBusinessVo queryById(Long id);
+
+	/**
+	 * 查询列表
+	 */
+	List<QuestionChapterBusinessVo> queryList(QuestionChapterBusinessQueryBo bo);
+
+	/**
+	 * 根据新增业务对象插入题目章卷业务层次关系
+	 * @param bo 题目章卷业务层次关系新增业务对象
+	 * @return
+	 */
+	Boolean insertByAddBo(QuestionChapterBusinessAddBo bo);
+
+	/**
+	 * 根据编辑业务对象修改题目章卷业务层次关系
+	 * @param bo 题目章卷业务层次关系编辑业务对象
+	 * @return
+	 */
+	Boolean updateByEditBo(QuestionChapterBusinessEditBo bo);
+
+	/**
+	 * 校验并删除数据
+	 * @param ids 主键集合
+	 * @param isValid 是否校验,true-删除前校验,false-不校验
+	 * @return
+	 */
+	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+}

+ 100 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionChapterBusinessServiceImpl.java

@@ -0,0 +1,100 @@
+package com.zhongzheng.modules.bank.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.bank.bo.QuestionChapterBusinessAddBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterBusinessEditBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterBusinessQueryBo;
+import com.zhongzheng.modules.bank.domain.QuestionChapterBusiness;
+import com.zhongzheng.modules.bank.mapper.QuestionChapterBusinessMapper;
+import com.zhongzheng.modules.bank.service.IQuestionChapterBusinessService;
+import com.zhongzheng.modules.bank.vo.QuestionChapterBusinessVo;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.Page;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 题目章卷业务层次关系Service业务层处理
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Service
+public class QuestionChapterBusinessServiceImpl extends ServiceImpl<QuestionChapterBusinessMapper, QuestionChapterBusiness> implements IQuestionChapterBusinessService {
+
+    @Override
+    public QuestionChapterBusinessVo queryById(Long id){
+        QuestionChapterBusiness db = this.baseMapper.selectById(id);
+        return BeanUtil.toBean(db, QuestionChapterBusinessVo.class);
+    }
+
+    @Override
+    public List<QuestionChapterBusinessVo> queryList(QuestionChapterBusinessQueryBo bo) {
+        LambdaQueryWrapper<QuestionChapterBusiness> lqw = Wrappers.lambdaQuery();
+        lqw.eq(bo.getEducationTypeId() != null, QuestionChapterBusiness::getEducationTypeId, bo.getEducationTypeId());
+        lqw.eq(bo.getBusinessId() != null, QuestionChapterBusiness::getBusinessId, bo.getBusinessId());
+        lqw.eq(bo.getProjectId() != null, QuestionChapterBusiness::getProjectId, bo.getProjectId());
+        lqw.eq(bo.getSubjectId() != null, QuestionChapterBusiness::getSubjectId, bo.getSubjectId());
+        lqw.eq(bo.getChapterExamId() != null, QuestionChapterBusiness::getChapterExamId, bo.getChapterExamId());
+        return entity2Vo(this.list(lqw));
+    }
+
+    /**
+    * 实体类转化成视图对象
+    *
+    * @param collection 实体类集合
+    * @return
+    */
+    private List<QuestionChapterBusinessVo> entity2Vo(Collection<QuestionChapterBusiness> collection) {
+        List<QuestionChapterBusinessVo> voList = collection.stream()
+                .map(any -> BeanUtil.toBean(any, QuestionChapterBusinessVo.class))
+                .collect(Collectors.toList());
+        if (collection instanceof Page) {
+            Page<QuestionChapterBusiness> page = (Page<QuestionChapterBusiness>)collection;
+            Page<QuestionChapterBusinessVo> pageVo = new Page<>();
+            BeanUtil.copyProperties(page,pageVo);
+            pageVo.addAll(voList);
+            voList = pageVo;
+        }
+        return voList;
+    }
+
+    @Override
+    public Boolean insertByAddBo(QuestionChapterBusinessAddBo bo) {
+        QuestionChapterBusiness add = BeanUtil.toBean(bo, QuestionChapterBusiness.class);
+        validEntityBeforeSave(add);
+        return this.save(add);
+    }
+
+    @Override
+    public Boolean updateByEditBo(QuestionChapterBusinessEditBo bo) {
+        QuestionChapterBusiness update = BeanUtil.toBean(bo, QuestionChapterBusiness.class);
+        validEntityBeforeSave(update);
+        return this.updateById(update);
+    }
+
+    /**
+     * 保存前的数据校验
+     *
+     * @param entity 实体类数据
+     */
+    private void validEntityBeforeSave(QuestionChapterBusiness entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return this.removeByIds(ids);
+    }
+}

+ 47 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionChapterBusinessVo.java

@@ -0,0 +1,47 @@
+package com.zhongzheng.modules.bank.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.util.Date;
+
+
+
+/**
+ * 题目章卷业务层次关系视图对象 mall_package
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@ApiModel("题目章卷业务层次关系视图对象")
+public class QuestionChapterBusinessVo {
+	private static final long serialVersionUID = 1L;
+
+	/** $pkColumn.columnComment */
+	@ApiModelProperty("$pkColumn.columnComment")
+	private Long id;
+
+	/** 教育类型id */
+	@Excel(name = "教育类型id")
+	@ApiModelProperty("教育类型id")
+	private Long educationTypeId;
+	/** 业务层次id */
+	@Excel(name = "业务层次id")
+	@ApiModelProperty("业务层次id")
+	private Long businessId;
+	/** 项目ID */
+	@Excel(name = "项目ID")
+	@ApiModelProperty("项目ID")
+	private Long projectId;
+	/** 科目id */
+	@Excel(name = "科目id")
+	@ApiModelProperty("科目id")
+	private Long subjectId;
+	/** $column.columnComment */
+	@Excel(name = "科目id")
+	@ApiModelProperty("$column.columnComment")
+	private Long chapterExamId;
+}

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionVo.java

@@ -4,6 +4,7 @@ import com.zhongzheng.common.annotation.Excel;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.zhongzheng.modules.bank.domain.QuestionBusiness;
 import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
+import com.zhongzheng.modules.exam.domain.ExamKnowledge;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -90,4 +91,8 @@ public class QuestionVo {
 	/** 业务层级列表 */
 	@ApiModelProperty("业务层级列表")
 	private List<QuestionBusiness> businessList;
+
+	/** 知识点列表 */
+	@ApiModelProperty("知识点列表")
+	private List<ExamKnowledge> knowledgeList;
 }

+ 10 - 1
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionMapper.xml

@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="publishStatus" column="publish_status"/>
         <result property="code" column="code"/>
         <collection property="businessList" javaType="java.util.List" resultMap="QuestionBusiness"/>
+        <collection property="knowledgeList" javaType="java.util.List" resultMap="ExamKnowledge"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.bank.domain.QuestionBusiness" id="QuestionBusiness">
@@ -50,13 +51,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="subjectName" column="subject_name"/>
     </resultMap>
 
+    <resultMap type="com.zhongzheng.modules.exam.domain.ExamKnowledge" id="ExamKnowledge">
+        <result property="knowledgeId" column="knowledge_id"/>
+        <result property="knowledgeName" column="knowledge_name"/>
+    </resultMap>
+
     <select id="selectList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="QuestionResultVo">
         SELECT
         q.*,
         cet.education_name,
         cpt.project_name,
         cb.business_name,
-        cs.subject_name
+        cs.subject_name,
+        ek.knowledge_name,
+        ek.knowledge_id
         FROM
         question q
         LEFT JOIN question_business qb ON q.question_id = qb.question_id
@@ -64,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id
         LEFT JOIN course_business cb ON qb.business_id = cb.id
         LEFT JOIN course_subject cs ON cs.id = qb.subject_id
+        LEFT JOIN exam_knowledge ek ON FIND_IN_SET( ek.knowledge_id, q.knowledge_ids )
         WHERE
         1 = 1
         <if test="status != null and status.size()!=0 ">