Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
c4a0683e96 | 10 months ago |
@ -1,30 +0,0 @@
|
||||
<!-- 声明 XML 文档版本为 1.0,并指定字符编码为 UTF-8 -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 定义文档类型,引用 MyBatis Mapper 的 DTD 规范,用于验证当前 XML 文档结构是否符合 MyBatis Mapper 3.0 标准 -->
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<!-- 定义一个 MyBatis Mapper 命名空间,将此 XML 映射文件与对应的 Java Mapper 接口关联起来 -->
|
||||
<!-- namespace 属性值为 Java Mapper 接口的全限定名 -->
|
||||
<mapper namespace="com.yf.exam.modules.exam.mapper.ExamDepartMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<!-- 定义一个结果映射,将数据库查询结果映射到 Java 对象 -->
|
||||
<!-- id 属性为结果映射的唯一标识,可在其他 SQL 语句中引用 -->
|
||||
<!-- type 属性指定映射的 Java 对象的全限定类名 -->
|
||||
<resultMap id="BaseResultMap" type="com.yf.exam.modules.exam.entity.ExamDepart">
|
||||
<!-- 映射数据库表的主键列到 Java 对象的属性 -->
|
||||
<!-- column 属性为数据库表的列名 -->
|
||||
<!-- property 属性为 Java 对象的属性名 -->
|
||||
<id column="id" property="id" />
|
||||
<!-- 映射数据库表的普通列到 Java 对象的属性 -->
|
||||
<result column="exam_id" property="examId" />
|
||||
<result column="depart_id" property="departId" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<!-- 定义一段可复用的 SQL 片段,包含常用的查询列 -->
|
||||
<!-- id 属性为 SQL 片段的唯一标识,可在其他 SQL 语句中通过 <include> 标签引用 -->
|
||||
<sql id="Base_Column_List">
|
||||
`id`,`exam_id`,`depart_id`
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
@ -1,28 +0,0 @@
|
||||
package com.yf.exam.config;
|
||||
|
||||
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
|
||||
|
||||
// * 文件上传配置
|
||||
// * @author bool
|
||||
// * @date 2019-07-29 16:23
|
||||
//
|
||||
@Configuration
|
||||
public class MultipartConfig {
|
||||
|
||||
@Bean
|
||||
public MultipartConfigElement multipartConfigElement() {
|
||||
MultipartConfigFactory factory = new MultipartConfigFactory();
|
||||
// 单个数据大小
|
||||
factory.setMaxFileSize(DataSize.ofMegabytes(5000L));
|
||||
// 总上传数据大小
|
||||
factory.setMaxRequestSize(DataSize.ofMegabytes(5000L));
|
||||
return factory.createMultipartConfig();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package com.yf.exam.config;
|
||||
|
||||
import com.yf.exam.aspect.mybatis.QueryInterceptor;
|
||||
import com.yf.exam.aspect.mybatis.UpdateInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
// * Mybatis过滤器配置
|
||||
// * 注意:必须按顺序进行配置,否则容易出现业务异常
|
||||
// * @author bool
|
||||
|
||||
@Configuration
|
||||
@MapperScan("com.yf.exam.modules.**.mapper")
|
||||
public class MybatisConfig {
|
||||
|
||||
|
||||
// * 数据查询过滤器
|
||||
|
||||
@Bean
|
||||
public QueryInterceptor queryInterceptor() {
|
||||
QueryInterceptor query = new QueryInterceptor();
|
||||
query.setLimit(-1L);
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
// * 插入数据过滤器
|
||||
|
||||
@Bean
|
||||
public UpdateInterceptor updateInterceptor() {
|
||||
return new UpdateInterceptor();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
package com.yf.exam.config;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
|
||||
// * 任务调度配置类,启用定时任务和异步任务的支持。
|
||||
// *
|
||||
// * @author bool
|
||||
|
||||
@Log4j2
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
@EnableAsync
|
||||
public class ScheduledConfig implements SchedulingConfigurer, AsyncConfigurer {
|
||||
|
||||
|
||||
// * 定义定时任务使用的线程池。
|
||||
// *
|
||||
// * @return 配置好的ThreadPoolTaskScheduler实例
|
||||
|
||||
@Bean(destroyMethod = "shutdown", name = "taskScheduler")
|
||||
public ThreadPoolTaskScheduler taskScheduler() {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setPoolSize(10); // 设置线程池大小为10
|
||||
scheduler.setThreadNamePrefix("task-"); // 设置线程名称前缀为"task-"
|
||||
scheduler.setAwaitTerminationSeconds(600); // 设置等待终止时间为600秒
|
||||
scheduler.setWaitForTasksToCompleteOnShutdown(true); // 设置在关闭时等待任务完成
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
|
||||
// * 定义异步任务执行使用的线程池。
|
||||
// *
|
||||
// * @return 配置好的ThreadPoolTaskExecutor实例
|
||||
|
||||
@Bean(name = "asyncExecutor")
|
||||
public ThreadPoolTaskExecutor asyncExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(10); // 设置核心线程池大小为10
|
||||
executor.setQueueCapacity(1000); // 设置队列容量为1000
|
||||
executor.setKeepAliveSeconds(600); // 设置线程空闲时间为600秒
|
||||
executor.setMaxPoolSize(20); // 设置最大线程池大小为20
|
||||
executor.setThreadNamePrefix("taskExecutor-"); // 设置线程名称前缀为"taskExecutor-"
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // 设置拒绝策略为CallerRunsPolicy
|
||||
executor.initialize(); // 初始化线程池
|
||||
return executor;
|
||||
}
|
||||
|
||||
|
||||
// * 配置定时任务注册器,使用自定义的线程池。
|
||||
// *
|
||||
// * @param scheduledTaskRegistrar 定时任务注册器
|
||||
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
|
||||
ThreadPoolTaskScheduler taskScheduler = taskScheduler(); // 获取自定义的线程池调度器
|
||||
scheduledTaskRegistrar.setTaskScheduler(taskScheduler); // 设置定时任务注册器使用的线程池调度器
|
||||
}
|
||||
|
||||
|
||||
// * 获取异步任务执行器。
|
||||
// *
|
||||
// * @return 自定义的ThreadPoolTaskExecutor实例
|
||||
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
return asyncExecutor(); // 返回自定义的异步任务执行器
|
||||
}
|
||||
|
||||
|
||||
// * 定义异步任务未捕获异常的处理逻辑。
|
||||
// *
|
||||
// * @return 异步任务未捕获异常的处理程序
|
||||
|
||||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return (throwable, method, objects) -> {
|
||||
log.error("异步任务执行出现异常, message {}, method {}, params {}", throwable.getMessage(), method, objects);
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.yf.exam.core.annon;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
///**
|
||||
// * 数据字典注解,用于标识字段需要从数据字典中获取对应的文本信息。
|
||||
// * @author bool
|
||||
// */
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Dict {
|
||||
// /**
|
||||
// * 必须指定的数据字典编码,用于唯一标识一个数据字典。
|
||||
// * @return 数据字典编码。
|
||||
// */
|
||||
String dicCode();
|
||||
|
||||
// /**
|
||||
// * 可选的数据字典文本,默认为空字符串。
|
||||
// * @return 数据字典文本。
|
||||
// */
|
||||
String dicText() default "";
|
||||
|
||||
// /**
|
||||
// * 可选的数据字典表名,默认为空字符串。
|
||||
// * @return 数据字典表名。
|
||||
// */
|
||||
String dictTable() default "";
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
package com.yf.exam.core.api;
|
||||
|
||||
|
||||
import com.yf.exam.core.api.ApiError;
|
||||
import com.yf.exam.core.exception.ServiceException;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
///**
|
||||
// * 数据结果返回的封装
|
||||
// * @author bool
|
||||
// * @date 2018/11/20 09:48
|
||||
// */
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value="接口响应", description="接口响应")
|
||||
public class ApiRest<T>{
|
||||
|
||||
// /**
|
||||
// * 响应消息
|
||||
// */
|
||||
@ApiModelProperty(value = "响应消息")
|
||||
private String msg;
|
||||
// /**
|
||||
// * 响应代码
|
||||
// */
|
||||
@ApiModelProperty(value = "响应代码,0为成功,1为失败", required = true)
|
||||
private Integer code;
|
||||
|
||||
// /**
|
||||
// * 请求或响应body
|
||||
// */
|
||||
@ApiModelProperty(value = "响应内容")
|
||||
protected T data;
|
||||
|
||||
|
||||
// /**
|
||||
// * 是否成功
|
||||
// * @return
|
||||
// */
|
||||
public boolean isSuccess(){
|
||||
return code.equals(0);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 构造函数
|
||||
// * @param error
|
||||
// */
|
||||
public ApiRest(ServiceException error){
|
||||
this.code = error.getCode();
|
||||
this.msg = error.getMsg();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 构造函数
|
||||
// * @param error
|
||||
// */
|
||||
public ApiRest(ApiError error){
|
||||
this.code = error.getCode();
|
||||
this.msg = error.msg;
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.yf.exam.core.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
///**
|
||||
// * 请求和响应的基础类,用于处理序列化
|
||||
// * @author dav
|
||||
// * @date 2019/3/16 15:56
|
||||
// */
|
||||
@Data
|
||||
public class BaseDTO implements Serializable {
|
||||
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package com.yf.exam.core.enums;
|
||||
|
||||
///**
|
||||
// * 通用的状态枚举信息
|
||||
// *
|
||||
// * @author bool
|
||||
// * @date 2019-09-17 17:57
|
||||
// */
|
||||
public interface CommonState {
|
||||
|
||||
// /**
|
||||
// * 普通状态,正常的
|
||||
// */
|
||||
Integer NORMAL = 0;
|
||||
// /**
|
||||
// * 非正常状态,禁用,下架等
|
||||
// */
|
||||
Integer ABNORMAL = 1;
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
package com.yf.exam.core.enums;
|
||||
|
||||
///**
|
||||
// * 开放方式
|
||||
// * @author bool
|
||||
// */
|
||||
public interface OpenType {
|
||||
|
||||
// /**
|
||||
// * 完全开放
|
||||
// */
|
||||
Integer OPEN = 1;
|
||||
|
||||
// /**
|
||||
// * 部门开放
|
||||
// */
|
||||
Integer DEPT_OPEN = 2;
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.yf.exam.core.exception;
|
||||
|
||||
import com.yf.exam.core.api.ApiError;
|
||||
import com.yf.exam.core.api.ApiRest;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ServiceException extends RuntimeException{
|
||||
|
||||
// /**
|
||||
// * 错误码
|
||||
// */
|
||||
private Integer code;
|
||||
|
||||
// /**
|
||||
// * 错误消息
|
||||
// */
|
||||
private String msg;
|
||||
|
||||
// /**
|
||||
// * 从结果初始化
|
||||
// * @param apiRest
|
||||
// */
|
||||
public ServiceException(ApiRest apiRest){
|
||||
this.code = apiRest.getCode();
|
||||
this.msg = apiRest.getMsg();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 从枚举中获取参数
|
||||
// * @param apiError
|
||||
// */
|
||||
public ServiceException(ApiError apiError){
|
||||
this.code = apiError.getCode();
|
||||
this.msg = apiError.msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常构造
|
||||
* @param msg
|
||||
*/
|
||||
public ServiceException(String msg){
|
||||
this.code = 1;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.yf.exam.core.utils;
|
||||
|
||||
import org.dozer.DozerBeanMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
///**
|
||||
// * 简单封装Dozer, 实现深度转换Bean<->Bean的Mapper.实现:
|
||||
// *
|
||||
// * 1. 持有Mapper的单例.
|
||||
// * 2. 返回值类型转换.
|
||||
// * 3. 批量转换Collection中的所有对象.
|
||||
// * 4. 区分创建新的B对象与将对象A值复制到已存在的B对象两种函数.
|
||||
// *
|
||||
// */
|
||||
public class BeanMapper {
|
||||
|
||||
// /**
|
||||
// * 持有Dozer单例, 避免重复创建DozerMapper消耗资源.
|
||||
// */
|
||||
private static DozerBeanMapper dozerBeanMapper = new DozerBeanMapper();
|
||||
|
||||
// /**
|
||||
// * 基于Dozer转换对象的类型.
|
||||
// */
|
||||
public static <T> T map(Object source, Class<T> destinationClass) {
|
||||
return dozerBeanMapper.map(source, destinationClass);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 基于Dozer转换Collection中对象的类型.
|
||||
// */
|
||||
public static <T> List<T> mapList(Iterable<?> sourceList, Class<T> destinationClass) {
|
||||
List<T> destinationList = new ArrayList();
|
||||
for (Object sourceObject : sourceList) {
|
||||
T destinationObject = dozerBeanMapper.map(sourceObject, destinationClass);
|
||||
destinationList.add(destinationObject);
|
||||
}
|
||||
return destinationList;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 基于Dozer将对象A的值拷贝到对象B中.
|
||||
// */
|
||||
public static void copy(Object source, Object destinationObject) {
|
||||
if(source!=null) {
|
||||
dozerBeanMapper.map(source, destinationObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, S> List<T> mapList(Collection<S> source, Function<? super S, ? extends T> mapper) {
|
||||
return source.stream().map(mapper).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
package com.yf.exam.core.utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
///**
|
||||
// * 时间转换quartz表达式
|
||||
// * @author bool
|
||||
// * @date 2020/11/29 下午3:00
|
||||
// */
|
||||
public class CronUtils {
|
||||
|
||||
// /**
|
||||
// * 格式化数据
|
||||
// */
|
||||
private static final String DATE_FORMAT = "ss mm HH dd MM ? yyyy";
|
||||
|
||||
// /**
|
||||
// * 准确的时间点到表达式
|
||||
// * @param date
|
||||
// * @return
|
||||
// */
|
||||
public static String dateToCron(final Date date){
|
||||
SimpleDateFormat fmt = new SimpleDateFormat(DATE_FORMAT);
|
||||
String formatTimeStr = "";
|
||||
if (date != null) {
|
||||
formatTimeStr = fmt.format(date);
|
||||
}
|
||||
return formatTimeStr;
|
||||
}
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
package com.yf.exam.core.utils.passwd;
|
||||
|
||||
|
||||
import com.yf.exam.core.utils.file.Md5Util;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
///**
|
||||
// * 通用的密码处理类,用于生成密码和校验密码
|
||||
// * ClassName: PassGenerator <br/>
|
||||
// * date: 2017年12月13日 下午7:13:03 <br/>
|
||||
// *
|
||||
// * @author Bool
|
||||
// * @version
|
||||
// */
|
||||
public class PassHandler {
|
||||
|
||||
// /**
|
||||
// * checkPass:校验密码是否一致
|
||||
// * @author Bool
|
||||
// * @param inputPass 用户传入的密码
|
||||
// * @param salt 数据库保存的密码随机码
|
||||
// * @param pass 数据库保存的密码MD5
|
||||
// * @return
|
||||
// */
|
||||
public static boolean checkPass(String inputPass , String salt , String pass){
|
||||
String pwdMd5 = Md5Util.md5(inputPass);
|
||||
return Md5Util.md5(pwdMd5 + salt).equals(pass);
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// *
|
||||
// * buildPassword:用于用户注册时产生一个密码
|
||||
// * @author Bool
|
||||
// * @param inputPass 输入的密码
|
||||
// * @return PassInfo 返回一个密码对象,记得保存
|
||||
// */
|
||||
public static PassInfo buildPassword(String inputPass) {
|
||||
|
||||
//产生一个6位数的随机码
|
||||
String salt = RandomStringUtils.randomAlphabetic(6);
|
||||
//加密后的密码
|
||||
String encryptPassword = Md5Util.md5(Md5Util.md5(inputPass)+salt);
|
||||
//返回对象
|
||||
return new PassInfo(salt,encryptPassword);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
PassInfo info = buildPassword("190601");
|
||||
|
||||
System.out.println(info.getPassword());
|
||||
System.out.println(info.getSalt());
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
package com.yf.exam.core.utils.passwd;
|
||||
|
||||
///**
|
||||
// * 密码实体类,用于存储和管理密码及其随机盐值。
|
||||
// *
|
||||
// * @author Bool
|
||||
// * @version 2018年2月13日 下午7:13:50
|
||||
// */
|
||||
public class PassInfo {
|
||||
|
||||
// /**
|
||||
// * 密码的随机盐值。
|
||||
// * 用于增强密码的安全性。
|
||||
// */
|
||||
private String salt;
|
||||
|
||||
// /**
|
||||
// * 经过MD5哈希处理后的密码。
|
||||
// * 存储最终用于验证的密码字符串。
|
||||
// */
|
||||
private String password;
|
||||
|
||||
// /**
|
||||
// * 构造方法,用于初始化密码实体对象。
|
||||
// *
|
||||
// * @param salt 密码的随机盐值
|
||||
// * @param password 经过MD5哈希处理后的密码
|
||||
// */
|
||||
public PassInfo(String salt, String password) {
|
||||
super();
|
||||
this.salt = salt;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 获取密码的随机盐值。
|
||||
// *
|
||||
// * @return 密码的随机盐值
|
||||
// */
|
||||
public String getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 设置密码的随机盐值。
|
||||
// *
|
||||
// * @param salt 密码的随机盐值
|
||||
// */
|
||||
public void setSalt(String salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 获取经过MD5哈希处理后的密码。
|
||||
// *
|
||||
// * @return 经过MD5哈希处理后的密码
|
||||
// */
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 设置经过MD5哈希处理后的密码。
|
||||
// *
|
||||
// * @param password 经过MD5哈希处理后的密码
|
||||
// */
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
@ -1,151 +0,0 @@
|
||||
package com.yf.exam.modules.exam.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yf.exam.core.api.ApiRest;
|
||||
import com.yf.exam.core.api.controller.BaseController;
|
||||
import com.yf.exam.core.api.dto.BaseIdReqDTO;
|
||||
import com.yf.exam.core.api.dto.BaseIdsReqDTO;
|
||||
import com.yf.exam.core.api.dto.BaseStateReqDTO;
|
||||
import com.yf.exam.core.api.dto.PagingReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSaveReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamOnlineRespDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamReviewRespDTO;
|
||||
import com.yf.exam.modules.exam.entity.Exam;
|
||||
import com.yf.exam.modules.exam.service.ExamService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试控制器
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
@Api(tags={"考试"})
|
||||
@RestController
|
||||
@RequestMapping("/exam/api/exam/exam")
|
||||
public class ExamController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ExamService baseService;
|
||||
|
||||
// /**
|
||||
// * 添加或修改
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
@RequiresRoles("sa")
|
||||
@ApiOperation(value = "添加或修改")
|
||||
@RequestMapping(value = "/save", method = { RequestMethod.POST})
|
||||
public ApiRest save(@RequestBody ExamSaveReqDTO reqDTO) {
|
||||
//复制参数
|
||||
baseService.save(reqDTO);
|
||||
return super.success();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 批量删除
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
@RequiresRoles("sa")
|
||||
@ApiOperation(value = "批量删除")
|
||||
@RequestMapping(value = "/delete", method = { RequestMethod.POST})
|
||||
public ApiRest edit(@RequestBody BaseIdsReqDTO reqDTO) {
|
||||
//根据ID删除
|
||||
baseService.removeByIds(reqDTO.getIds());
|
||||
return super.success();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 查找详情
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
@ApiOperation(value = "查找详情")
|
||||
@RequestMapping(value = "/detail", method = { RequestMethod.POST})
|
||||
public ApiRest<ExamSaveReqDTO> find(@RequestBody BaseIdReqDTO reqDTO) {
|
||||
ExamSaveReqDTO dto = baseService.findDetail(reqDTO.getId());
|
||||
return super.success(dto);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 查找详情
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
@RequiresRoles("sa")
|
||||
@ApiOperation(value = "查找详情")
|
||||
@RequestMapping(value = "/state", method = { RequestMethod.POST})
|
||||
public ApiRest state(@RequestBody BaseStateReqDTO reqDTO) {
|
||||
|
||||
QueryWrapper<Exam> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().in(Exam::getId, reqDTO.getIds());
|
||||
Exam exam = new Exam();
|
||||
exam.setState(reqDTO.getState());
|
||||
exam.setUpdateTime(new Date());
|
||||
|
||||
baseService.update(exam, wrapper);
|
||||
return super.success();
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 分页查找
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
@ApiOperation(value = "考试视角")
|
||||
@RequestMapping(value = "/online-paging", method = { RequestMethod.POST})
|
||||
public ApiRest<IPage<ExamOnlineRespDTO>> myPaging(@RequestBody PagingReqDTO<ExamDTO> reqDTO) {
|
||||
|
||||
//分页查询并转换
|
||||
IPage<ExamOnlineRespDTO> page = baseService.onlinePaging(reqDTO);
|
||||
return super.success(page);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 分页查找
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
@RequiresRoles("sa")
|
||||
@ApiOperation(value = "分页查找")
|
||||
@RequestMapping(value = "/paging", method = { RequestMethod.POST})
|
||||
public ApiRest<IPage<ExamDTO>> paging(@RequestBody PagingReqDTO<ExamDTO> reqDTO) {
|
||||
|
||||
//分页查询并转换
|
||||
IPage<ExamDTO> page = baseService.paging(reqDTO);
|
||||
|
||||
return super.success(page);
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 分页查找
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
@RequiresRoles("sa")
|
||||
@ApiOperation(value = "待阅试卷")
|
||||
@RequestMapping(value = "/review-paging", method = { RequestMethod.POST})
|
||||
public ApiRest<IPage<ExamReviewRespDTO>> reviewPaging(@RequestBody PagingReqDTO<ExamDTO> reqDTO) {
|
||||
//分页查询并转换
|
||||
IPage<ExamReviewRespDTO> page = baseService.reviewPaging(reqDTO);
|
||||
return super.success(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
package com.yf.exam.modules.exam.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.yf.exam.modules.paper.enums.ExamState;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试数据传输类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
@Data
|
||||
@ApiModel(value="考试", description="考试")
|
||||
public class ExamDTO implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "ID", required=true)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "考试名称", required=true)
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "考试描述", required=true)
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "1公开2部门3定员", required=true)
|
||||
private Integer openType;
|
||||
|
||||
@ApiModelProperty(value = "考试状态", required=true)
|
||||
private Integer state;
|
||||
|
||||
@ApiModelProperty(value = "是否限时", required=true)
|
||||
private Boolean timeLimit;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "开始时间", required=true)
|
||||
private Date startTime;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "结束时间", required=true)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required=true)
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间", required=true)
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty(value = "总分数", required=true)
|
||||
private Integer totalScore;
|
||||
|
||||
@ApiModelProperty(value = "总时长(分钟)", required=true)
|
||||
private Integer totalTime;
|
||||
|
||||
@ApiModelProperty(value = "及格分数", required=true)
|
||||
private Integer qualifyScore;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 是否结束
|
||||
* @return
|
||||
*/
|
||||
public Integer getState(){
|
||||
|
||||
if(this.timeLimit!=null && this.timeLimit){
|
||||
|
||||
if(System.currentTimeMillis() < startTime.getTime() ){
|
||||
return ExamState.READY_START;
|
||||
}
|
||||
|
||||
if(System.currentTimeMillis() > endTime.getTime()){
|
||||
return ExamState.OVERDUE;
|
||||
}
|
||||
|
||||
if(System.currentTimeMillis() > startTime.getTime()
|
||||
&& System.currentTimeMillis() < endTime.getTime()
|
||||
&& !ExamState.DISABLED.equals(this.state)){
|
||||
return ExamState.ENABLE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this.state;
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
package com.yf.exam.modules.exam.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试部门数据传输类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-03 17:24
|
||||
//*/
|
||||
@Data
|
||||
@ApiModel(value="考试部门", description="考试部门")
|
||||
public class ExamDepartDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "ID", required=true)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "考试ID", required=true)
|
||||
private String examId;
|
||||
|
||||
@ApiModelProperty(value = "部门ID", required=true)
|
||||
private String departId;
|
||||
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.yf.exam.modules.exam.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试题库数据传输类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-05 11:14
|
||||
//*/
|
||||
@Data
|
||||
@ApiModel(value="考试题库", description="考试题库")
|
||||
public class ExamRepoDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "ID", required=true)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "考试ID", required=true)
|
||||
private String examId;
|
||||
|
||||
@ApiModelProperty(value = "题库ID", required=true)
|
||||
private String repoId;
|
||||
|
||||
@ApiModelProperty(value = "单选题数量", required=true)
|
||||
private Integer radioCount;
|
||||
|
||||
@ApiModelProperty(value = "单选题分数", required=true)
|
||||
private Integer radioScore;
|
||||
|
||||
@ApiModelProperty(value = "多选题数量", required=true)
|
||||
private Integer multiCount;
|
||||
|
||||
@ApiModelProperty(value = "多选题分数", required=true)
|
||||
private Integer multiScore;
|
||||
|
||||
@ApiModelProperty(value = "判断题数量", required=true)
|
||||
private Integer judgeCount;
|
||||
|
||||
@ApiModelProperty(value = "判断题分数", required=true)
|
||||
private Integer judgeScore;
|
||||
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.yf.exam.modules.exam.dto.ext;
|
||||
|
||||
import com.yf.exam.modules.exam.dto.ExamRepoDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试题库数据传输类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-05 11:14
|
||||
//*/
|
||||
@Data
|
||||
@ApiModel(value="考试题库扩展响应类", description="考试题库扩展响应类")
|
||||
public class ExamRepoExtDTO extends ExamRepoDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "单选题总量", required=true)
|
||||
private Integer totalRadio;
|
||||
|
||||
@ApiModelProperty(value = "多选题总量", required=true)
|
||||
private Integer totalMulti;
|
||||
|
||||
@ApiModelProperty(value = "判断题总量", required=true)
|
||||
private Integer totalJudge;
|
||||
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.yf.exam.modules.exam.dto.request;
|
||||
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.ext.ExamRepoExtDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试保存请求类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
@Data
|
||||
@ApiModel(value="考试保存请求类", description="考试保存请求类")
|
||||
public class ExamSaveReqDTO extends ExamDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "题库列表", required=true)
|
||||
private List<ExamRepoExtDTO> repoList;
|
||||
|
||||
@ApiModelProperty(value = "考试部门列表", required=true)
|
||||
private List<String> departIds;
|
||||
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
package com.yf.exam.modules.exam.dto.response;
|
||||
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
//* <p>
|
||||
//* 考试分页响应类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
@Data
|
||||
@ApiModel(value="在线考试分页响应类", description="在线考试分页响应类")
|
||||
public class ExamOnlineRespDTO extends ExamDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
package com.yf.exam.modules.exam.dto.response;
|
||||
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试分页响应类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
@Data
|
||||
@ApiModel(value="阅卷分页响应类", description="阅卷分页响应类")
|
||||
public class ExamReviewRespDTO extends ExamDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "考试人数", required=true)
|
||||
private Integer examUser;
|
||||
|
||||
@ApiModelProperty(value = "待阅试卷", required=true)
|
||||
private Integer unreadPaper;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,100 +0,0 @@
|
||||
package com.yf.exam.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 com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试实体类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
@Data
|
||||
@TableName("el_exam")
|
||||
public class Exam extends Model<Exam> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// /**
|
||||
// * ID
|
||||
// */
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
// /**
|
||||
// * 考试名称
|
||||
// */
|
||||
private String title;
|
||||
|
||||
// /**
|
||||
// * 考试描述
|
||||
// */
|
||||
private String content;
|
||||
|
||||
// /**
|
||||
// * 1公开2部门3定员
|
||||
// */
|
||||
@TableField("open_type")
|
||||
private Integer openType;
|
||||
|
||||
// /**
|
||||
// * 考试状态
|
||||
// */
|
||||
private Integer state;
|
||||
|
||||
// /**
|
||||
// * 是否限时
|
||||
// */
|
||||
@TableField("time_limit")
|
||||
private Boolean timeLimit;
|
||||
|
||||
// /**
|
||||
// * 开始时间
|
||||
// */
|
||||
@TableField("start_time")
|
||||
private Date startTime;
|
||||
|
||||
// /**
|
||||
// * 结束时间
|
||||
// */
|
||||
@TableField("end_time")
|
||||
private Date endTime;
|
||||
|
||||
// /**
|
||||
// * 创建时间
|
||||
// */
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
// /**
|
||||
// * 更新时间
|
||||
// */
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
// /**
|
||||
// * 总分数
|
||||
// */
|
||||
@TableField("total_score")
|
||||
private Integer totalScore;
|
||||
|
||||
// /**
|
||||
// * 总时长(分钟)
|
||||
// */
|
||||
@TableField("total_time")
|
||||
private Integer totalTime;
|
||||
|
||||
// /**
|
||||
// * 及格分数
|
||||
// */
|
||||
@TableField("qualify_score")
|
||||
private Integer qualifyScore;
|
||||
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
package com.yf.exam.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 com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试部门实体类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-03 17:24
|
||||
//*/
|
||||
@Data
|
||||
@TableName("el_exam_depart")
|
||||
public class ExamDepart extends Model<ExamDepart> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// /**
|
||||
// * ID
|
||||
// */
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
// /**
|
||||
// * 考试ID
|
||||
// */
|
||||
@TableField("exam_id")
|
||||
private String examId;
|
||||
|
||||
// /**
|
||||
// * 部门ID
|
||||
// */
|
||||
@TableField("depart_id")
|
||||
private String departId;
|
||||
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
package com.yf.exam.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 com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试题库实体类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-05 11:14
|
||||
//*/
|
||||
@Data
|
||||
@TableName("el_exam_repo")
|
||||
public class ExamRepo extends Model<ExamRepo> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// /**
|
||||
// * ID
|
||||
// */
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
// /**
|
||||
// * 考试ID
|
||||
// */
|
||||
@TableField("exam_id")
|
||||
private String examId;
|
||||
|
||||
// /**
|
||||
// * 题库ID
|
||||
// */
|
||||
@TableField("repo_id")
|
||||
private String repoId;
|
||||
|
||||
// /**
|
||||
// * 单选题数量
|
||||
// */
|
||||
@TableField("radio_count")
|
||||
private Integer radioCount;
|
||||
|
||||
// /**
|
||||
// * 单选题分数
|
||||
// */
|
||||
@TableField("radio_score")
|
||||
private Integer radioScore;
|
||||
|
||||
// /**
|
||||
// * 多选题数量
|
||||
// */
|
||||
@TableField("multi_count")
|
||||
private Integer multiCount;
|
||||
|
||||
// /**
|
||||
// * 多选题分数
|
||||
// */
|
||||
@TableField("multi_score")
|
||||
private Integer multiScore;
|
||||
|
||||
// /**
|
||||
// * 判断题数量
|
||||
// */
|
||||
@TableField("judge_count")
|
||||
private Integer judgeCount;
|
||||
|
||||
// /**
|
||||
// * 判断题分数
|
||||
// */
|
||||
@TableField("judge_score")
|
||||
private Integer judgeScore;
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package com.yf.exam.modules.exam.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yf.exam.modules.exam.entity.ExamDepart;
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试部门Mapper
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-03 17:24
|
||||
//*/
|
||||
public interface ExamDepartMapper extends BaseMapper<ExamDepart> {
|
||||
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
package com.yf.exam.modules.exam.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamReviewRespDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamOnlineRespDTO;
|
||||
import com.yf.exam.modules.exam.entity.Exam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试Mapper
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
public interface ExamMapper extends BaseMapper<Exam> {
|
||||
|
||||
// /**
|
||||
// * 查找分页内容
|
||||
// * @param page
|
||||
// * @param query
|
||||
// * @return
|
||||
// */
|
||||
IPage<ExamDTO> paging(Page page, @Param("query") ExamDTO query);
|
||||
|
||||
// /**
|
||||
// * 查找分页内容
|
||||
// * @param page
|
||||
// * @param query
|
||||
// * @return
|
||||
// */
|
||||
IPage<ExamReviewRespDTO> reviewPaging(Page page, @Param("query") ExamDTO query);
|
||||
|
||||
// /**
|
||||
// * 在线考试分页响应类-考生视角
|
||||
// * @param page
|
||||
// * @param query
|
||||
// * @return
|
||||
// */
|
||||
IPage<ExamOnlineRespDTO> online(Page page, @Param("query") ExamDTO query);
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
package com.yf.exam.modules.exam.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yf.exam.modules.exam.dto.ext.ExamRepoExtDTO;
|
||||
import com.yf.exam.modules.exam.entity.ExamRepo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试题库Mapper
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-05 11:14
|
||||
//*/
|
||||
public interface ExamRepoMapper extends BaseMapper<ExamRepo> {
|
||||
|
||||
// /**
|
||||
// * 查找考试题库列表
|
||||
// * @param examId
|
||||
// * @return
|
||||
// */
|
||||
List<ExamRepoExtDTO> listByExam(@Param("examId") String examId);
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.yf.exam.modules.exam.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yf.exam.modules.exam.entity.ExamDepart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试部门业务类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-03 17:24
|
||||
//*/
|
||||
public interface ExamDepartService extends IService<ExamDepart> {
|
||||
|
||||
// /**
|
||||
// * 保存全部
|
||||
// * @param examId
|
||||
// * @param departs
|
||||
// */
|
||||
void saveAll(String examId, List<String> departs);
|
||||
|
||||
|
||||
// /**
|
||||
// * 根据考试查找对应的部门
|
||||
// * @param examId
|
||||
// * @return
|
||||
// */
|
||||
List<String> listByExam(String examId);
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
package com.yf.exam.modules.exam.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yf.exam.modules.exam.dto.ext.ExamRepoExtDTO;
|
||||
import com.yf.exam.modules.exam.entity.ExamRepo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试题库业务类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-05 11:14
|
||||
//*/
|
||||
public interface ExamRepoService extends IService<ExamRepo> {
|
||||
|
||||
|
||||
// /**
|
||||
// * 保存全部
|
||||
// * @param examId
|
||||
// * @param list
|
||||
// */
|
||||
void saveAll(String examId, List<ExamRepoExtDTO> list);
|
||||
//
|
||||
// /**
|
||||
// * 查找考试题库列表
|
||||
// * @param examId
|
||||
// * @return
|
||||
// */
|
||||
List<ExamRepoExtDTO> listByExam(String examId);
|
||||
|
||||
// /**
|
||||
// * 清理脏数据
|
||||
// * @param examId
|
||||
// */
|
||||
void clear(String examId);
|
||||
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
package com.yf.exam.modules.exam.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yf.exam.core.api.dto.PagingReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSaveReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamOnlineRespDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamReviewRespDTO;
|
||||
import com.yf.exam.modules.exam.entity.Exam;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试业务类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
public interface ExamService extends IService<Exam> {
|
||||
|
||||
// /**
|
||||
// * 保存考试信息
|
||||
// * @param reqDTO
|
||||
// */
|
||||
void save(ExamSaveReqDTO reqDTO);
|
||||
|
||||
// /**
|
||||
// * 查找考试详情
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
ExamSaveReqDTO findDetail(String id);
|
||||
|
||||
// /**
|
||||
// * 查找考试详情--简要信息
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
ExamDTO findById(String id);
|
||||
|
||||
// /**
|
||||
// * 分页查询数据
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
IPage<ExamDTO> paging(PagingReqDTO<ExamDTO> reqDTO);
|
||||
|
||||
|
||||
// /**
|
||||
// * 在线考试分页响应类-考生视角
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
IPage<ExamOnlineRespDTO> onlinePaging(PagingReqDTO<ExamDTO> reqDTO);
|
||||
|
||||
|
||||
// * 待阅试卷列表
|
||||
// * @param reqDTO
|
||||
// * @return
|
||||
// */
|
||||
IPage<ExamReviewRespDTO> reviewPaging(PagingReqDTO<ExamDTO> reqDTO);
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
package com.yf.exam.modules.exam.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yf.exam.core.exception.ServiceException;
|
||||
import com.yf.exam.modules.exam.entity.ExamDepart;
|
||||
import com.yf.exam.modules.exam.mapper.ExamDepartMapper;
|
||||
import com.yf.exam.modules.exam.service.ExamDepartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试部门业务实现类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-03 17:24
|
||||
//*/
|
||||
@Service
|
||||
public class ExamDepartServiceImpl extends ServiceImpl<ExamDepartMapper, ExamDepart> implements ExamDepartService {
|
||||
|
||||
@Override
|
||||
public void saveAll(String examId, List<String> departs) {
|
||||
|
||||
// 先删除
|
||||
QueryWrapper<ExamDepart> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(ExamDepart::getExamId, examId);
|
||||
this.remove(wrapper);
|
||||
|
||||
// 再增加
|
||||
if(CollectionUtils.isEmpty(departs)){
|
||||
throw new ServiceException(1, "请至少选择选择一个部门!!");
|
||||
}
|
||||
List<ExamDepart> list = new ArrayList<>();
|
||||
|
||||
for(String id: departs){
|
||||
ExamDepart depart = new ExamDepart();
|
||||
depart.setDepartId(id);
|
||||
depart.setExamId(examId);
|
||||
list.add(depart);
|
||||
}
|
||||
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listByExam(String examId) {
|
||||
// 先删除
|
||||
QueryWrapper<ExamDepart> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(ExamDepart::getExamId, examId);
|
||||
List<ExamDepart> list = this.list(wrapper);
|
||||
List<String> ids = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
for(ExamDepart item: list){
|
||||
ids.add(item.getDepartId());
|
||||
}
|
||||
}
|
||||
|
||||
return ids;
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
package com.yf.exam.modules.exam.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yf.exam.core.exception.ServiceException;
|
||||
import com.yf.exam.core.utils.BeanMapper;
|
||||
import com.yf.exam.modules.exam.dto.ext.ExamRepoExtDTO;
|
||||
import com.yf.exam.modules.exam.entity.ExamRepo;
|
||||
import com.yf.exam.modules.exam.mapper.ExamRepoMapper;
|
||||
import com.yf.exam.modules.exam.service.ExamRepoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试题库业务实现类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-09-05 11:14
|
||||
//*/
|
||||
@Service
|
||||
public class ExamRepoServiceImpl extends ServiceImpl<ExamRepoMapper, ExamRepo> implements ExamRepoService {
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void saveAll(String examId, List<ExamRepoExtDTO> list) {
|
||||
|
||||
// 先删除
|
||||
QueryWrapper<ExamRepo> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(ExamRepo::getExamId, examId);
|
||||
this.remove(wrapper);
|
||||
|
||||
// 再增加
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
throw new ServiceException(1, "必须选择题库!");
|
||||
}
|
||||
List<ExamRepo> repos = BeanMapper.mapList(list, ExamRepo.class);
|
||||
for(ExamRepo item: repos){
|
||||
item.setExamId(examId);
|
||||
item.setId(IdWorker.getIdStr());
|
||||
}
|
||||
|
||||
this.saveBatch(repos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExamRepoExtDTO> listByExam(String examId) {
|
||||
return baseMapper.listByExam(examId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(String examId) {
|
||||
|
||||
// 先删除
|
||||
QueryWrapper<ExamRepo> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(ExamRepo::getExamId, examId);
|
||||
this.remove(wrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,194 +0,0 @@
|
||||
package com.yf.exam.modules.exam.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yf.exam.core.api.dto.PagingReqDTO;
|
||||
import com.yf.exam.core.enums.OpenType;
|
||||
import com.yf.exam.core.exception.ServiceException;
|
||||
import com.yf.exam.core.utils.BeanMapper;
|
||||
import com.yf.exam.modules.exam.dto.ExamDTO;
|
||||
import com.yf.exam.modules.exam.dto.ExamRepoDTO;
|
||||
import com.yf.exam.modules.exam.dto.ext.ExamRepoExtDTO;
|
||||
import com.yf.exam.modules.exam.dto.request.ExamSaveReqDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamOnlineRespDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamReviewRespDTO;
|
||||
import com.yf.exam.modules.exam.entity.Exam;
|
||||
import com.yf.exam.modules.exam.mapper.ExamMapper;
|
||||
import com.yf.exam.modules.exam.service.ExamDepartService;
|
||||
import com.yf.exam.modules.exam.service.ExamRepoService;
|
||||
import com.yf.exam.modules.exam.service.ExamService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
///**
|
||||
//* <p>
|
||||
//* 考试业务实现类
|
||||
//* </p>
|
||||
//*
|
||||
//* @author 聪明笨狗
|
||||
//* @since 2020-07-25 16:18
|
||||
//*/
|
||||
@Service
|
||||
public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements ExamService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ExamRepoService examRepoService;
|
||||
|
||||
@Autowired
|
||||
private ExamDepartService examDepartService;
|
||||
|
||||
@Override
|
||||
public void save(ExamSaveReqDTO reqDTO) {
|
||||
|
||||
// ID
|
||||
String id = reqDTO.getId();
|
||||
|
||||
if(StringUtils.isBlank(id)){
|
||||
id = IdWorker.getIdStr();
|
||||
}
|
||||
|
||||
//复制参数
|
||||
Exam entity = new Exam();
|
||||
|
||||
// 计算分值
|
||||
this.calcScore(reqDTO);
|
||||
|
||||
|
||||
// 复制基本数据
|
||||
BeanMapper.copy(reqDTO, entity);
|
||||
entity.setId(id);
|
||||
|
||||
// 修复状态
|
||||
if (reqDTO.getTimeLimit()!=null
|
||||
&& !reqDTO.getTimeLimit()
|
||||
&& reqDTO.getState()!=null
|
||||
&& reqDTO.getState() == 2) {
|
||||
entity.setState(0);
|
||||
} else {
|
||||
entity.setState(reqDTO.getState());
|
||||
}
|
||||
|
||||
// 题库组卷
|
||||
try {
|
||||
examRepoService.saveAll(id, reqDTO.getRepoList());
|
||||
}catch (DuplicateKeyException e){
|
||||
throw new ServiceException(1, "不能选择重复的题库!");
|
||||
}
|
||||
|
||||
|
||||
// 开放的部门
|
||||
if(OpenType.DEPT_OPEN.equals(reqDTO.getOpenType())){
|
||||
examDepartService.saveAll(id, reqDTO.getDepartIds());
|
||||
}
|
||||
|
||||
this.saveOrUpdate(entity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExamSaveReqDTO findDetail(String id) {
|
||||
ExamSaveReqDTO respDTO = new ExamSaveReqDTO();
|
||||
Exam exam = this.getById(id);
|
||||
BeanMapper.copy(exam, respDTO);
|
||||
|
||||
// 考试部门
|
||||
List<String> departIds = examDepartService.listByExam(id);
|
||||
respDTO.setDepartIds(departIds);
|
||||
|
||||
// 题库
|
||||
List<ExamRepoExtDTO> repos = examRepoService.listByExam(id);
|
||||
respDTO.setRepoList(repos);
|
||||
|
||||
return respDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExamDTO findById(String id) {
|
||||
ExamDTO respDTO = new ExamDTO();
|
||||
Exam exam = this.getById(id);
|
||||
BeanMapper.copy(exam, respDTO);
|
||||
return respDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ExamDTO> paging(PagingReqDTO<ExamDTO> reqDTO) {
|
||||
|
||||
//创建分页对象
|
||||
Page page = new Page(reqDTO.getCurrent(), reqDTO.getSize());
|
||||
|
||||
//转换结果
|
||||
IPage<ExamDTO> pageData = baseMapper.paging(page, reqDTO.getParams());
|
||||
return pageData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ExamOnlineRespDTO> onlinePaging(PagingReqDTO<ExamDTO> reqDTO) {
|
||||
|
||||
|
||||
// 创建分页对象
|
||||
Page page = new Page(reqDTO.getCurrent(), reqDTO.getSize());
|
||||
|
||||
// 查找分页
|
||||
IPage<ExamOnlineRespDTO> pageData = baseMapper.online(page, reqDTO.getParams());
|
||||
|
||||
return pageData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ExamReviewRespDTO> reviewPaging(PagingReqDTO<ExamDTO> reqDTO) {
|
||||
// 创建分页对象
|
||||
Page page = new Page(reqDTO.getCurrent(), reqDTO.getSize());
|
||||
|
||||
// 查找分页
|
||||
IPage<ExamReviewRespDTO> pageData = baseMapper.reviewPaging(page, reqDTO.getParams());
|
||||
|
||||
return pageData;
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 计算分值
|
||||
// * @param reqDTO
|
||||
// */
|
||||
private void calcScore(ExamSaveReqDTO reqDTO){
|
||||
|
||||
// 主观题分数
|
||||
int objScore = 0;
|
||||
|
||||
// 题库组卷
|
||||
List<ExamRepoExtDTO> repoList = reqDTO.getRepoList();
|
||||
|
||||
for(ExamRepoDTO item: repoList){
|
||||
if(item.getRadioCount()!=null
|
||||
&& item.getRadioCount()>0
|
||||
&& item.getRadioScore()!=null
|
||||
&& item.getRadioScore()>0){
|
||||
objScore+=item.getRadioCount()*item.getRadioScore();
|
||||
}
|
||||
if(item.getMultiCount()!=null
|
||||
&& item.getMultiCount()>0
|
||||
&& item.getMultiScore()!=null
|
||||
&& item.getMultiScore()>0){
|
||||
objScore+=item.getMultiCount()*item.getMultiScore();
|
||||
}
|
||||
if(item.getJudgeCount()!=null
|
||||
&& item.getJudgeCount()>0
|
||||
&& item.getJudgeScore()!=null
|
||||
&& item.getJudgeScore()>0){
|
||||
objScore+=item.getJudgeCount()*item.getJudgeScore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
reqDTO.setTotalScore(objScore);
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue