From 991e44b4bd4aadc5eb6dbbe196c7a0adc3295106 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Fri, 16 Jul 2021 18:55:33 +0800
Subject: [PATCH] 考试管理

---
 src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java          |   13 +-
 src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java |   13 --
 src/main/java/org/springblade/modules/exam/entity/ExamPaper.java                  |   80 ++++++++++++---
 src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java            |   16 ---
 src/main/java/org/springblade/modules/exam/service/ExamPaperService.java          |   20 +---
 src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java    |   58 ++++-------
 src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml             |   58 -----------
 src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java                    |   31 -----
 src/main/resources/application.yml                                                |    1 
 9 files changed, 98 insertions(+), 192 deletions(-)

diff --git a/src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java b/src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java
index 0d06085..2a41307 100644
--- a/src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java
+++ b/src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java
@@ -4,10 +4,10 @@
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions are met:
  *
- *  Redistributions of source code must retain the above copyright notice,
+ *  Redistributions of source code must retain the above copyright exam,
  *  this list of conditions and the following disclaimer.
  *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
+ *  exam, this list of conditions and the following disclaimer in the
  *  documentation and/or other materials provided with the distribution.
  *  Neither the name of the dreamlu.net developer nor the names of its
  *  contributors may be used to endorse or promote products derived from
@@ -54,50 +54,32 @@
 	 */
 	@GetMapping("/detail")
 	@ApiOperationSupport(order = 1)
-	@ApiOperation(value = "详情", notes = "传入notice")
-	public R<ExamPaperVO> detail(ExamPaper notice) {
-		ExamPaper detail = examPaperService.getOne(Condition.getQueryWrapper(notice));
+	@ApiOperation(value = "详情", notes = "传入exam")
+	public R<ExamPaperVO> detail(ExamPaper exam) {
+		ExamPaper detail = examPaperService.getOne(Condition.getQueryWrapper(exam));
 		return R.data(ExamPaperWrapper.build().entityVO(detail));
 	}
 
 	/**
 	 * 分页
 	 */
-	@GetMapping("/list")
-	@ApiImplicitParams({
-		@ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"),
-		@ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string")
-	})
+	@GetMapping("/page")
 	@ApiOperationSupport(order = 2)
-	@ApiOperation(value = "分页", notes = "传入notice")
-	public R<IPage<ExamPaperVO>> list(@ApiIgnore @RequestParam Map<String, Object> notice, Query query) {
-		IPage<ExamPaper> pages = examPaperService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, ExamPaper.class));
+	@ApiOperation(value = "分页", notes = "传入exam")
+	public R<IPage<ExamPaperVO>> list(@ApiIgnore @RequestParam Map<String, Object> exam, Query query) {
+		IPage<ExamPaper> pages = examPaperService.page(Condition.getPage(query), Condition.getQueryWrapper(exam, ExamPaper.class));
 		return R.data(ExamPaperWrapper.build().pageVO(pages));
 	}
 
-	/**
-	 * 多表联合查询自定义分页
-	 */
-	@GetMapping("/page")
-	@ApiImplicitParams({
-		@ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"),
-		@ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string")
-	})
-	@ApiOperationSupport(order = 3)
-	@ApiOperation(value = "分页", notes = "传入notice")
-	public R<IPage<ExamPaperVO>> page(@ApiIgnore ExamPaperVO notice, Query query) {
-		IPage<ExamPaperVO> pages = examPaperService.selectExamPaperPage(Condition.getPage(query), notice);
-		return R.data(pages);
-	}
 
 	/**
 	 * 新增
 	 */
 	@PostMapping("/save")
 	@ApiOperationSupport(order = 4)
