Browse Source

fix 卷列表

he2802 3 years ago
parent
commit
d2cc6b8bbc
18 changed files with 307 additions and 5 deletions
  1. 1 1
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/QuestionChapterController.java
  2. 24 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/QuestionController.java
  3. 2 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserController.java
  4. 12 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterQueryBo.java
  5. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/Question.java
  6. 7 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/QuestionChapterMapper.java
  7. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionChapterService.java
  8. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionService.java
  9. 7 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionChapterServiceImpl.java
  10. 13 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java
  11. 27 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamGoodsVo.java
  12. 6 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamVo.java
  13. 32 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionBusinessImport.java
  14. 11 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionChapterVo.java
  15. 68 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionImport.java
  16. 3 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionModuleVo.java
  17. 18 0
      zhongzheng-system/src/main/resources/mapper/modules/bank/ExamMapper.xml
  18. 68 0
      zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionChapterMapper.xml

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

@@ -57,7 +57,7 @@ public class QuestionChapterController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo<QuestionChapterVo> list(QuestionChapterQueryBo bo) {
         startPage();
-        List<QuestionChapterVo> list = iQuestionChapterService.queryList(bo);
+        List<QuestionChapterVo> list = iQuestionChapterService.getList(bo);
         return getDataTable(list);
     }
 

+ 24 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/QuestionController.java

@@ -5,16 +5,22 @@ import java.util.Arrays;
 
 import cn.hutool.http.HttpStatus;
 import com.github.pagehelper.PageInfo;
+import com.zhongzheng.common.core.domain.entity.SysUser;
+import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.poi.ExcelUtil;
+import com.zhongzheng.framework.web.service.TokenService;
 import com.zhongzheng.modules.bank.bo.QuestionAddBo;
 import com.zhongzheng.modules.bank.bo.QuestionBusinessQueryBo;
 import com.zhongzheng.modules.bank.bo.QuestionEditBo;
 import com.zhongzheng.modules.bank.bo.QuestionQueryBo;
+import com.zhongzheng.modules.bank.domain.Question;
 import com.zhongzheng.modules.bank.domain.QuestionBusiness;
 import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
 import com.zhongzheng.modules.bank.service.IQuestionService;
 import com.zhongzheng.modules.bank.vo.QuestionBusinessVo;
+import com.zhongzheng.modules.bank.vo.QuestionImport;
 import com.zhongzheng.modules.bank.vo.QuestionVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import lombok.RequiredArgsConstructor;
@@ -34,6 +40,7 @@ import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.enums.BusinessType;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 题库题目Controller
@@ -51,6 +58,9 @@ public class QuestionController extends BaseController {
 
     private final IQuestionBusinessService iQuestionBusinessService;
 
+    @Autowired
+    private TokenService tokenService;
+
     /**
      * 查询题库题目列表
      */
@@ -131,4 +141,18 @@ public class QuestionController extends BaseController {
         List<QuestionBusiness> list = iQuestionBusinessService.getListById(bo);
         return getDataTable(list);
     }
+
+    @Log(title = "题目管理", businessType = BusinessType.IMPORT)
+    @ApiOperation("导入题目模板")
+    @PreAuthorize("@ss.hasPermi('system:question:import')")
+    @PostMapping("/importData")
+    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
+    {
+        ExcelUtil<QuestionImport> util = new ExcelUtil<QuestionImport>(QuestionImport.class);
+        List<QuestionImport> questionList = util.importExcel(file.getInputStream());
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        String operName = loginUser.getUsername();
+        String message = iQuestionService.importQuestion(questionList, updateSupport, operName);
+        return AjaxResult.success(message);
+    }
 }

+ 2 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserController.java

@@ -3,6 +3,7 @@ package com.zhongzheng.controller.user;
 import java.util.List;
 import java.util.Arrays;
 
+import com.zhongzheng.common.core.domain.entity.SysUser;
 import com.zhongzheng.modules.user.bo.UserAddBo;
 import com.zhongzheng.modules.user.bo.UserEditBo;
 import com.zhongzheng.modules.user.bo.UserQueryBo;
@@ -123,4 +124,5 @@ public class UserController extends BaseController {
         List<UserStudyRecordVo> list = iUserService.selectStudyRecordList(bo);
         return getDataTable(list);
     }
+
 }

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterQueryBo.java

