Parcourir la source

fix 试卷题目

he2802 il y a 4 ans
Parent
commit
1836422905

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

@@ -0,0 +1,112 @@
+package com.zhongzheng.controller.bank;
+
+import java.util.List;
+import java.util.Arrays;
+
+import com.zhongzheng.modules.bank.bo.QuestionChapterAddBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterEditBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterQueryBo;
+import com.zhongzheng.modules.bank.service.IQuestionChapterService;
+import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
+import lombok.RequiredArgsConstructor;
+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 com.zhongzheng.common.annotation.Log;
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.common.utils.poi.ExcelUtil;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 章卷Controller
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Api(value = "章卷控制器", tags = {"章卷管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/bank/chapter")
+public class QuestionChapterController extends BaseController {
+
+    private final IQuestionChapterService iQuestionChapterService;
+
+    /**
+     * 查询章卷列表
+     */
+    @ApiOperation("查询章卷列表")
+    @PreAuthorize("@ss.hasPermi('system:chapter:list')")
+    @GetMapping("/list")
+    public TableDataInfo<QuestionChapterVo> list(QuestionChapterQueryBo bo) {
+        startPage();
+        List<QuestionChapterVo> list = iQuestionChapterService.queryList(bo);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出章卷列表
+     */
+  /*  @ApiOperation("导出章卷列表")
+    @PreAuthorize("@ss.hasPermi('system:chapter:export')")
+    @Log(title = "章卷", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult<QuestionChapterVo> export(QuestionChapterQueryBo bo) {
+        List<QuestionChapterVo> list = iQuestionChapterService.queryList(bo);
+        ExcelUtil<QuestionChapterVo> util = new ExcelUtil<QuestionChapterVo>(QuestionChapterVo.class);
+        return util.exportExcel(list, "章卷");
+    }*/
+
+    /**
+     * 获取章卷详细信息
+     */
+    @ApiOperation("获取章卷详细信息")
+    @PreAuthorize("@ss.hasPermi('system:chapter:query')")
+    @GetMapping("/{chapterExamId}")
+    public AjaxResult<QuestionChapterVo> getInfo(@PathVariable("chapterExamId" ) Long chapterExamId) {
+        return AjaxResult.success(iQuestionChapterService.queryById(chapterExamId));
+    }
+
+    /**
+     * 新增章卷
+     */
+    @ApiOperation("新增章卷")
+    @PreAuthorize("@ss.hasPermi('system:chapter:add')")
+    @Log(title = "章卷", businessType = BusinessType.INSERT)
+    @PostMapping()
+    public AjaxResult<Void> add(@RequestBody QuestionChapterAddBo bo) {
+        return toAjax(iQuestionChapterService.insertByAddBo(bo) ? 1 : 0);
+    }
+
+    /**
+     * 修改章卷
+     */
+    @ApiOperation("修改章卷")
+    @PreAuthorize("@ss.hasPermi('system:chapter:edit')")
+    @Log(title = "章卷", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    public AjaxResult<Void> edit(@RequestBody QuestionChapterEditBo bo) {
+        return toAjax(iQuestionChapterService.updateByEditBo(bo) ? 1 : 0);
+    }
+
+    /**
+     * 删除章卷
+     */
+    /*@ApiOperation("删除章卷")
+    @PreAuthorize("@ss.hasPermi('system:chapter:remove')")
+    @Log(title = "章卷" , businessType = BusinessType.DELETE)
+    @DeleteMapping("/{chapterExamIds}")
+    public AjaxResult<Void> remove(@PathVariable Long[] chapterExamIds) {
+        return toAjax(iQuestionChapterService.deleteWithValidByIds(Arrays.asList(chapterExamIds), true) ? 1 : 0);
+    }*/
+}

+ 45 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterAddBo.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
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@ApiModel("章卷添加对象")
+public class QuestionChapterAddBo {
+
+    /** 名称 */
+    @ApiModelProperty("名称")
+    private String name;
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long sort;
+    /** 添加时间 */
+    @ApiModelProperty("添加时间")
+    private Long createTime;
+    /** 修改时间 */
+    @ApiModelProperty("修改时间")
+    private Long updateTime;
+    /** 状态 1正常 0关闭 */
+    @ApiModelProperty("状态 1正常 0关闭")
+    private Integer status;
+    /** 前缀名称 */
+    @ApiModelProperty("前缀名称")
+    private String prefixName;
+    /** 发布状态 1发布 0未发布 */
+    @ApiModelProperty("发布状态 1发布 0未发布")
+    private Long publishStatus;
+    /** 编码 */
+    @ApiModelProperty("编码")
+    private String code;
+}

+ 53 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionChapterEditBo.java

@@ -0,0 +1,53 @@
+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
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@ApiModel("章卷编辑对象")
+public class QuestionChapterEditBo {
+
+    /** 章卷ID */
+    @ApiModelProperty("章卷ID")
+    private Long chapterExamId;
+
+    /** 名称 */
+    @ApiModelProperty("名称")
+    private String name;
+
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long sort;
+
+    /** 修改时间 */
+    @ApiModelProperty("修改时间")
+    private Long updateTime;
+
+    /** 状态 1正常 0关闭 */
+    @ApiModelProperty("状态 1正常 0关闭")
+    private Integer status;
+
+
+    /** 前缀名称 */
+    @ApiModelProperty("前缀名称")
+    private String prefixName;
+
+    /** 发布状态 1发布 0未发布 */
+    @ApiModelProperty("发布状态 1发布 0未发布")
+    private Long publishStatus;
+
+    /** 编码 */
+    @ApiModelProperty("编码")
+    private String code;
+
+}

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

@@ -0,0 +1,57 @@
+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
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel("章卷分页查询对象")
+public class QuestionChapterQueryBo extends BaseEntity {
+
+	/** 分页大小 */
+	@ApiModelProperty("分页大小")
+	private Integer pageSize;
+	/** 当前页数 */
+	@ApiModelProperty("当前页数")
+	private Integer pageNum;
+	/** 排序列 */
+	@ApiModelProperty("排序列")
+	private String orderByColumn;
+	/** 排序的方向desc或者asc */
+	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
+	private String isAsc;
+
+
+	/** 名称 */
+	@ApiModelProperty("名称")
+	private String name;
+	/** $column.columnComment */
+	@ApiModelProperty("$column.columnComment")
+	private Long sort;
+	/** 状态 1正常 0关闭 */
+	@ApiModelProperty("状态 1正常 0关闭")
+	private Integer status;
+	/** 前缀名称 */
+	@ApiModelProperty("前缀名称")
+	private String prefixName;
+	/** 发布状态 1发布 0未发布 */
+	@ApiModelProperty("发布状态 1发布 0未发布")
+	private Long publishStatus;
+	/** 编码 */
+	@ApiModelProperty("编码")
+	private String code;
+}

+ 47 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/QuestionChapter.java

@@ -0,0 +1,47 @@
+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
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("question_chapter")
+public class QuestionChapter implements Serializable {
+
+private static final long serialVersionUID=1L;
+
+    /** 章卷ID */
+    @TableId(value = "chapter_exam_id")
+    private Long chapterExamId;
+    /** 名称 */
+    private String name;
+    /** $column.columnComment */
+    private Long sort;
+    /** 添加时间 */
+    @TableField(fill = FieldFill.INSERT)
+    private Long createTime;
+    /** 修改时间 */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Long updateTime;
+    /** 状态 1正常 0关闭 */
+    private Integer status;
+    /** 前缀名称 */
+    private String prefixName;
+    /** 发布状态 1发布 0未发布 */
+    private Long publishStatus;
+    /** 编码 */
+    private String code;
+}

+ 13 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/QuestionChapterMapper.java

@@ -0,0 +1,13 @@
+package com.zhongzheng.modules.bank.mapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.bank.domain.QuestionChapter;
+
+/**
+ * 章卷Mapper接口
+ *
+ * @author hjl
+ * @date 2021-10-25
+ */
+public interface QuestionChapterMapper extends BaseMapper<QuestionChapter> {
+
+}

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

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

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

@@ -0,0 +1,104 @@
+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.QuestionChapterAddBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterEditBo;
+import com.zhongzheng.modules.bank.bo.QuestionChapterQueryBo;
+import com.zhongzheng.modules.bank.domain.QuestionChapter;
+import com.zhongzheng.modules.bank.mapper.QuestionChapterMapper;
+import com.zhongzheng.modules.bank.service.IQuestionChapterService;
+import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
+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 QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMapper, QuestionChapter> implements IQuestionChapterService {
+
+    @Override
+    public QuestionChapterVo queryById(Long chapterExamId){
+        QuestionChapter db = this.baseMapper.selectById(chapterExamId);
+        return BeanUtil.toBean(db, QuestionChapterVo.class);
+    }
+
+    @Override
+    public List<QuestionChapterVo> queryList(QuestionChapterQueryBo bo) {
+        LambdaQueryWrapper<QuestionChapter> lqw = Wrappers.lambdaQuery();
+        lqw.like(StrUtil.isNotBlank(bo.getName()), QuestionChapter::getName, bo.getName());
+        lqw.eq(bo.getSort() != null, QuestionChapter::getSort, bo.getSort());
+        lqw.eq(bo.getStatus() != null, QuestionChapter::getStatus, bo.getStatus());
+        lqw.like(StrUtil.isNotBlank(bo.getPrefixName()), QuestionChapter::getPrefixName, bo.getPrefixName());
+        lqw.eq(bo.getPublishStatus() != null, QuestionChapter::getPublishStatus, bo.getPublishStatus());
+        lqw.eq(StrUtil.isNotBlank(bo.getCode()), QuestionChapter::getCode, bo.getCode());
+        return entity2Vo(this.list(lqw));
+    }
+
+    /**
+    * 实体类转化成视图对象
+    *
+    * @param collection 实体类集合
+    * @return
+    */
+    private List<QuestionChapterVo> entity2Vo(Collection<QuestionChapter> collection) {
+        List<QuestionChapterVo> voList = collection.stream()
+                .map(any -> BeanUtil.toBean(any, QuestionChapterVo.class))
+                .collect(Collectors.toList());
+        if (collection instanceof Page) {
+            Page<QuestionChapter> page = (Page<QuestionChapter>)collection;
+            Page<QuestionChapterVo> pageVo = new Page<>();
+            BeanUtil.copyProperties(page,pageVo);
+            pageVo.addAll(voList);
+            voList = pageVo;
+        }
+        return voList;
+    }
+
+    @Override
+    public Boolean insertByAddBo(QuestionChapterAddBo bo) {
+        QuestionChapter add = BeanUtil.toBean(bo, QuestionChapter.class);
+        validEntityBeforeSave(add);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        return this.save(add);
+    }
+
+    @Override
+    public Boolean updateByEditBo(QuestionChapterEditBo bo) {
+        QuestionChapter update = BeanUtil.toBean(bo, QuestionChapter.class);
+        validEntityBeforeSave(update);
+        update.setUpdateTime(DateUtils.getNowTime());
+        return this.updateById(update);
+    }
+
+    /**
+     * 保存前的数据校验
+     *
+     * @param entity 实体类数据
+     */
+    private void validEntityBeforeSave(QuestionChapter entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return this.removeByIds(ids);
+    }
+}

+ 51 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/QuestionChapterVo.java

@@ -0,0 +1,51 @@
+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 QuestionChapterVo {
+	private static final long serialVersionUID = 1L;
+
+	/** 章卷ID */
+	@ApiModelProperty("章卷ID")
+	private Long chapterExamId;
+
+	/** 名称 */
+	@Excel(name = "名称")
+	@ApiModelProperty("名称")
+	private String name;
+	/** $column.columnComment */
+	@Excel(name = "名称")
+	@ApiModelProperty("$column.columnComment")
+	private Long sort;
+	/** 状态 1正常 0关闭 */
+	@Excel(name = "状态 1正常 0关闭")
+	@ApiModelProperty("状态 1正常 0关闭")
+	private Integer status;
+	/** 前缀名称 */
+	@Excel(name = "前缀名称")
+	@ApiModelProperty("前缀名称")
+	private String prefixName;
+	/** 发布状态 1发布 0未发布 */
+	@Excel(name = "发布状态 1发布 0未发布")
+	@ApiModelProperty("发布状态 1发布 0未发布")
+	private Long publishStatus;
+	/** 编码 */
+	@Excel(name = "编码")
+	@ApiModelProperty("编码")
+	private String code;
+}

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

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhongzheng.modules.bank.mapper.QuestionChapterMapper">
+
+    <resultMap type="com.zhongzheng.modules.bank.domain.QuestionChapter" id="QuestionChapterResult">
+        <result property="chapterExamId" column="chapter_exam_id"/>
+        <result property="name" column="name"/>
+        <result property="sort" column="sort"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="status" column="status"/>
+        <result property="prefixName" column="prefix_name"/>
+        <result property="publishStatus" column="publish_status"/>
+        <result property="code" column="code"/>
+    </resultMap>
+
+
+</mapper>