-	@ApiOperation(value = "新增", notes = "传入notice")
-	public R save(@RequestBody ExamPaper notice) {
-		return R.status(examPaperService.save(notice));
+	@ApiOperation(value = "新增", notes = "传入exam")
+	public R save(@RequestBody ExamPaper exam) {
+		return R.status(examPaperService.save(exam));
 	}
 
 	/**
@@ -105,9 +87,9 @@
 	 */
 	@PostMapping("/update")
 	@ApiOperationSupport(order = 5)
-	@ApiOperation(value = "修改", notes = "传入notice")
-	public R update(@RequestBody ExamPaper notice) {
-		return R.status(examPaperService.updateById(notice));
+	@ApiOperation(value = "修改", notes = "传入exam")
+	public R update(@RequestBody ExamPaper exam) {
+		return R.status(examPaperService.updateById(exam));
 	}
 
 	/**
@@ -115,9 +97,9 @@
 	 */
 	@PostMapping("/submit")
 	@ApiOperationSupport(order = 6)
-	@ApiOperation(value = "新增或修改", notes = "传入notice")
-	public R submit(@RequestBody ExamPaper notice) {
-		return R.status(examPaperService.saveOrUpdate(notice));
+	@ApiOperation(value = "新增或修改", notes = "传入exam")
+	public R submit(@RequestBody ExamPaper exam) {
+		return R.status(examPaperService.saveOrUpdate(exam));
 	}
 
 	/**
@@ -125,9 +107,9 @@
 	 */
 	@PostMapping("/remove")
 	@ApiOperationSupport(order = 7)
-	@ApiOperation(value = "逻辑删除", notes = "传入notice")
+	@ApiOperation(value = "逻辑删除", notes = "传入exam")
 	public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
-		boolean temp = examPaperService.deleteLogic(Func.toLongList(ids));
+		boolean temp = examPaperService.removeByIds(Func.toLongList(ids));
 		return R.status(temp);
 	}
 
diff --git a/src/main/java/org/springblade/modules/exam/entity/ExamPaper.java b/src/main/java/org/springblade/modules/exam/entity/ExamPaper.java
index 5b24b78..cb4e7f7 100644
--- a/src/main/java/org/springblade/modules/exam/entity/ExamPaper.java
+++ b/src/main/java/org/springblade/modules/exam/entity/ExamPaper.java
@@ -16,13 +16,16 @@
  */
 package org.springblade.modules.exam.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.springblade.core.tenant.mp.TenantEntity;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -31,40 +34,81 @@
  * @author Chill
  */
 @Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("blade_notice")
-public class ExamPaper extends TenantEntity {
+@TableName("ksxt_exam")
+public class ExamPaper implements Serializable {
 
 	private static final long serialVersionUID = 1L;
 
 	/**
-	 * 标题
+	 * ID
 	 */
-	@ApiModelProperty(value = "标题")
-	private String title;
+	@ApiModelProperty(value = "id")
+	@TableId(value = "id", type = IdType.AUTO)
+	private Long id;
 
 	/**
-	 * 通知类型
+	 * 考试名称
 	 */
-	@ApiModelProperty(value = "通知类型")
-	private Integer category;
+	@TableField("exam_name")
+	private String exam_name;
 
 	/**
-	 * 发布日期
+	 * 考试类型
 	 */
-	@ApiModelProperty(value = "发布日期")
-	private Date releaseTime;
+	@TableField("exam_type")
+	private String exam_type;
 
 	/**
-	 * 内容
+	 * 注意事项
 	 */
-	@ApiModelProperty(value = "内容")
-	private String content;
+	@TableField("exam_attention")
+	private String exam_attention;
 
 	/**
-	 * 单位id
+	 * 考试开始时间
 	 */
-	@TableField("dept_id")
-	private Long deptId;
+	@TableField("start_time")
+	private Date start_time;
+
+	/**
+	 * 考试结束时间
+	 */
+	@TableField("end_time")
+	private Date end_time;
+
+	/**
+	 * 时间区间
+	 */
+	@TableField("exam_time")
+	private String exam_time;
+
+	/**
+	 * 总分
+	 */
+	@TableField("total_score")
+	private String total_score;
+
+	/**
+	 * 状态
+	 */
+	@TableField("exam_status")
+	private String exam_status;
+
+	/**
+	 * 创建人
+	 */
+	private String creator;
+
+	/**
+	 * 创建时间
+	 */
+	@TableField("creator_date")
+	private Date creator_date;
+
+	/**
+	 * 备注
+	 */
+	private String remark;
+
 
 }
diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
index 622f5a7..55318f7 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
@@ -32,21 +32,5 @@
  */
 public interface ExamPaperMapper extends BaseMapper<ExamPaper> {
 
-	/**
-	 * 前N条数据
-	 *
-	 * @param number 数量
-	 * @return List<Notice>
-	 */
-	List<ExamPaper> topList(Integer number);
-
-	/**
-	 * 自定义分页
-	 *
-	 * @param page   分页
-	 * @param exam 实体
-	 * @return List<NoticeVO>
-	 */
-	List<ExamPaperVO> selectNoticePage(IPage page, ExamPaperVO exam);
 
 }
diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
index aa9ba40..68fe17c 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -16,63 +16,5 @@
         <result column="content" property="content"/>
     </resultMap>
 
-    <!-- 通用查询映射结果 -->
-    <resultMap id="noticeVOResultMap" type="org.springblade.modules.exam.vo.ExamPaperVO">
-        <result column="id" property="id"/>
-        <result column="create_user" property="createUser"/>
-        <result column="create_time" property="createTime"/>
-        <result column="update_user" property="updateUser"/>
-        <result column="update_time" property="updateTime"/>
-        <result column="status" property="status"/>
-        <result column="is_deleted" property="isDeleted"/>
-        <result column="release_time" property="releaseTime"/>
-        <result column="title" property="title"/>
-        <result column="content" property="content"/>
-    </resultMap>
 
-    <select id="topList" resultMap="noticeResultMap">
-        select * from blade_notice limit #{number}
-    </select>
-
-    <select id="selectNoticePage" resultMap="noticeVOResultMap">
-        SELECT
-        n.*,
-        d.dict_value AS categoryName
-        FROM
-        blade_notice n
-        LEFT JOIN
-        ( SELECT * FROM blade_dict WHERE code = 'notice' ) d
-        ON
-        n.category = d.dict_key
-        <if test="notice.deptId!=null and notice.jurisdiction!=null">
-            left join
-            blade_user bu
-            on
-            bu.dept_id = n.dept_id
-        </if>
-        WHERE
-        n.is_deleted = 0
-        <if test="notice.title!=null">
-            and n.title like concat(concat('%', #{notice.title}), '%')
-        </if>
-        <if test="notice.category!=null">
-            and n.category = #{notice.category}
-        </if>
-        <if test="notice.deptId!=null and notice.jurisdiction!=null">
-            and (n.dept_id = #{notice.deptId} or bu.jurisdiction = #{notice.jurisdiction}
-            or n.dept_id = 1123598813738675201
-            )
-        </if>
-        <if test="notice.deptId!=null and notice.jurisdiction==null">
-            and (n.dept_id = #{notice.deptId} and n.category=2
-            or n.dept_id = 1123598813738675201
-            )
-        </if>
-        <if test="notice.startTime!=null and notice.startTime!=''">
-            and n.release_time &gt;= #{notice.startTime}
-        </if>
-        <if test="notice.endTime!=null and notice.endTime!=''">
-            and n.release_time &lt;= #{notice.endTime}
-        </if>
-    </select>
 </mapper>
diff --git a/src/main/java/org/springblade/modules/exam/service/ExamPaperService.java b/src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
index 55073a8..2421710 100644
--- a/src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
+++ b/src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
@@ -4,10 +4,10 @@
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions are met:
  *
- *  Redistributions of source code must retain the above copyright notice,
+ *  Redistributions of source code must retain the above copyright exam,
  *  this list of conditions and the following disclaimer.
  *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
+ *  exam, this list of conditions and the following disclaimer in the
  *  documentation and/or other materials provided with the distribution.
  *  Neither the name of the dreamlu.net developer nor the names of its
  *  contributors may be used to endorse or promote products derived from
@@ -16,26 +16,16 @@
  */
 package org.springblade.modules.exam.service;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.springblade.core.mp.base.BaseService;
-import org.springblade.modules.desk.entity.Notice;
-import org.springblade.modules.desk.vo.NoticeVO;
+import com.baomidou.mybatisplus.extension.service.IService;
 import org.springblade.modules.exam.entity.ExamPaper;
-import org.springblade.modules.exam.vo.ExamPaperVO;
 
 /**
  * 服务类
  *
  * @author Chill
  */
-public interface ExamPaperService extends BaseService<ExamPaper> {
+public interface ExamPaperService extends IService<ExamPaper> {
 
-	/**
-	 * 自定义分页
-	 * @param page
-	 * @param exam
-	 * @return
-	 */
-	IPage<ExamPaperVO> selectExamPaperPage(IPage<ExamPaperVO> page, ExamPaperVO exam);
+
 
 }
diff --git a/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java b/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
index d4f0a0b..4864a20 100644
--- a/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
@@ -16,13 +16,10 @@
  */
 package org.springblade.modules.exam.service.impl;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.springblade.core.mp.base.BaseServiceImpl;
-import org.springblade.core.secure.utils.AuthUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springblade.modules.exam.entity.ExamPaper;
 import org.springblade.modules.exam.mapper.ExamPaperMapper;
 import org.springblade.modules.exam.service.ExamPaperService;
-import org.springblade.modules.exam.vo.ExamPaperVO;
 import org.springframework.stereotype.Service;
 
 /**
@@ -31,13 +28,7 @@
  * @author Chill
  */
 @Service
-public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamPaper> implements ExamPaperService {
+public class ExamPaperServiceImpl extends ServiceImpl<ExamPaperMapper, ExamPaper> implements ExamPaperService {
 
-	@Override
-	public IPage<ExamPaperVO> selectExamPaperPage(IPage<ExamPaperVO> page, ExamPaperVO exam) {
-		// 若不使用mybatis-plus自带的分页方法,则不会自动带入tenantId,所以我们需要自行注入
-		exam.setTenantId(AuthUtil.getTenantId());
-		return page.setRecords(baseMapper.selectNoticePage(page, exam));
-	}
 
 }
diff --git a/src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java b/src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java
index 227726b..2a411c4 100644
--- a/src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java
+++ b/src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java
@@ -1,9 +1,8 @@
 package org.springblade.modules.exam.vo;
 
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import org.springblade.modules.desk.entity.Notice;
+import org.springblade.modules.exam.entity.ExamPaper;
 
 /**
  * 通知公告视图类
@@ -12,32 +11,6 @@
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
-public class ExamPaperVO extends Notice {
-
-	@ApiModelProperty(value = "通知类型名")
-	private String categoryName;
-
-	@ApiModelProperty(value = "租户编号")
-	private String tenantId;
-
-	/**
-	 * 通知开始时间
-	 */
-	private String startTime;
-
-	/**
-	 * 通知结束时间
-	 */
-	private String endTime;
-
-	/**
-	 * 行政区(辖区)id
-	 */
-	private Long jurisdiction;
-
-	/**
-	 * 用户id
-	 */
-	private Long userId;
+public class ExamPaperVO extends ExamPaper {
 
 }
diff --git a/src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java b/src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java
index d413d0e..ad60ffc 100644
--- a/src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java
+++ b/src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java
@@ -4,10 +4,10 @@
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions are met:
  *
- *  Redistributions of source code must retain the above copyright notice,
+ *  Redistributions of source code must retain the above copyright exam,
  *  this list of conditions and the following disclaimer.
  *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
+ *  exam, this list of conditions and the following disclaimer in the
  *  documentation and/or other materials provided with the distribution.
  *  Neither the name of the dreamlu.net developer nor the names of its
  *  contributors may be used to endorse or promote products derived from
@@ -37,11 +37,10 @@
 	}
 
 	@Override
-	public ExamPaperVO entityVO(ExamPaper notice) {
-		ExamPaperVO noticeVO = Objects.requireNonNull(BeanUtil.copy(notice, ExamPaperVO.class));
-		String dictValue = DictCache.getValue(DictEnum.NOTICE, noticeVO.getCategory());
-		noticeVO.setCategoryName(dictValue);
-		return noticeVO;
+	public ExamPaperVO entityVO(ExamPaper exam) {
+		ExamPaperVO examVO = Objects.requireNonNull(BeanUtil.copy(exam, ExamPaperVO.class));
+//		String dictValue = DictCache.getValue(DictEnum.NOTICE, examVO.getCategory());
+		return examVO;
 	}
 
 }
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 0b4dec6..67a2a2b 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -202,6 +202,7 @@
       - /trainingRegistration/**
       - /workReport/**
       - /examSubjectChoices/**
+      - /exampaper/**
     #授权认证配置
     auth:
       - method: ALL

--
Gitblit v1.9.3