@@ -55,4 +55,16 @@ public class QuestionChapterQueryBo extends BaseEntity {
 	/** 编码 */
 	@ApiModelProperty("编码")
 	private String code;
+	private Long examPaperId;
+	@ApiModelProperty("教育类型ID")
+	private Long educationTypeId;
+	/** 业务层次id */
+	@ApiModelProperty("业务层次id")
+	private Long businessId;
+	/** 科目id */
+	@ApiModelProperty("科目id")
+	private Long subjectId;
+	/** 项目ID */
+	@ApiModelProperty("项目ID")
+	private Long projectId;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/Question.java

@@ -54,4 +54,7 @@ private static final long serialVersionUID=1L;
     private Integer publishStatus;
     /** 编码 */
     private String code;
+    /** 创建者 */
+    @TableField(fill = FieldFill.INSERT)
+    private String createBy;
 }

+ 7 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/QuestionChapterMapper.java

@@ -1,6 +1,12 @@
 package com.zhongzheng.modules.bank.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.bank.bo.ExamQueryBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterQueryBo;
 import com.zhongzheng.modules.bank.domain.QuestionChapter;
+import com.zhongzheng.modules.bank.vo.ExamVo;
+import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
+
+import java.util.List;
 
 /**
  * 章卷Mapper接口
@@ -9,5 +15,5 @@ import com.zhongzheng.modules.bank.domain.QuestionChapter;
  * @date 2021-10-25
  */
 public interface QuestionChapterMapper extends BaseMapper<QuestionChapter> {
-
+    List<QuestionChapterVo> getList(QuestionChapterQueryBo bo);
 }

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

