mod doc
This commit is contained in:
@@ -2,20 +2,15 @@ package com.bc.exam;
|
||||
|
||||
import com.bc.exam.core.api.utils.JsonConverter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description 描述:
|
||||
* @Description 描述:springboot 系统启动
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@@ -24,24 +19,11 @@ import java.util.List;
|
||||
@EnableTransactionManagement
|
||||
public class ExamApplication implements WebMvcConfigurer {
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
ConfigurableApplicationContext application = SpringApplication.run(ExamApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
String path = env.getProperty("server.servlet.context-path");
|
||||
|
||||
// 未配置默认空白
|
||||
if(path == null){
|
||||
path = "";
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"系统启动成功,访问路径如下:\n\t" +
|
||||
"本地路径: \t\thttp://127.0.0.1:" + port + path + "/\n\t" +
|
||||
"网络地址: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
||||
"API文档: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"本地路径: \t\thttp://127.0.0.1:8101/\n\t"+
|
||||
"API文档: \t\thttp://127.0.0.1:8101/doc.html\n\t" +
|
||||
"----------------------------------------------------------");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 全局错误码定义,用于定义接口的响应数据,
|
||||
* 枚举名称全部使用代码命名,在系统中调用,免去取名难的问题。
|
||||
* @author chenhaodong
|
||||
* @date 2019-06-14 21:15
|
||||
* @Description 描述:全局错误码定义,用于定义接口的响应数据,枚举名称全部使用代码命名,在系统中调用,免去取名难的问题。
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -7,10 +7,11 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* 数据结果返回的封装
|
||||
* @author chenhaodong
|
||||
* @date 2018/11/20 09:48
|
||||
* @Description 描述:数据结果返回的封装
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
||||
@@ -8,9 +8,9 @@ import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用ID列表类操作,用于批量删除、修改状态等
|
||||
* @author chenhaodong
|
||||
* @date 2019-08-01 19:07
|
||||
* @Description 描述:通用ID列表类操作,用于批量删除、修改状态等
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="删除参数", description="删除参数")
|
||||
|
||||
@@ -8,13 +8,11 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用状态请求类,用于修改状态什么的
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2019-04-20 12:15
|
||||
* @Description 描述:通用状态请求类,用于修改状态什么的
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="通用状态请求类", description="通用状态请求类")
|
||||
|
||||
@@ -7,9 +7,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 分页查询类
|
||||
* @param <T>
|
||||
* @author chenhaodong
|
||||
* @Description 描述:分页查询类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@ApiModel(value="分页参数", description="分页参数")
|
||||
@Data
|
||||
|
||||
@@ -3,10 +3,9 @@ package com.bc.exam.core.api.dto;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
/**
|
||||
* 分页响应类
|
||||
* @author chenhaodong
|
||||
* @date 2019-07-20 15:17
|
||||
* @param <T>
|
||||
* @Description 描述:
|
||||
* @Author A贾宇婷034244310分页响应类
|
||||
* @Date 20260615
|
||||
*/
|
||||
public class PagingRespDTO<T> extends Page<T> {
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JSON数据转换器,用于转换返回消息的格式
|
||||
* @author chenhaodong
|
||||
* @date 2018/9/11 19:30
|
||||
* @Description 描述:JSON数据转换器,用于转换返回消息的格式
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public class JsonConverter {
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.bc.exam.core.enums;
|
||||
|
||||
|
||||
/**
|
||||
* 通用的状态枚举信息
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @date 2019-09-17 17:57
|
||||
* @Description 描述:通用的状态枚举信息
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface CommonState {
|
||||
|
||||
|
||||
@@ -6,6 +6,11 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Description 描述:服务自定义异常 继承运行时异常
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
@@ -7,9 +7,9 @@ import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 统一异常处理类
|
||||
* @author chenhaodong
|
||||
* @date 2019-06-21 19:27
|
||||
* @Description 描述:统一异常处理类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class ServiceExceptionHandler {
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.bc.exam.core.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
|
||||
/**
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-23 21:11
|
||||
*/
|
||||
public class CodeGenerator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// 1、创建代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 2、全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
String projectPath = System.getProperty("user.dir");
|
||||
gc.setOutputDir(projectPath + "/exam-api/src/main/java");
|
||||
gc.setAuthor("chenhaodong");
|
||||
gc.setOpen(false); //生成后是否打开资源管理器
|
||||
gc.setFileOverride(false); //重新生成时文件是否覆盖
|
||||
gc.setServiceName("%sService"); //去掉Service接口的首字母I
|
||||
gc.setIdType(IdType.ASSIGN_ID); //主键策略
|
||||
gc.setDateType(DateType.ONLY_DATE);//定义生成的实体类中日期类型
|
||||
gc.setSwagger2(false);//开启Swagger2模式
|
||||
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 3、数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl("jdbc:mysql://47.102.144.36:3306/chdbs?useSSL=false&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true");
|
||||
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||
dsc.setUsername("chdbs");
|
||||
dsc.setPassword("chdbs");
|
||||
dsc.setDbType(DbType.MYSQL);
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 4、包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
// 模块名 会在Parent目录下建立目录
|
||||
pc.setModuleName("tlog");
|
||||
pc.setParent("com.bc.exam.modules");
|
||||
pc.setController("controller");
|
||||
pc.setEntity("entity");
|
||||
pc.setService("service");
|
||||
pc.setMapper("mapper");
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 5、策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setInclude("t_log");//对那一张表生成代码
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
|
||||
strategy.setTablePrefix(pc.getModuleName() + "_"); //生成实体时去掉表前缀
|
||||
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);//数据库表字段映射到实体的命名策略
|
||||
strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
||||
|
||||
strategy.setRestControllerStyle(true); //restful api风格控制器
|
||||
strategy.setControllerMappingHyphenStyle(true); //url中驼峰转连字符
|
||||
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
// 6、执行
|
||||
mpg.execute();
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.bc.exam.core.utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
* 日期处理工具类
|
||||
* ClassName: DateUtils <br/>
|
||||
* date: 2018年12月13日 下午6:34:02 <br/>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @version
|
||||
*/
|
||||
public class DateUtils {
|
||||
|
||||
/**
|
||||
*
|
||||
* calcExpDays:计算某个日期与当前日期相差的天数,如果计算的日期大于现在时间,将返回负数;否则返回正数 <br/>
|
||||
* @author chenhaodong
|
||||
* @param userCreateTime
|
||||
* @return
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public static int calcExpDays(Date userCreateTime){
|
||||
|
||||
Calendar start = Calendar.getInstance();
|
||||
start.setTime(userCreateTime);
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
now.setTime(new Date());
|
||||
|
||||
long l = now.getTimeInMillis() - start.getTimeInMillis();
|
||||
int days = new Long(l / (1000 * 60 * 60 * 24)).intValue();
|
||||
return days;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* dateNow:获取当前时间的字符串格式,根据传入的格式化来展示. <br/>
|
||||
* @author chenhaodong
|
||||
* @param format 日期格式化
|
||||
* @return
|
||||
*/
|
||||
public static String dateNow(String format) {
|
||||
SimpleDateFormat fmt = new SimpleDateFormat(format);
|
||||
Calendar c = new GregorianCalendar();
|
||||
return fmt.format(c.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* formatDate:格式化日期,返回指定的格式 <br/>
|
||||
* @author chenhaodong
|
||||
* @param time
|
||||
* @param format
|
||||
* @return
|
||||
*/
|
||||
public static String formatDate(Date time, String format) {
|
||||
SimpleDateFormat fmt = new SimpleDateFormat(format);
|
||||
return fmt.format(time.getTime());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* parseDate:将字符串转换成日期,使用:yyyy-MM-dd HH:mm:ss 来格式化
|
||||
* @author chenhaodong
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date parseDate(String date) {
|
||||
return parseDate(date, "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* parseDate:将字符串转换成日期,使用指定格式化来格式化
|
||||
* @author chenhaodong
|
||||
* @param date
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
public static Date parseDate(String date, String pattern) {
|
||||
|
||||
if (pattern==null) {
|
||||
pattern = "yyyy-MM-dd HH:mm:ss";
|
||||
}
|
||||
|
||||
SimpleDateFormat fmt = new SimpleDateFormat(pattern);
|
||||
|
||||
try {
|
||||
return fmt.parse(date);
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.bc.exam.core.utils;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* IP获取工具类,用户获取网络请求过来的真实IP
|
||||
* ClassName: IpUtils <br/>
|
||||
* date: 2018年2月13日 下午7:27:52 <br/>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @version
|
||||
*/
|
||||
public class IpUtils {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* getClientIp:通过请求获取客户端的真实IP地址
|
||||
* @author chenhaodong
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String extractClientIp(HttpServletRequest request) {
|
||||
|
||||
String ip = null;
|
||||
|
||||
//X-Forwarded-For:Squid 服务代理
|
||||
String ipAddresses = request.getHeader("X-Forwarded-For");
|
||||
|
||||
if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
|
||||
//Proxy-Client-IP:apache 服务代理
|
||||
ipAddresses = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
|
||||
if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
|
||||
//WL-Proxy-Client-IP:weblogic 服务代理
|
||||
ipAddresses = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
|
||||
if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
|
||||
//HTTP_CLIENT_IP:有些代理服务器
|
||||
ipAddresses = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
|
||||
if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
|
||||
//X-Real-IP:nginx服务代理
|
||||
ipAddresses = request.getHeader("X-Real-IP");
|
||||
}
|
||||
|
||||
//有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP
|
||||
if (ipAddresses != null && ipAddresses.length() != 0) {
|
||||
ip = ipAddresses.split(",")[0];
|
||||
}
|
||||
|
||||
//还是不能获取到,最后再通过request.getRemoteAddr();获取
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
/**
|
||||
* Copyright (c) 2005-2012 springside.org.cn
|
||||
*/
|
||||
package com.bc.exam.core.utils;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@@ -18,11 +15,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 反射工具类.
|
||||
* 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数.
|
||||
* @author chenhaodong
|
||||
* @version 2016-01-15
|
||||
* @Description 描述:反射工具类.提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数.
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Log4j2
|
||||
public class Reflections {
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.bc.exam.core.utils;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Spring获取工具
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @date 2019-12-09 15:55
|
||||
*/
|
||||
@Component
|
||||
public class SpringUtils implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext context) throws BeansException {
|
||||
applicationContext = context;
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> tClass) {
|
||||
return applicationContext.getBean(tClass);
|
||||
}
|
||||
|
||||
public static <T> T getBean(String name, Class<T> type) {
|
||||
return applicationContext.getBean(name, type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.bc.exam.core.utils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 字符串常用工具类
|
||||
* @author chenhaodong
|
||||
* @date 2019-05-15 11:40
|
||||
* @Description 描述:字符串常用工具类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public class StringUtils {
|
||||
|
||||
@@ -19,21 +19,5 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将MAP转换成一个xml格式,格式为<xml><key>value</key>...</xml>
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String mapToXml(Map<String, String> params){
|
||||
StringBuffer sb = new StringBuffer("<xml>");
|
||||
for(String key:params.keySet()){
|
||||
sb.append("<")
|
||||
.append(key).append(">")
|
||||
.append(params.get(key))
|
||||
.append("</").append(key).append(">");
|
||||
}
|
||||
|
||||
sb.append("</xml>");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,402 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
|
||||
*/
|
||||
package com.bc.exam.core.utils.excel;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.bc.exam.core.utils.Reflections;
|
||||
import com.bc.exam.core.utils.excel.annotation.ExcelField;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Comment;
|
||||
import org.apache.poi.ss.usermodel.DataFormat;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导出Excel文件(导出“XLSX”格式,支持大数据量导出 @see org.apache.poi.ss.SpreadsheetVersion)
|
||||
* @author chenhaodong
|
||||
* @version 2016-04-21
|
||||
*/
|
||||
public class ExportExcel {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(ExportExcel.class);
|
||||
|
||||
/**
|
||||
* 工作薄对象
|
||||
*/
|
||||
private SXSSFWorkbook wb;
|
||||
|
||||
/**
|
||||
* 工作表对象
|
||||
*/
|
||||
private Sheet sheet;
|
||||
|
||||
/**
|
||||
* 样式列表
|
||||
*/
|
||||
private Map<String, CellStyle> styles;
|
||||
|
||||
/**
|
||||
* 当前行号
|
||||
*/
|
||||
private int rownum;
|
||||
|
||||
/**
|
||||
* 注解列表(Object[]{ ExcelField, Field/Method })
|
||||
*/
|
||||
List<Object[]> annotationList = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param title 表格标题,传“空值”,表示无标题
|
||||
* @param cls 实体对象,通过annotation.ExportField获取标题
|
||||
*/
|
||||
public ExportExcel(String title, Class<?> cls){
|
||||
this(title, cls, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param title 表格标题,传“空值”,表示无标题
|
||||
* @param cls 实体对象,通过annotation.ExportField获取标题
|
||||
* @param type 导出类型(1:导出数据;2:导出模板)
|
||||
* @param groups 导入分组
|
||||
*/
|
||||
public ExportExcel(String title, Class<?> cls, int type, int... groups){
|
||||
// Get annotation field
|
||||
Field[] fs = cls.getDeclaredFields();
|
||||
for (Field f : fs){
|
||||
ExcelField ef = f.getAnnotation(ExcelField.class);
|
||||
if (ef != null && (ef.type()==0 || ef.type()==type)){
|
||||
if (groups!=null && groups.length>0){
|
||||
boolean inGroup = false;
|
||||
for (int g : groups){
|
||||
if (inGroup){
|
||||
break;
|
||||
}
|
||||
for (int efg : ef.groups()){
|
||||
if (g == efg){
|
||||
inGroup = true;
|
||||
annotationList.add(new Object[]{ef, f});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
annotationList.add(new Object[]{ef, f});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get annotation method
|
||||
Method[] ms = cls.getDeclaredMethods();
|
||||
for (Method m : ms){
|
||||
ExcelField ef = m.getAnnotation(ExcelField.class);
|
||||
if (ef != null && (ef.type()==0 || ef.type()==type)){
|
||||
if (groups!=null && groups.length>0){
|
||||
boolean inGroup = false;
|
||||
for (int g : groups){
|
||||
if (inGroup){
|
||||
break;
|
||||
}
|
||||
for (int efg : ef.groups()){
|
||||
if (g == efg){
|
||||
inGroup = true;
|
||||
annotationList.add(new Object[]{ef, m});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
annotationList.add(new Object[]{ef, m});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Field sorting
|
||||
Collections.sort(annotationList, new Comparator<Object[]>() {
|
||||
@Override
|
||||
public int compare(Object[] o1, Object[] o2) {
|
||||
return new Integer(((ExcelField)o1[0]).sort()).compareTo(
|
||||
new Integer(((ExcelField)o2[0]).sort()));
|
||||
}
|
||||
});
|
||||
// Initialize
|
||||
List<String> headerList = Lists.newArrayList();
|
||||
for (Object[] os : annotationList){
|
||||
String t = ((ExcelField)os[0]).title();
|
||||
// 如果是导出,则去掉注释
|
||||
if (type==1){
|
||||
String[] ss = StringUtils.split(t, "**", 2);
|
||||
if (ss.length==2){
|
||||
t = ss[0];
|
||||
}
|
||||
}
|
||||
headerList.add(t);
|
||||
}
|
||||
initialize(title, headerList);
|
||||
}
|
||||
/**
|
||||
* 初始化函数
|
||||
* @param title 表格标题,传“空值”,表示无标题
|
||||
* @param headerList 表头列表
|
||||
*/
|
||||
private void initialize(String title, List<String> headerList) {
|
||||
this.wb = new SXSSFWorkbook(500);
|
||||
this.sheet = wb.createSheet("Export");
|
||||
this.styles = createStyles(wb);
|
||||
// Create title
|
||||
if (StringUtils.isNotBlank(title)){
|
||||
Row titleRow = sheet.createRow(rownum++);
|
||||
titleRow.setHeightInPoints(30);
|
||||
Cell titleCell = titleRow.createCell(0);
|
||||
titleCell.setCellStyle(styles.get("title"));
|
||||
titleCell.setCellValue(title);
|
||||
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
|
||||
titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-1));
|
||||
}
|
||||
// Create header
|
||||
if (headerList == null){
|
||||
throw new RuntimeException("headerList not null!");
|
||||
}
|
||||
Row headerRow = sheet.createRow(rownum++);
|
||||
headerRow.setHeightInPoints(16);
|
||||
for (int i = 0; i < headerList.size(); i++) {
|
||||
Cell cell = headerRow.createCell(i);
|
||||
cell.setCellStyle(styles.get("header"));
|
||||
String[] ss = StringUtils.split(headerList.get(i), "**", 2);
|
||||
if (ss.length==2){
|
||||
cell.setCellValue(ss[0]);
|
||||
Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
|
||||
new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
|
||||
comment.setString(new XSSFRichTextString(ss[1]));
|
||||
cell.setCellComment(comment);
|
||||
}else{
|
||||
cell.setCellValue(headerList.get(i));
|
||||
}
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
for (int i = 0; i < headerList.size(); i++) {
|
||||
int colWidth = sheet.getColumnWidth(i)*2;
|
||||
sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
|
||||
}
|
||||
log.debug("Initialize success.");
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建表格样式
|
||||
* @param wb 工作薄对象
|
||||
* @return 样式列表
|
||||
*/
|
||||
private Map<String, CellStyle> createStyles(Workbook wb) {
|
||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||
|
||||
CellStyle style = wb.createCellStyle();
|
||||
style.setAlignment(CellStyle.ALIGN_CENTER);
|
||||
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
|
||||
Font titleFont = wb.createFont();
|
||||
titleFont.setFontName("Arial");
|
||||
titleFont.setFontHeightInPoints((short) 16);
|
||||
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
||||
style.setFont(titleFont);
|
||||
styles.put("title", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
|
||||
style.setBorderRight(CellStyle.BORDER_THIN);
|
||||
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setBorderLeft(CellStyle.BORDER_THIN);
|
||||
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setBorderTop(CellStyle.BORDER_THIN);
|
||||
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setBorderBottom(CellStyle.BORDER_THIN);
|
||||
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
Font dataFont = wb.createFont();
|
||||
dataFont.setFontName("Arial");
|
||||
dataFont.setFontHeightInPoints((short) 10);
|
||||
style.setFont(dataFont);
|
||||
styles.put("data", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(styles.get("data"));
|
||||
style.setAlignment(CellStyle.ALIGN_LEFT);
|
||||
styles.put("data1", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(styles.get("data"));
|
||||
style.setAlignment(CellStyle.ALIGN_CENTER);
|
||||
styles.put("data2", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(styles.get("data"));
|
||||
style.setAlignment(CellStyle.ALIGN_RIGHT);
|
||||
styles.put("data3", style);
|
||||
|
||||
style = wb.createCellStyle();
|
||||
style.cloneStyleFrom(styles.get("data"));
|
||||
// style.setWrapText(true);
|
||||
style.setAlignment(CellStyle.ALIGN_CENTER);
|
||||
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
||||
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
||||
Font headerFont = wb.createFont();
|
||||
headerFont.setFontName("Arial");
|
||||
headerFont.setFontHeightInPoints((short) 10);
|
||||
headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
||||
headerFont.setColor(IndexedColors.WHITE.getIndex());
|
||||
style.setFont(headerFont);
|
||||
styles.put("header", style);
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一行
|
||||
* @return 行对象
|
||||
*/
|
||||
public Row addRow(){
|
||||
return sheet.createRow(rownum++);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加一个单元格
|
||||
* @param row 添加的行
|
||||
* @param column 添加列号
|
||||
* @param val 添加值
|
||||
* @return 单元格对象
|
||||
*/
|
||||
public Cell addCell(Row row, int column, Object val){
|
||||
return this.addCell(row, column, val, 0, Class.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个单元格
|
||||
* @param row 添加的行
|
||||
* @param column 添加列号
|
||||
* @param val 添加值
|
||||
* @param align 对齐方式(1:靠左;2:居中;3:靠右)
|
||||
* @return 单元格对象
|
||||
*/
|
||||
public Cell addCell(Row row, int column, Object val, int align, Class<?> fieldType){
|
||||
Cell cell = row.createCell(column);
|
||||
CellStyle style = styles.get("data"+(align>=1&&align<=3?align:""));
|
||||
try {
|
||||
if (val == null){
|
||||
cell.setCellValue("");
|
||||
} else if (val instanceof String) {
|
||||
cell.setCellValue((String) val);
|
||||
} else if (val instanceof Integer) {
|
||||
cell.setCellValue((Integer) val);
|
||||
} else if (val instanceof Long) {
|
||||
cell.setCellValue((Long) val);
|
||||
} else if (val instanceof Double) {
|
||||
cell.setCellValue((Double) val);
|
||||
} else if (val instanceof Float) {
|
||||
cell.setCellValue((Float) val);
|
||||
} else if (val instanceof Date) {
|
||||
DataFormat format = wb.createDataFormat();
|
||||
style.setDataFormat(format.getFormat("yyyy-MM-dd"));
|
||||
cell.setCellValue((Date) val);
|
||||
} else {
|
||||
if (fieldType != Class.class){
|
||||
cell.setCellValue((String)fieldType.getMethod("setValue", Object.class).invoke(null, val));
|
||||
}else{
|
||||
cell.setCellValue((String)Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
|
||||
"fieldtype."+val.getClass().getSimpleName()+"Type")).getMethod("setValue", Object.class).invoke(null, val));
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.info("Set cell value ["+row.getRowNum()+","+column+"] error: " + ex.toString());
|
||||
cell.setCellValue(val.toString());
|
||||
}
|
||||
cell.setCellStyle(style);
|
||||
return cell;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据(通过annotation.ExportField添加数据)
|
||||
* @return list 数据列表
|
||||
*/
|
||||
public <E> ExportExcel setDataList(List<E> list){
|
||||
for (E e : list){
|
||||
int colunm = 0;
|
||||
Row row = this.addRow();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Object[] os : annotationList){
|
||||
ExcelField ef = (ExcelField)os[0];
|
||||
Object val = null;
|
||||
try{
|
||||
if (StringUtils.isNotBlank(ef.value())){
|
||||
val = Reflections.invokeGetter(e, ef.value());
|
||||
}else{
|
||||
if (os[1] instanceof Field){
|
||||
val = Reflections.invokeGetter(e, ((Field)os[1]).getName());
|
||||
}else if (os[1] instanceof Method){
|
||||
val = Reflections.invokeMethod(e, ((Method)os[1]).getName(), new Class[] {}, new Object[] {});
|
||||
}
|
||||
}
|
||||
}catch(Exception ex) {
|
||||
log.info(ex.toString());
|
||||
val = "";
|
||||
}
|
||||
this.addCell(row, colunm++, val, ef.align(), ef.fieldType());
|
||||
sb.append(val + ", ");
|
||||
}
|
||||
log.debug("Write success: ["+row.getRowNum()+"] "+sb.toString());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出数据流
|
||||
* @param os 输出数据流
|
||||
*/
|
||||
public ExportExcel write(OutputStream os) throws IOException{
|
||||
wb.write(os);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出到客户端
|
||||
* @param fileName 输出文件名
|
||||
*/
|
||||
public ExportExcel write(HttpServletResponse response, String fileName) throws IOException{
|
||||
response.reset();
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setContentType("application/octet-stream; charset=utf-8");
|
||||
response.addHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(fileName, "utf-8"));
|
||||
write(response.getOutputStream());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理临时文件
|
||||
*/
|
||||
public ExportExcel dispose(){
|
||||
wb.dispose();
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,303 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
|
||||
*/
|
||||
package com.bc.exam.core.utils.excel;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.bc.exam.core.utils.Reflections;
|
||||
import com.bc.exam.core.utils.excel.annotation.ExcelField;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 导入Excel文件(支持“XLS”和“XLSX”格式)
|
||||
* @author chenhaodong
|
||||
* @version 2016-03-10
|
||||
*/
|
||||
public class ImportExcel {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(ImportExcel.class);
|
||||
|
||||
/**
|
||||
* 工作薄对象
|
||||
*/
|
||||
private Workbook wb;
|
||||
|
||||
/**
|
||||
* 工作表对象
|
||||
*/
|
||||
private Sheet sheet;
|
||||
|
||||
/**
|
||||
* 标题行号
|
||||
*/
|
||||
private int headerNum;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param multipartFile 导入文件对象
|
||||
* @param headerNum 标题行号,数据行号=标题行号+1
|
||||
* @param sheetIndex 工作表编号
|
||||
* @throws InvalidFormatException
|
||||
* @throws IOException
|
||||
*/
|
||||
public ImportExcel(MultipartFile multipartFile, int headerNum, int sheetIndex)
|
||||
throws InvalidFormatException, IOException {
|
||||
this(multipartFile.getOriginalFilename(), multipartFile.getInputStream(), headerNum, sheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param is 导入文件对象
|
||||
* @param headerNum 标题行号,数据行号=标题行号+1
|
||||
* @param sheetIndex 工作表编号
|
||||
* @throws InvalidFormatException
|
||||
* @throws IOException
|
||||
*/
|
||||
public ImportExcel(String fileName, InputStream is, int headerNum, int sheetIndex)
|
||||
throws IOException {
|
||||
if (StringUtils.isBlank(fileName)){
|
||||
throw new RuntimeException("导入文档为空!");
|
||||
}else if(fileName.toLowerCase().endsWith("xls")){
|
||||
this.wb = new HSSFWorkbook(is);
|
||||
}else if(fileName.toLowerCase().endsWith("xlsx")){
|
||||
this.wb = new XSSFWorkbook(is);
|
||||
}else{
|
||||
throw new RuntimeException("文档格式不正确!");
|
||||
}
|
||||
if (this.wb.getNumberOfSheets()<sheetIndex){
|
||||
throw new RuntimeException("文档中没有工作表!");
|
||||
}
|
||||
this.sheet = this.wb.getSheetAt(sheetIndex);
|
||||
this.headerNum = headerNum;
|
||||
log.debug("Initialize success.");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行对象
|
||||
* @param rownum
|
||||
* @return
|
||||
*/
|
||||
public Row getRow(int rownum){
|
||||
return this.sheet.getRow(rownum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据行号
|
||||
* @return
|
||||
*/
|
||||
public int getDataRowNum(){
|
||||
return headerNum+1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最后一个数据行号
|
||||
* @return
|
||||
*/
|
||||
public int getLastDataRowNum(){
|
||||
return this.sheet.getLastRowNum()+headerNum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取单元格值
|
||||
* @param row 获取的行
|
||||
* @param column 获取单元格列号
|
||||
* @return 单元格值
|
||||
*/
|
||||
public Object getCellValue(Row row, int column) {
|
||||
Object val = "";
|
||||
try {
|
||||
Cell cell = row.getCell(column);
|
||||
if (cell != null) {
|
||||
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
|
||||
// 当excel 中的数据为数值或日期是需要特殊处理
|
||||
if (HSSFDateUtil.isCellDateFormatted(cell)) {
|
||||
double d = cell.getNumericCellValue();
|
||||
Date date = HSSFDateUtil.getJavaDate(d);
|
||||
SimpleDateFormat dformat = new SimpleDateFormat(
|
||||
"yyyy-MM-dd");
|
||||
val = dformat.format(date);
|
||||
} else {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setGroupingUsed(false);// true时的格式:1,234,567,890
|
||||
val = nf.format(cell.getNumericCellValue());// 数值类型的数据为double,所以需要转换一下
|
||||
}
|
||||
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
|
||||
val = cell.getStringCellValue();
|
||||
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
|
||||
val = cell.getCellFormula();
|
||||
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
|
||||
val = cell.getBooleanCellValue();
|
||||
} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
|
||||
val = cell.getErrorCellValue();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入数据列表
|
||||
* @param cls 导入对象类型
|
||||
* @param groups 导入分组
|
||||
*/
|
||||
public <E> List<E> getDataList(Class<E> cls, int... groups) throws InstantiationException, IllegalAccessException{
|
||||
List<Object[]> annotationList = Lists.newArrayList();
|
||||
// Get annotation field
|
||||
Field[] fs = cls.getDeclaredFields();
|
||||
for (Field f : fs){
|
||||
ExcelField ef = f.getAnnotation(ExcelField.class);
|
||||
if (ef != null && (ef.type()==0 || ef.type()==2)){
|
||||
if (groups!=null && groups.length>0){
|
||||
boolean inGroup = false;
|
||||
for (int g : groups){
|
||||
if (inGroup){
|
||||
break;
|
||||
}
|
||||
for (int efg : ef.groups()){
|
||||
if (g == efg){
|
||||
inGroup = true;
|
||||
annotationList.add(new Object[]{ef, f});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
annotationList.add(new Object[]{ef, f});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get annotation method
|
||||
Method[] ms = cls.getDeclaredMethods();
|
||||
for (Method m : ms){
|
||||
ExcelField ef = m.getAnnotation(ExcelField.class);
|
||||
if (ef != null && (ef.type()==0 || ef.type()==2)){
|
||||
if (groups!=null && groups.length>0){
|
||||
boolean inGroup = false;
|
||||
for (int g : groups){
|
||||
if (inGroup){
|
||||
break;
|
||||
}
|
||||
for (int efg : ef.groups()){
|
||||
if (g == efg){
|
||||
inGroup = true;
|
||||
annotationList.add(new Object[]{ef, m});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
annotationList.add(new Object[]{ef, m});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Field sorting
|
||||
Collections.sort(annotationList, new Comparator<Object[]>() {
|
||||
@Override
|
||||
public int compare(Object[] o1, Object[] o2) {
|
||||
return new Integer(((ExcelField)o1[0]).sort()).compareTo(
|
||||
new Integer(((ExcelField)o2[0]).sort()));
|
||||
}
|
||||
});
|
||||
// Get excel data
|
||||
List<E> dataList = Lists.newArrayList();
|
||||
for (int i = this.getDataRowNum(); i < this.getLastDataRowNum(); i++) {
|
||||
E e = (E)cls.newInstance();
|
||||
int column = 0;
|
||||
Row row = this.getRow(i);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Object[] os : annotationList){
|
||||
Object val = this.getCellValue(row, column++);
|
||||
if (val != null){
|
||||
ExcelField ef = (ExcelField)os[0];
|
||||
// Get param type and type cast
|
||||
Class<?> valType = Class.class;
|
||||
if (os[1] instanceof Field){
|
||||
valType = ((Field)os[1]).getType();
|
||||
}else if (os[1] instanceof Method){
|
||||
Method method = ((Method)os[1]);
|
||||
if ("get".equals(method.getName().substring(0, 3))){
|
||||
valType = method.getReturnType();
|
||||
}else if("set".equals(method.getName().substring(0, 3))){
|
||||
valType = ((Method)os[1]).getParameterTypes()[0];
|
||||
}
|
||||
}
|
||||
//log.debug("Import value type: ["+i+","+column+"] " + valType);
|
||||
try {
|
||||
//如果导入的java对象,需要在这里自己进行变换。
|
||||
if (valType == String.class){
|
||||
String s = String.valueOf(val.toString());
|
||||
if(StringUtils.endsWith(s, ".0")){
|
||||
val = StringUtils.substringBefore(s, ".0");
|
||||
}else{
|
||||
val = String.valueOf(val.toString());
|
||||
}
|
||||
}else if (valType == Integer.class){
|
||||
val = Double.valueOf(val.toString()).intValue();
|
||||
}else if (valType == Long.class){
|
||||
val = Double.valueOf(val.toString()).longValue();
|
||||
}else if (valType == Double.class){
|
||||
val = Double.valueOf(val.toString());
|
||||
}else if (valType == Float.class){
|
||||
val = Float.valueOf(val.toString());
|
||||
}else if (valType == Date.class){
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
||||
val=sdf.parse(val.toString());
|
||||
}else{
|
||||
if (ef.fieldType() != Class.class){
|
||||
val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString());
|
||||
}else{
|
||||
val = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
|
||||
"fieldtype."+valType.getSimpleName()+"Type")).getMethod("getValue", String.class).invoke(null, val.toString());
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.info("Get cell value ["+i+","+column+"] error: " + ex.toString());
|
||||
val = null;
|
||||
}
|
||||
// set entity value
|
||||
if (os[1] instanceof Field){
|
||||
Reflections.invokeSetter(e, ((Field)os[1]).getName(), val);
|
||||
}else if (os[1] instanceof Method){
|
||||
String mthodName = ((Method)os[1]).getName();
|
||||
if ("get".equals(mthodName.substring(0, 3))){
|
||||
mthodName = "set"+StringUtils.substringAfter(mthodName, "get");
|
||||
}
|
||||
Reflections.invokeMethod(e, mthodName, new Class[] {valType}, new Object[] {val});
|
||||
}
|
||||
}
|
||||
sb.append(val+", ");
|
||||
}
|
||||
dataList.add(e);
|
||||
log.debug("Read success: ["+i+"] "+sb.toString());
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
|
||||
*/
|
||||
package com.bc.exam.core.utils.excel.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Excel注解定义
|
||||
* @author chenhaodong
|
||||
* @version 2016-03-10
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ExcelField {
|
||||
|
||||
/**
|
||||
* 导出字段名(默认调用当前字段的“get”方法,如指定导出字段为对象,请填写“对象名.对象属性”,例:“area.name”、“office.name”)
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* 导出字段标题(需要添加批注请用“**”分隔,标题**批注,仅对导出模板有效)
|
||||
*/
|
||||
String title();
|
||||
|
||||
/**
|
||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||
*/
|
||||
int type() default 0;
|
||||
|
||||
/**
|
||||
* 导出字段对齐方式(0:自动;1:靠左;2:居中;3:靠右)
|
||||
*/
|
||||
int align() default 0;
|
||||
|
||||
/**
|
||||
* 导出字段字段排序(升序)
|
||||
*/
|
||||
int sort() default 0;
|
||||
|
||||
/**
|
||||
* 如果是字典类型,请设置字典的type值
|
||||
*/
|
||||
String dictType() default "";
|
||||
|
||||
/**
|
||||
* 反射类型
|
||||
*/
|
||||
Class<?> fieldType() default Class.class;
|
||||
|
||||
/**
|
||||
* 字段归属组(根据分组导出导入)
|
||||
*/
|
||||
int[] groups() default {};
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
|
||||
*/
|
||||
package com.bc.exam.core.utils.excel.fieldtype;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.bc.exam.core.utils.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字段类型转换
|
||||
* @author chenhaodong
|
||||
* @version 2016-5-29
|
||||
*/
|
||||
public class ListType {
|
||||
|
||||
/**
|
||||
* 获取对象值(导入)
|
||||
*/
|
||||
public static Object getValue(String val) {
|
||||
List<String> list = Lists.newArrayList();
|
||||
if(!StringUtils.isBlank(val)) {
|
||||
for (String s : val.split(",")) {
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置对象值(导出)
|
||||
*/
|
||||
public static String setValue(Object val) {
|
||||
if (val != null){
|
||||
List<String> list = (List<String>)val;
|
||||
StringBuffer sb = null;
|
||||
for (String item: list){
|
||||
if(StringUtils.isBlank(item)){
|
||||
continue;
|
||||
}
|
||||
if(sb == null){
|
||||
sb = new StringBuffer(item);
|
||||
}else{
|
||||
sb.append(",").append(item);
|
||||
}
|
||||
}
|
||||
|
||||
if(sb!=null) {
|
||||
return sb.toString().replace("[]", "");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,13 +6,11 @@ import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* MD5工具类
|
||||
* ClassName: MD5Util <br/>
|
||||
* date: 2018年1月13日 下午6:54:53 <br/>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @version
|
||||
* @Description 描述:MD5工具类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public class MD5Util {
|
||||
|
||||
|
||||
@@ -4,19 +4,17 @@ package com.bc.exam.core.utils.passwd;
|
||||
import com.bc.exam.core.utils.file.MD5Util;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 通用的密码处理类,用于生成密码和校验密码
|
||||
* ClassName: PassGenerator <br/>
|
||||
* date: 2017年12月13日 下午7:13:03 <br/>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @version
|
||||
* @Description 描述:通用的密码处理类,用于生成密码和校验密码
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public class PassHandler {
|
||||
|
||||
/**
|
||||
* checkPass:校验密码是否一致
|
||||
* @author chenhaodong
|
||||
* @author A贾宇婷034244310
|
||||
* @param inputPass 用户传入的密码
|
||||
* @param salt 数据库保存的密码随机码
|
||||
* @param pass 数据库保存的密码MD5
|
||||
@@ -31,7 +29,7 @@ public class PassHandler {
|
||||
/**
|
||||
*
|
||||
* buildPassword:用于用户注册时产生一个密码
|
||||
* @author chenhaodong
|
||||
* @author A贾宇婷034244310
|
||||
* @param inputPass 输入的密码
|
||||
* @return PassInfo 返回一个密码对象,记得保存
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.bc.exam.core.utils.passwd;
|
||||
|
||||
/**
|
||||
* 密码实体
|
||||
* ClassName: PassInfo <br/>
|
||||
* date: 2018年2月13日 下午7:13:50 <br/>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @version
|
||||
* @Description 描述:密码实体
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public class PassInfo {
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.bc.exam.modules;
|
||||
|
||||
|
||||
/**
|
||||
* 通用常量
|
||||
* @author chd
|
||||
*/
|
||||
|
||||
public class Constant {
|
||||
|
||||
/**
|
||||
|
||||
+5
-8
@@ -16,14 +16,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用配置控制器
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-17 09:12
|
||||
*/
|
||||
@Api(tags={"通用配置"})
|
||||
* @Description 描述:通用配置控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Api(tags={"系统配置"})
|
||||
@RestController
|
||||
@RequestMapping("/exam/api/sys/config")
|
||||
public class SysConfigController extends BaseController {
|
||||
|
||||
@@ -6,16 +6,14 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用配置请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-17 09:12
|
||||
*/
|
||||
* @Description 描述:通用配置请求类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="通用配置", description="通用配置")
|
||||
@ApiModel(value="系统配置", description="系统配置")
|
||||
public class SysConfigDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -7,14 +7,12 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用配置实体类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-17 09:12
|
||||
*/
|
||||
* @Description 描述:系统配置实体类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_config")
|
||||
public class SysConfig extends Model<SysConfig> {
|
||||
|
||||
@@ -3,14 +3,12 @@ package com.bc.exam.modules.config.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bc.exam.modules.config.entity.SysConfig;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用配置Mapper
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-17 09:12
|
||||
*/
|
||||
* @Description 描述:系统配置Mapper
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysConfigMapper extends BaseMapper<SysConfig> {
|
||||
|
||||
}
|
||||
|
||||
@@ -4,14 +4,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bc.exam.modules.config.dto.SysConfigDTO;
|
||||
import com.bc.exam.modules.config.entity.SysConfig;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用配置业务类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-17 09:12
|
||||
*/
|
||||
* @Description 描述:系统配置接口
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysConfigService extends IService<SysConfig> {
|
||||
|
||||
/**
|
||||
|
||||
+5
-7
@@ -9,14 +9,12 @@ import com.bc.exam.modules.config.mapper.SysConfigMapper;
|
||||
import com.bc.exam.modules.config.service.SysConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 语言设置 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-17 09:12
|
||||
*/
|
||||
* @Description 描述:语言设置 服务实现类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
|
||||
|
||||
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
package com.bc.exam.modules.depart.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.bc.exam.core.api.ApiRest;
|
||||
import com.bc.exam.core.api.controller.BaseController;
|
||||
import com.bc.exam.core.api.dto.BaseIdReqDTO;
|
||||
import com.bc.exam.core.api.dto.BaseIdsReqDTO;
|
||||
import com.bc.exam.core.api.dto.PagingReqDTO;
|
||||
import com.bc.exam.core.utils.BeanMapper;
|
||||
import com.bc.exam.modules.depart.dto.SysDepartDTO;
|
||||
import com.bc.exam.modules.depart.dto.request.DepartSortReqDTO;
|
||||
import com.bc.exam.modules.depart.dto.response.SysDepartTreeDTO;
|
||||
import com.bc.exam.modules.depart.entity.SysDepart;
|
||||
import com.bc.exam.modules.depart.service.SysDepartService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门信息控制器
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-09-02 17:25
|
||||
*/
|
||||
@Api(tags={"部门信息"})
|
||||
@RestController
|
||||
@RequestMapping("/exam/api/sys/depart")
|
||||
public class SysDepartController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private SysDepartService baseService;
|
||||
|
||||
/**
|
||||
* 添加或修改
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加或修改")
|
||||
@PostMapping("save")
|
||||
public ApiRest save(@RequestBody SysDepartDTO reqDTO) {
|
||||
baseService.save(reqDTO);
|
||||
return super.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "批量删除")
|
||||
@PostMapping("delete")
|
||||
public ApiRest edit(@RequestBody BaseIdsReqDTO reqDTO) {
|
||||
//根据ID删除
|
||||
baseService.removeByIds(reqDTO.getIds());
|
||||
return super.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找详情
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查找详情")
|
||||
@PostMapping("detail")
|
||||
public ApiRest<SysDepartDTO> find(@RequestBody BaseIdReqDTO reqDTO) {
|
||||
SysDepart entity = baseService.getById(reqDTO.getId());
|
||||
SysDepartDTO dto = new SysDepartDTO();
|
||||
BeanUtils.copyProperties(entity, dto);
|
||||
return super.success(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查找
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页查找")
|
||||
@PostMapping("paging")
|
||||
public ApiRest<IPage<SysDepartTreeDTO>> paging(@RequestBody PagingReqDTO<SysDepartDTO> reqDTO) {
|
||||
//分页查询并转换
|
||||
IPage<SysDepartTreeDTO> page = baseService.paging(reqDTO);
|
||||
return super.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找列表,每次最多返回200条数据
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查找列表")
|
||||
@PostMapping("list")
|
||||
public ApiRest<List<SysDepartDTO>> list(@RequestBody SysDepartDTO reqDTO) {
|
||||
|
||||
//分页查询并转换
|
||||
QueryWrapper<SysDepart> wrapper = new QueryWrapper<>();
|
||||
|
||||
//转换并返回
|
||||
List<SysDepart> list = baseService.list(wrapper);
|
||||
|
||||
//转换数据
|
||||
List<SysDepartDTO> dtoList = BeanMapper.mapList(list, SysDepartDTO.class);
|
||||
|
||||
return super.success(dtoList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 树列表
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "树列表")
|
||||
@PostMapping("tree")
|
||||
public ApiRest<List<SysDepartTreeDTO>> tree() {
|
||||
List<SysDepartTreeDTO> dtoList = baseService.findTree();
|
||||
return super.success(dtoList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类排序
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分类排序")
|
||||
@PostMapping("sort")
|
||||
public ApiRest sort(@RequestBody DepartSortReqDTO reqDTO) {
|
||||
baseService.sort(reqDTO.getId(), reqDTO.getSort());
|
||||
return super.success();
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.bc.exam.modules.depart.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门信息数据传输类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-09-02 17:25
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="部门信息", description="部门信息")
|
||||
public class SysDepartDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "ID", required=true)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "1公司2部门", required=true)
|
||||
private Integer deptType;
|
||||
|
||||
@ApiModelProperty(value = "所属上级", required=true)
|
||||
private String parentId;
|
||||
|
||||
@ApiModelProperty(value = "部门名称", required=true)
|
||||
private String deptName;
|
||||
|
||||
@ApiModelProperty(value = "部门编码", required=true)
|
||||
private String deptCode;
|
||||
|
||||
@ApiModelProperty(value = "排序", required=true)
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.bc.exam.modules.depart.dto.request;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门排序请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-03-14 10:37
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="部门排序请求类", description="部门排序请求类")
|
||||
public class DepartSortReqDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "分类ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "排序,0下降,1上升")
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.bc.exam.modules.depart.dto.response;
|
||||
|
||||
import com.bc.exam.modules.depart.dto.SysDepartDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门树结构响应类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-09-02 17:25
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="部门树结构响应类", description="部门树结构响应类")
|
||||
public class SysDepartTreeDTO extends SysDepartDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "子列表", required=true)
|
||||
private List<SysDepartTreeDTO> children;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.bc.exam.modules.depart.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 chd
|
||||
* @since 2020-09-02 17:25
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart")
|
||||
public class SysDepart extends Model<SysDepart> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 1公司2部门
|
||||
*/
|
||||
@TableField("dept_type")
|
||||
private Integer deptType;
|
||||
|
||||
/**
|
||||
* 所属上级
|
||||
*/
|
||||
@TableField("parent_id")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@TableField("dept_name")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 部门编码
|
||||
*/
|
||||
@TableField("dept_code")
|
||||
private String deptCode;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.bc.exam.modules.depart.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.bc.exam.modules.depart.dto.SysDepartDTO;
|
||||
import com.bc.exam.modules.depart.dto.response.SysDepartTreeDTO;
|
||||
import com.bc.exam.modules.depart.entity.SysDepart;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门信息Mapper
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-09-02 17:25
|
||||
*/
|
||||
public interface SysDepartMapper extends BaseMapper<SysDepart> {
|
||||
|
||||
/**
|
||||
* 部门树分页
|
||||
* @param page
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
IPage<SysDepartTreeDTO> paging(Page page, @Param("query") SysDepartDTO query);
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.bc.exam.modules.depart.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bc.exam.core.api.dto.PagingReqDTO;
|
||||
import com.bc.exam.modules.depart.dto.SysDepartDTO;
|
||||
import com.bc.exam.modules.depart.dto.response.SysDepartTreeDTO;
|
||||
import com.bc.exam.modules.depart.entity.SysDepart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门信息业务类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-09-02 17:25
|
||||
*/
|
||||
public interface SysDepartService extends IService<SysDepart> {
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @param reqDTO
|
||||
*/
|
||||
void save(SysDepartDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 分页查询数据
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
IPage<SysDepartTreeDTO> paging(PagingReqDTO<SysDepartDTO> reqDTO);
|
||||
|
||||
/**
|
||||
* 查找部门树结构
|
||||
* @return
|
||||
*/
|
||||
List<SysDepartTreeDTO> findTree();
|
||||
|
||||
/**
|
||||
* 查找部门树
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<SysDepartTreeDTO> findTree(List<String> ids);
|
||||
|
||||
/**
|
||||
* 排序
|
||||
* @param id
|
||||
* @param sort
|
||||
*/
|
||||
void sort(String id, Integer sort);
|
||||
|
||||
|
||||
/**
|
||||
* 获取某个部门ID下的所有子部门ID
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<String> listAllSubIds( String id);
|
||||
}
|
||||
-277
@@ -1,277 +0,0 @@
|
||||
package com.bc.exam.modules.depart.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bc.exam.core.api.dto.PagingReqDTO;
|
||||
import com.bc.exam.core.utils.BeanMapper;
|
||||
import com.bc.exam.modules.depart.dto.SysDepartDTO;
|
||||
import com.bc.exam.modules.depart.dto.response.SysDepartTreeDTO;
|
||||
import com.bc.exam.modules.depart.entity.SysDepart;
|
||||
import com.bc.exam.modules.depart.mapper.SysDepartMapper;
|
||||
import com.bc.exam.modules.depart.service.SysDepartService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门信息业务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-09-02 17:25
|
||||
*/
|
||||
@Service
|
||||
public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart> implements SysDepartService {
|
||||
|
||||
|
||||
/**
|
||||
* 0标识为顶级分类
|
||||
*/
|
||||
private static final String ROOT_TAG = "0";
|
||||
|
||||
|
||||
@Override
|
||||
public void save(SysDepartDTO reqDTO) {
|
||||
|
||||
if(StringUtils.isBlank(reqDTO.getId())) {
|
||||
this.fillCode(reqDTO);
|
||||
}else{
|
||||
reqDTO.setSort(null);
|
||||
reqDTO.setDeptCode(null);
|
||||
}
|
||||
|
||||
SysDepart entity = new SysDepart();
|
||||
BeanMapper.copy(reqDTO, entity);
|
||||
this.saveOrUpdate(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysDepartTreeDTO> paging(PagingReqDTO<SysDepartDTO> reqDTO) {
|
||||
|
||||
// 创建分页对象
|
||||
Page query = new Page(reqDTO.getCurrent(), reqDTO.getSize());
|
||||
|
||||
// 请求参数
|
||||
SysDepartDTO params = reqDTO.getParams();
|
||||
|
||||
//转换结果
|
||||
IPage<SysDepartTreeDTO> pageData = baseMapper.paging(query, params);
|
||||
|
||||
return pageData;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysDepartTreeDTO> findTree() {
|
||||
return this.findTree(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDepartTreeDTO> findTree(List<String> ids) {
|
||||
QueryWrapper<SysDepart> wrapper = new QueryWrapper();
|
||||
wrapper.lambda().orderByAsc(SysDepart::getSort);
|
||||
if(!CollectionUtils.isEmpty(ids)){
|
||||
List<String> fullIds = new ArrayList<>();
|
||||
for(String id: ids){
|
||||
this.cycleAllParent(fullIds, id);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(fullIds)){
|
||||
wrapper.lambda().in(SysDepart::getId, fullIds);
|
||||
}
|
||||
}
|
||||
//全部列表
|
||||
List<SysDepart> list = this.list(wrapper);
|
||||
List<SysDepartTreeDTO> dtoList = BeanMapper.mapList(list, SysDepartTreeDTO.class);
|
||||
//子结构的列表
|
||||
Map<String,List<SysDepartTreeDTO>> map = new HashMap<>(16);
|
||||
for(SysDepartTreeDTO item: dtoList){
|
||||
//如果存在
|
||||
if(map.containsKey(item.getParentId())){
|
||||
map.get(item.getParentId()).add(item);
|
||||
continue;
|
||||
}
|
||||
//增加新的结构
|
||||
List<SysDepartTreeDTO> a = new ArrayList<>();
|
||||
a.add(item);
|
||||
map.put(item.getParentId(), a);
|
||||
}
|
||||
//注意,第0级为顶级的
|
||||
List<SysDepartTreeDTO> topList = map.get(ROOT_TAG);
|
||||
if(!CollectionUtils.isEmpty(topList)){
|
||||
for(SysDepartTreeDTO item: topList){
|
||||
this.fillChildren(map, item);
|
||||
}
|
||||
}
|
||||
|
||||
return topList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sort(String id, Integer sort) {
|
||||
|
||||
SysDepart depart = this.getById(id);
|
||||
SysDepart exchange = null;
|
||||
|
||||
QueryWrapper<SysDepart> wrapper = new QueryWrapper<>();
|
||||
// 同级排序
|
||||
wrapper.lambda()
|
||||
.eq(SysDepart::getParentId, depart.getParentId());
|
||||
wrapper.last("LIMIT 1");
|
||||
|
||||
// 上升
|
||||
if(sort == 0){
|
||||
// 同级排序
|
||||
wrapper.lambda()
|
||||
.lt(SysDepart::getSort, depart.getSort())
|
||||
.orderByDesc(SysDepart::getSort);
|
||||
exchange = this.getOne(wrapper, false);
|
||||
}
|
||||
|
||||
// 下降
|
||||
if(sort == 1){
|
||||
// 同级排序
|
||||
wrapper.lambda()
|
||||
.gt(SysDepart::getSort, depart.getSort())
|
||||
.orderByAsc(SysDepart::getSort);
|
||||
exchange = this.getOne(wrapper, false);
|
||||
}
|
||||
|
||||
|
||||
if(exchange!=null) {
|
||||
SysDepart a = new SysDepart();
|
||||
a.setId(id);
|
||||
a.setSort(exchange.getSort());
|
||||
SysDepart b = new SysDepart();
|
||||
b.setId(exchange.getId());
|
||||
b.setSort(depart.getSort());
|
||||
this.updateById(a);
|
||||
this.updateById(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门编号
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
private void fillCode(SysDepartDTO reqDTO){
|
||||
|
||||
// 前缀
|
||||
String code = "";
|
||||
|
||||
if(StringUtils.isNotBlank(reqDTO.getParentId())
|
||||
&& !ROOT_TAG.equals(reqDTO.getParentId())){
|
||||
SysDepart parent = this.getById(reqDTO.getParentId());
|
||||
code = parent.getDeptCode();
|
||||
}
|
||||
|
||||
QueryWrapper<SysDepart> wrapper = new QueryWrapper<>();
|
||||
|
||||
// 同级排序
|
||||
wrapper.lambda()
|
||||
.eq(SysDepart::getParentId, reqDTO.getParentId())
|
||||
.orderByDesc(SysDepart::getSort);
|
||||
wrapper.last("LIMIT 1");
|
||||
SysDepart depart = this.getOne(wrapper, false);
|
||||
|
||||
if(depart !=null){
|
||||
code += this.formatCode(depart.getSort()+1);
|
||||
reqDTO.setSort(depart.getSort()+1);
|
||||
}else{
|
||||
code += this.formatCode(1);
|
||||
reqDTO.setSort(1);
|
||||
}
|
||||
|
||||
reqDTO.setDeptCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根式化加0
|
||||
* @param sort
|
||||
* @return
|
||||
*/
|
||||
private String formatCode(Integer sort){
|
||||
if(sort < 10){
|
||||
return "A0"+sort;
|
||||
}
|
||||
return "A"+sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归去做填充数据
|
||||
* @param map
|
||||
* @param item
|
||||
*/
|
||||
private void fillChildren(Map<String,List<SysDepartTreeDTO>> map, SysDepartTreeDTO item){
|
||||
|
||||
//设置子类
|
||||
if(map.containsKey(item.getId())){
|
||||
|
||||
List<SysDepartTreeDTO> children = map.get(item.getId());
|
||||
if(!CollectionUtils.isEmpty(children)){
|
||||
for(SysDepartTreeDTO sub: children){
|
||||
this.fillChildren(map, sub);
|
||||
}
|
||||
}
|
||||
item.setChildren(children);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> listAllSubIds( String id){
|
||||
|
||||
List<String> ids = new ArrayList<>();
|
||||
this.cycleAllSubs(ids, id);
|
||||
return ids;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归所有子级别ID
|
||||
* @param list
|
||||
* @param id
|
||||
*/
|
||||
private void cycleAllSubs(List<String> list, String id){
|
||||
|
||||
// 添加ID
|
||||
list.add(id);
|
||||
|
||||
QueryWrapper<SysDepart> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda()
|
||||
.eq(SysDepart::getParentId, id)
|
||||
.orderByDesc(SysDepart::getSort);
|
||||
List<SysDepart> subList = this.list(wrapper);
|
||||
if(!CollectionUtils.isEmpty(subList)){
|
||||
for(SysDepart item: subList){
|
||||
this.cycleAllSubs(list, item.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归所有子级别ID
|
||||
* @param list
|
||||
* @param id
|
||||
*/
|
||||
private void cycleAllParent(List<String> list, String id){
|
||||
|
||||
// 往上递归获得父类
|
||||
list.add(id);
|
||||
SysDepart depart = this.getById(id);
|
||||
|
||||
if(StringUtils.isNotBlank(depart.getParentId())
|
||||
&& !ROOT_TAG.equals(depart.getParentId())){
|
||||
this.cycleAllParent(list, depart.getParentId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+4
-6
@@ -20,13 +20,11 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值数据表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:字典码值数据表 前端控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/api/dict/data")
|
||||
|
||||
+4
-6
@@ -22,13 +22,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值大类表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:字典 码值大类表 前端控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/api/dict/type")
|
||||
|
||||
@@ -11,13 +11,11 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值数据表
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:字典码值数据表
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -10,13 +10,11 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值大类表
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:字典码值大类表
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -9,13 +9,11 @@ import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值数据表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:码值数据表 Mapper 接口
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysDictDataMapper extends BaseMapper<SysDictData> {
|
||||
@Select("${sqlStr}")
|
||||
|
||||
@@ -3,13 +3,11 @@ package com.bc.exam.modules.dict.mapper;
|
||||
import com.bc.exam.modules.dict.entity.SysDictType;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值大类表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:码值大类表 Mapper 接口
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
|
||||
|
||||
|
||||
@@ -11,12 +11,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值数据表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:码值数据表 服务类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysDictDataService extends IService<SysDictData> {
|
||||
|
||||
|
||||
@@ -10,12 +10,9 @@ import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值大类表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:码值大类表 服务类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysDictTypeService extends IService<SysDictType> {
|
||||
/**
|
||||
|
||||
+3
-6
@@ -21,12 +21,9 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值数据表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:码值数据表 服务实现类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictData> implements SysDictDataService {
|
||||
|
||||
+3
-6
@@ -22,12 +22,9 @@ import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 码值大类表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2022-11-24
|
||||
* @Description 描述:码值大类表 服务实现类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {
|
||||
|
||||
+3
-4
@@ -17,10 +17,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 公告表 前端控制器
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:公告表 前端控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/gonggao/gggl")
|
||||
|
||||
@@ -7,12 +7,9 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告表
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:公告表
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -4,12 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bc.exam.modules.gonggao.entity.TGonggao;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:公告表 Mapper 接口
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TGonggaoMapper extends BaseMapper<TGonggao> {
|
||||
|
||||
|
||||
@@ -6,12 +6,9 @@ import com.bc.exam.core.api.dto.PagingReqDTO;
|
||||
import com.bc.exam.modules.gonggao.entity.TGonggao;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:公告表 服务类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TGonggaoService extends IService<TGonggao> {
|
||||
IPage<TGonggao> paging(PagingReqDTO<TGonggao> reqDTO);
|
||||
|
||||
+3
-6
@@ -14,12 +14,9 @@ import com.bc.exam.modules.gonggao.service.TGonggaoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公告表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:公告表 服务实现类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class TGonggaoServiceImpl extends ServiceImpl<TGonggaoMapper, TGonggao> implements TGonggaoService {
|
||||
|
||||
@@ -18,10 +18,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 留言信息表 前端控制器
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:留言信息表 前端控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/liuyan/lygl")
|
||||
|
||||
@@ -7,12 +7,9 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 留言信息表
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:留言信息表
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -4,12 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bc.exam.modules.liuyan.entity.TLiuyan;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 留言信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:留言信息表 Mapper 接口
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TLiuyanMapper extends BaseMapper<TLiuyan> {
|
||||
|
||||
|
||||
@@ -6,12 +6,9 @@ import com.bc.exam.core.api.dto.PagingReqDTO;
|
||||
import com.bc.exam.modules.liuyan.entity.TLiuyan;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 留言信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:留言信息表 服务类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TLiuyanService extends IService<TLiuyan> {
|
||||
|
||||
|
||||
+3
-6
@@ -14,12 +14,9 @@ import com.bc.exam.modules.liuyan.service.TLiuyanService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 留言信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:留言信息表 服务实现类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class TLiuyanServiceImpl extends ServiceImpl<TLiuyanMapper, TLiuyan> implements TLiuyanService {
|
||||
|
||||
+3
-4
@@ -14,10 +14,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 学生基础信息 前端控制器
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-26
|
||||
* @Description 描述:学生基础信息 前端控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/student/student")
|
||||
|
||||
@@ -10,12 +10,9 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 学生基础信息
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-26
|
||||
* @Description 描述:学生基础信息
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -8,12 +8,9 @@ import com.bc.exam.modules.student.entity.Student;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 学生基础信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-26
|
||||
* @Description 描述:学生基础信息 Mapper 接口
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface StudentMapper extends BaseMapper<Student> {
|
||||
IPage<Student> paging(Page<Student> page, @Param("ew") Wrapper<Student> wrapper);
|
||||
|
||||
@@ -7,12 +7,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 学生基础信息 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-26
|
||||
* @Description 描述:学生基础信息 服务类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface StudentService extends IService<Student> {
|
||||
|
||||
|
||||
+3
-6
@@ -13,12 +13,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 学生基础信息 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-26
|
||||
* @Description 描述:学生基础信息 服务实现类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {
|
||||
|
||||
@@ -4,13 +4,10 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 机主信息Mapper
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-08-22 13:46
|
||||
*/
|
||||
* @Description 描述:机主信息Mapper
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDictMapper {
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.bc.exam.modules.system.service;
|
||||
|
||||
/**
|
||||
* 数据字典工具类
|
||||
* @author bool
|
||||
*/
|
||||
public interface SysDictService {
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,9 +5,6 @@ import com.bc.exam.modules.system.service.SysDictService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author bool
|
||||
*/
|
||||
@Service
|
||||
public class SysDictServiceImpl implements SysDictService {
|
||||
|
||||
|
||||
@@ -25,10 +25,9 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 借还信息表前端控制器
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:借还信息表前端控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/tjhxxb/controller")
|
||||
|
||||
@@ -10,10 +10,9 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 借还信息表
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:借还信息表
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -7,13 +7,11 @@ import com.bc.exam.modules.tjhxxb.entity.TJhxxb;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:借还信息表mapper
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TJhxxbMapper extends BaseMapper<TJhxxb> {
|
||||
IPage<TJhxxb> paging(Page<TJhxxb> page, @Param("ew") Wrapper<TJhxxb> wrapper);
|
||||
|
||||
@@ -6,12 +6,9 @@ import com.bc.exam.modules.tjhxxb.entity.TJhxxb;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:借还信息表实现
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TJhxxbService extends IService<TJhxxb> {
|
||||
|
||||
|
||||
+3
-6
@@ -12,12 +12,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:借还信息表实现
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class TJhxxbServiceImpl extends ServiceImpl<TJhxxbMapper, TJhxxb> implements TJhxxbService {
|
||||
|
||||
@@ -17,10 +17,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 书籍借还日志记录前端控制器
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:书籍借还日志记录前端控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/tlog/logcontrol")
|
||||
|
||||
@@ -6,12 +6,9 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:借还日志
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -3,13 +3,11 @@ package com.bc.exam.modules.tlog.mapper;
|
||||
import com.bc.exam.modules.tlog.entity.TLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:借还日志接口
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TLogMapper extends BaseMapper<TLog> {
|
||||
|
||||
|
||||
@@ -6,12 +6,9 @@ import com.bc.exam.modules.tlog.entity.TLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:借还日志服务类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TLogService extends IService<TLog> {
|
||||
IPage<TLog> paging(PagingReqDTO<TLog> reqDTO);
|
||||
|
||||
@@ -12,12 +12,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-03-03
|
||||
* @Description 描述:借还日志服务
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class TLogServiceImpl extends ServiceImpl<TLogMapper, TLog> implements TLogService {
|
||||
|
||||
@@ -17,10 +17,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 书籍信息表前端控制器
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:书籍信息表前端控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/tsjxxb/controller")
|
||||
|
||||
@@ -10,10 +10,9 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 书籍信息表
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:书籍信息表
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@@ -4,12 +4,9 @@ import com.bc.exam.modules.tsjxxb.entity.TSjxxb;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:书籍信息表mapper
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TSjxxbMapper extends BaseMapper<TSjxxb> {
|
||||
|
||||
|
||||
@@ -6,12 +6,9 @@ import com.bc.exam.modules.tsjxxb.entity.TSjxxb;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:书籍信息表服务
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface TSjxxbService extends IService<TSjxxb> {
|
||||
|
||||
|
||||
+3
-6
@@ -12,12 +12,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2023-02-27
|
||||
* @Description 描述:书籍信息表服务实现类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Service
|
||||
public class TSjxxbServiceImpl extends ServiceImpl<TSjxxbMapper, TSjxxb> implements TSjxxbService {
|
||||
|
||||
@@ -6,8 +6,9 @@ import com.bc.exam.modules.user.dto.response.SysUserLoginDTO;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
|
||||
/**
|
||||
* 用户静态工具类
|
||||
* @author chd
|
||||
* @Description 描述:用户静态工具类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public class UserUtils {
|
||||
|
||||
@@ -28,32 +29,6 @@ public class UserUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的ID
|
||||
* @param throwable
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAdmin(boolean throwable){
|
||||
try {
|
||||
SysUserLoginDTO dto = ((SysUserLoginDTO) SecurityUtils.getSubject().getPrincipal());
|
||||
return dto.getRoles().contains("sa");
|
||||
}catch (Exception e){
|
||||
if(throwable){
|
||||
throw new ServiceException(ApiError.ERROR_10010002);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前用户不是admin, 默认不抛异常
|
||||
* @return true 不是admin, false 是admin
|
||||
*/
|
||||
public static boolean isNotAdmin(){
|
||||
return !isAdmin(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的ID,默认是会抛异常的
|
||||
* @return
|
||||
|
||||
@@ -20,12 +20,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理用户控制器
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-13 16:57
|
||||
* @Description 描述:用户角色
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Api(tags = {"管理用户"})
|
||||
@RestController
|
||||
|
||||
@@ -22,12 +22,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理用户控制器
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-13 16:57
|
||||
* @Description 描述:管理用户控制器
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Api(tags = {"管理用户"})
|
||||
@RestController
|
||||
|
||||
@@ -7,13 +7,10 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:角色类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="角色", description="角色")
|
||||
public class SysRoleDTO implements Serializable {
|
||||
|
||||
@@ -8,13 +8,10 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理用户请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:管理用户
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="管理用户", description="管理用户")
|
||||
public class SysUserDTO implements Serializable {
|
||||
|
||||
@@ -7,13 +7,10 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:用户角色
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="用户角色", description="用户角色")
|
||||
public class SysUserRoleDTO implements Serializable {
|
||||
|
||||
@@ -7,13 +7,10 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理员登录请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:登录请求
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="管理员登录请求类", description="管理员登录请求类")
|
||||
public class SysUserLoginReqDTO implements Serializable {
|
||||
|
||||
@@ -8,13 +8,10 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理员登录请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:登录信息保存
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="管理员保存请求类", description="管理员保存请求类")
|
||||
public class SysUserSaveReqDTO implements Serializable {
|
||||
|
||||
@@ -7,13 +7,10 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 会话检查请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:请求token
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="会话检查请求类", description="会话检查请求类")
|
||||
public class SysUserTokenReqDTO implements Serializable {
|
||||
|
||||
@@ -11,13 +11,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理用户请求类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:管理用户登录响应类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="管理用户登录响应类", description="管理用户登录响应类")
|
||||
public class SysUserLoginDTO implements Serializable {
|
||||
|
||||
@@ -8,13 +8,10 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色实体类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:角色
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_role")
|
||||
public class SysRole extends Model<SysRole> {
|
||||
|
||||
@@ -10,13 +10,10 @@ import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理用户实体类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:用户类
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_user")
|
||||
public class SysUser extends Model<SysUser> {
|
||||
|
||||
@@ -8,13 +8,10 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色实体类
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:用户角色
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_user_role")
|
||||
public class SysUserRole extends Model<SysUserRole> {
|
||||
|
||||
@@ -3,13 +3,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bc.exam.modules.user.entity.SysRole;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色Mapper
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:角色Mapper
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
}
|
||||
|
||||
@@ -4,13 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bc.exam.modules.user.entity.SysUser;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理用户Mapper
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:管理用户Mapper
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
}
|
||||
|
||||
@@ -4,13 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bc.exam.modules.user.entity.SysUserRole;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色Mapper
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaodong
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:用户角色Mapper
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
|
||||
}
|
||||
|
||||
@@ -7,13 +7,10 @@ import com.bc.exam.modules.user.dto.SysRoleDTO;
|
||||
import com.bc.exam.modules.user.entity.SysRole;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色业务类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:角色
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysRoleService extends IService<SysRole> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,13 +9,10 @@ import com.bc.exam.modules.user.entity.SysUserRole;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色业务类
|
||||
* </p>
|
||||
*
|
||||
* @author chd
|
||||
* @since 2020-04-13 16:57
|
||||
*/
|
||||
* @Description 描述:用户角色
|
||||
* @Author A贾宇婷034244310
|
||||
* @Date 20260615
|
||||
*/
|
||||
public interface SysUserRoleService extends IService<SysUserRole> {
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user