@@ -22,6 +22,7 @@ public interface IQuestionChapterService extends IService<QuestionChapter> {
 	 * @return
 	 */
 	QuestionChapterVo queryById(Long chapterExamId);
+	List<QuestionChapterVo> getList(QuestionChapterQueryBo bo);
 
 	/**
 	 * 查询列表

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionService.java

@@ -2,10 +2,12 @@ package com.zhongzheng.modules.bank.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.common.core.domain.entity.SysUser;
 import com.zhongzheng.modules.bank.bo.QuestionAddBo;
 import com.zhongzheng.modules.bank.bo.QuestionEditBo;
 import com.zhongzheng.modules.bank.bo.QuestionQueryBo;
 import com.zhongzheng.modules.bank.domain.Question;
+import com.zhongzheng.modules.bank.vo.QuestionImport;
 import com.zhongzheng.modules.bank.vo.QuestionVo;
 
 import java.util.Collection;
@@ -55,4 +57,6 @@ public interface IQuestionService extends IService<Question> {
 	 * @return
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+	String importQuestion(List<QuestionImport> questionList, Boolean isUpdateSupport, String operName);
 }

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionChapterServiceImpl.java

@@ -41,6 +41,8 @@ public class QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMappe
 
     @Autowired
     private IQuestionChapterExamService iQuestionChapterExamService;
+    @Autowired
+    private QuestionChapterMapper questionChapterMapper;
 
     @Override
     public QuestionChapterVo queryById(Long chapterExamId){
@@ -48,6 +50,11 @@ public class QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMappe
         return BeanUtil.toBean(db, QuestionChapterVo.class);
     }
 
+    @Override
+    public List<QuestionChapterVo> getList(QuestionChapterQueryBo bo) {
+        return questionChapterMapper.getList(bo);
+    }
+
     @Override
     public List<QuestionChapterVo> queryList(QuestionChapterQueryBo bo) {
         LambdaQueryWrapper<QuestionChapter> lqw = Wrappers.lambdaQuery();

+ 13 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.zhongzheng.common.core.domain.entity.SysUser;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
@@ -14,6 +15,7 @@ import com.zhongzheng.modules.bank.mapper.QuestionMapper;
 import com.zhongzheng.modules.bank.service.IExamQuestionService;
 import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
 import com.zhongzheng.modules.bank.service.IQuestionService;
+import com.zhongzheng.modules.bank.vo.QuestionImport;
 import com.zhongzheng.modules.bank.vo.QuestionVo;
 import com.zhongzheng.modules.base.domain.ApplyAreas;
 import com.zhongzheng.modules.course.bo.CourseChapterSectionListAddBo;
@@ -169,6 +171,17 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return this.removeByIds(ids);
     }
 
+    @Override
+    public String importQuestion(List<QuestionImport> questionList, Boolean isUpdateSupport, String operName) {
+        if (Validator.isNull(questionList) || questionList.size() == 0) {
+            throw new CustomException("导入数据不能为空!");
+        }
+        for (QuestionImport question : questionList) {
+            System.out.println(question);
+        }
+        return null;
+    }
+
     private boolean checkNameUnique(Question entity) {
         Question info = getOne(new LambdaQueryWrapper<Question>()
                 .eq(Question::getPrefixName,entity.getPrefixName()).ne(Question::getContent,entity.getContent()).last("limit 1"));

+ 27 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamGoodsVo.java

@@ -0,0 +1,27 @@
+package com.zhongzheng.modules.bank.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * 课程视图对象 mall_package
+ *
+ * @author hjl
+ * @date 2021-10-09
+ */
+@Data
+@ApiModel("课程商品视图对象")
+public class ExamGoodsVo {
+	private static final long serialVersionUID = 1L;
+
+	@ApiModelProperty("商品id")
+	private Long goodsId;
+
+	/** 商品名称 */
+	@Excel(name = "商品名称")
+	@ApiModelProperty("商品名称")
+	private String goodsName;
+}

+ 6 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamVo.java

@@ -3,13 +3,15 @@ package com.zhongzheng.modules.bank.vo;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.zhongzheng.common.annotation.Excel;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.zhongzheng.modules.course.vo.CourseGoodsVo;
+import com.zhongzheng.modules.goods.vo.GoodsVo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
-
+import java.util.List;
 
 
 /**
@@ -109,4 +111,7 @@ public class ExamVo {
 	private String businessName;
 
 	private String subjectName;
+
+	@ApiModelProperty("商品列表")
+	private List<ExamGoodsVo> goodsList;
 }

+ 32 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionBusinessImport.java

@@ -0,0 +1,32 @@
+package com.zhongzheng.modules.bank.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * 题库题目添加对象 question
+ *
+ * @author hjl
+ * @date 2021-10-22
+ */
+@Data
+@ApiModel("题库题目添加对象")
+public class QuestionBusinessImport {
+
+    /** 教育类型ID */
+    @Excel(name = "教育类型")
+    private String educationType;
+    /** 业务层次id */
+    @Excel(name = "业务层次")
+    private String business;
+    /** 科目id */
+    @Excel(name = "科目")
+    private String subject;
+    /** 项目ID */
+    @Excel(name = "项目类型")
+    private String project;
+
+}

+ 11 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionChapterVo.java

@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import java.util.Date;
-
+import java.util.List;
 
 
 /**
@@ -48,5 +48,15 @@ public class QuestionChapterVo {
 	@Excel(name = "编码")
 	@ApiModelProperty("编码")
 	private String code;
+	@ApiModelProperty("商品列表")
+	private List<ExamGoodsVo> goodsList;
+
+	private String educationName;
+
+	private String projectName;
+
+	private String businessName;
+
+	private String subjectName;
 
 }

+ 68 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionImport.java

@@ -0,0 +1,68 @@
+package com.zhongzheng.modules.bank.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import com.zhongzheng.common.annotation.Excels;
+import com.zhongzheng.modules.bank.bo.QuestionBusinessAddBo;
+import com.zhongzheng.modules.bank.bo.QuestionChildAddBo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * 题库题目添加对象 question
+ *
+ * @author hjl
+ * @date 2021-10-22
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+public class QuestionImport implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /** 题目正文 */
+    @Excel(name = "题目内容")
+    private String content;
+
+    @Excel(name = "题型")
+    private String type;
+
+    @Excel(name = "正确答案")
+    private String answerQuestion;
+
+
+    @Excel(name = "答案解析")
+    private String analysisContent;
+    /** 问题内容 */
+    @Excel(name = "问题内容")
+    @ApiModelProperty("问题内容")
+    private String jsonStr;
+    /** 前缀名称 */
+    @Excel(name = "标题前缀")
+    private String prefixName;
+
+    /** 教育类型ID */
+    @Excel(name = "教育类型")
+    private String educationType;
+    /** 业务层次id */
+    @Excel(name = "业务层次")
+    private String business;
+    /** 科目id */
+    @Excel(name = "科目")
+    private String subject;
+    /** 项目ID */
+    @Excel(name = "项目类型")
+    private String project;
+
+
+
+}

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionModuleVo.java

@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import java.util.Date;
-
+import java.util.List;
 
 
 /**
@@ -44,4 +44,6 @@ public class QuestionModuleVo {
 	@Excel(name = "编码")
 	@ApiModelProperty("编码")
 	private String code;
+	@ApiModelProperty("商品列表")
+	private List<ExamGoodsVo> goodsList;
 }

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

@@ -21,6 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="examPaperId" column="exam_paper_id"/>
         <result property="answerNum" column="answer_num"/>
         <result property="sort" column="sort"/>
+        <result property="createBy" column="create_by"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.bank.vo.ExamVo" id="ExamVoResult">
@@ -48,6 +49,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="subjectId" column="subject_id"/>
         <result property="projectId" column="project_id"/>
         <result property="subjectName" column="subject_name"/>
+        <collection property="goodsList" column="exam_id" select="findGoodsList"/>
+    </resultMap>
+
+    <select id="findGoodsList" resultMap="GoodsListResult">
+        SELECT
+            g.goods_name,
+            g.goods_id
+        FROM
+            goods_attached ga
+                LEFT JOIN goods g ON ga.goods_id = g.goods_id
+        WHERE
+            ga.major_id =#{exam_id} AND ga.type = 3
+    </select>
+
+    <resultMap type="com.zhongzheng.modules.bank.vo.ExamGoodsVo" id="GoodsListResult">
+        <result property="goodsName" column="goods_name"/>
+        <result property="goodsId" column="goods_id"/>
     </resultMap>
 
     <select id="getList" parameterType="com.zhongzheng.modules.bank.bo.ExamQueryBo" resultMap="ExamVoResult">

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

@@ -16,5 +16,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="code" column="code"/>
     </resultMap>
 
+    <resultMap type="com.zhongzheng.modules.bank.vo.QuestionChapterVo" id="QuestionChapterResultVo">
+        <result property="chapterExamId" column="chapter_exam_id"/>
+        <result property="name" column="name"/>
+        <result property="sort" column="sort"/>
+        <result property="status" column="status"/>
+        <result property="prefixName" column="prefix_name"/>
+        <result property="publishStatus" column="publish_status"/>
+        <result property="code" column="code"/>
+        <collection property="goodsList" column="chapter_exam_id" select="findGoodsList"/>
+    </resultMap>
+
+    <select id="findGoodsList" resultMap="GoodsListResult">
+        SELECT
+            g.goods_name,
+            g.goods_id
+        FROM
+            goods_attached ga
+                LEFT JOIN goods g ON ga.goods_id = g.goods_id
+        WHERE
+            ga.major_id =#{chapter_exam_id} AND ga.type = 2
+    </select>
+
+    <resultMap type="com.zhongzheng.modules.bank.vo.ExamGoodsVo" id="GoodsListResult">
+        <result property="goodsName" column="goods_name"/>
+        <result property="goodsId" column="goods_id"/>
+    </resultMap>
 
+    <select id="getList" parameterType="com.zhongzheng.modules.bank.bo.QuestionChapterQueryBo" resultMap="QuestionChapterResultVo">
+        SELECT
+        qc.*,
+        qb.education_type_id,
+        qb.business_id,
+        qb.project_id,
+        qb.subject_id,
+        cet.education_name,
+        cpt.project_name,
+        cb.business_name,
+        cs.subject_name
+        FROM
+        question_chapter qc
+        LEFT JOIN question_business qb ON qc.chapter_exam_id = qb.major_id
+        AND qb.type = 2
+        LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id
+        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 where 1=1
+        <if test="educationTypeId != null and educationTypeId != ''">
+            AND cet.id = #{educationTypeId}
+        </if>
+        <if test="subjectId != null and subjectId != ''">
+            AND cs.id = #{subjectId}
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND cb.id = #{businessId}
+        </if>
+        <if test="projectId != null and projectId != ''">
+            AND cpt.id = #{projectId}
+        </if>
+        <if test="publishStatus != null and publishStatus != ''">
+            AND qc.publish_status = #{publishStatus}
+        </if>
+        <if test="name != null and name != ''">
+            AND qc.name  like concat('%', #{name}, '%')
+        </if>
+        <if test="prefixName != null and prefixName != ''">
+            AND qc.prefix_name  like concat('%', #{prefixName}, '%')
+        </if>
+        ORDER BY qc.chapter_exam_id DESC
+    </select>
 </mapper>