add 集成 EasyExcel 框架 完成业务功能切换
update 优化 Validation 校验框架功能 update 移除掉 StringUtils 语义不明确的api方法 使用特定工具替换2.X
parent
f2b11d704b
commit
07ba70ec8c
|
|
@ -50,8 +50,8 @@
|
||||||
| 多数据源框架 | Dynamic-Datasource | [dynamic-ds文档](https://www.kancloud.cn/tracy5546/dynamic-datasource/content) | 支持主从与多种类数据库异构 |
|
| 多数据源框架 | Dynamic-Datasource | [dynamic-ds文档](https://www.kancloud.cn/tracy5546/dynamic-datasource/content) | 支持主从与多种类数据库异构 |
|
||||||
| 序列化框架 | Jackson | [Jackson官网](https://github.com/FasterXML/jackson) | 统一使用 jackson 高效可靠 |
|
| 序列化框架 | Jackson | [Jackson官网](https://github.com/FasterXML/jackson) | 统一使用 jackson 高效可靠 |
|
||||||
| Redis客户端 | Redisson | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | 支持单机、集群配置 |
|
| Redis客户端 | Redisson | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | 支持单机、集群配置 |
|
||||||
| 校验框架(待优化) | Validation | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | 增强接口安全性、严谨性 支持国际化 |
|
| 校验框架 | Validation | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | 增强接口安全性、严谨性 支持国际化 |
|
||||||
| Excel框架(未完成) | Alibaba EasyExcel | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel) | 性能优异 扩展性强 |
|
| Excel框架 | Alibaba EasyExcel | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel) | 性能优异 扩展性强 |
|
||||||
| 文档框架 | Knife4j | [Knife4j文档](https://doc.xiaominfo.com/knife4j/documentation/) | 美化接口文档 |
|
| 文档框架 | Knife4j | [Knife4j文档](https://doc.xiaominfo.com/knife4j/documentation/) | 美化接口文档 |
|
||||||
| 工具类框架 | Hutool、Lombok | [Hutool文档](https://www.hutool.cn/docs/) | 减少代码冗余 增加安全性 |
|
| 工具类框架 | Hutool、Lombok | [Hutool文档](https://www.hutool.cn/docs/) | 减少代码冗余 增加安全性 |
|
||||||
| 代码生成器(未完成) | 适配MP、Knife4j规范化代码 | [Hutool文档](https://www.hutool.cn/docs/) | 一键生成前后端代码 |
|
| 代码生成器(未完成) | 适配MP、Knife4j规范化代码 | [Hutool文档](https://www.hutool.cn/docs/) | 一键生成前后端代码 |
|
||||||
|
|
|
||||||
24
pom.xml
24
pom.xml
|
|
@ -34,6 +34,8 @@
|
||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<minio.version>8.2.2</minio.version>
|
<minio.version>8.2.2</minio.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
|
<easyexcel.version>3.0.5</easyexcel.version>
|
||||||
|
<cglib.version>3.3.0</cglib.version>
|
||||||
<commons-collections.version>3.2.2</commons-collections.version>
|
<commons-collections.version>3.2.2</commons-collections.version>
|
||||||
<transmittable-thread-local.version>2.12.2</transmittable-thread-local.version>
|
<transmittable-thread-local.version>2.12.2</transmittable-thread-local.version>
|
||||||
<hutool.version>5.7.18</hutool.version>
|
<hutool.version>5.7.18</hutool.version>
|
||||||
|
|
@ -224,6 +226,28 @@
|
||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
<version>${easyexcel.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml-schemas</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cglib</groupId>
|
||||||
|
<artifactId>cglib</artifactId>
|
||||||
|
<version>${cglib.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 文件上传工具类 -->
|
<!-- 文件上传工具类 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common-excel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,47 +1,39 @@
|
||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.TreeEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.Email;
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门表 sys_dept
|
* 部门表 sys_dept
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class SysDept extends BaseEntity {
|
@ApiModel("部门业务对象")
|
||||||
|
public class SysDept extends TreeEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "部门id")
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 父部门ID
|
|
||||||
*/
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 祖级列表
|
|
||||||
*/
|
|
||||||
private String ancestors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门名称
|
* 部门名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "部门名称")
|
||||||
@NotBlank(message = "部门名称不能为空")
|
@NotBlank(message = "部门名称不能为空")
|
||||||
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
@ -49,23 +41,27 @@ public class SysDept extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 显示顺序
|
* 显示顺序
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "显示顺序")
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
private String orderNum;
|
private String orderNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 负责人
|
* 负责人
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "负责人")
|
||||||
private String leader;
|
private String leader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系电话
|
* 联系电话
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "联系电话")
|
||||||
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮箱
|
* 邮箱
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "邮箱")
|
||||||
@Email(message = "邮箱格式不正确")
|
@Email(message = "邮箱格式不正确")
|
||||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
@ -73,21 +69,19 @@ public class SysDept extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 部门状态:0正常,1停用
|
* 部门状态:0正常,1停用
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "部门状态:0正常,1停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标志(0代表存在 2代表删除)
|
* 删除标志(0代表存在 2代表删除)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父部门名称
|
* 祖级列表
|
||||||
*/
|
*/
|
||||||
private String parentName;
|
@ApiModelProperty(value = "祖级列表")
|
||||||
|
private String ancestors;
|
||||||
/**
|
|
||||||
* 子部门
|
|
||||||
*/
|
|
||||||
private List<SysDept> children = new ArrayList<SysDept>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
@ -15,76 +18,94 @@ import javax.validation.constraints.Size;
|
||||||
/**
|
/**
|
||||||
* 字典数据表 sys_dict_data
|
* 字典数据表 sys_dict_data
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@ApiModel("字典数据业务对象")
|
||||||
public class SysDictData extends BaseEntity {
|
public class SysDictData extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典编码
|
* 字典编码
|
||||||
*/
|
*/
|
||||||
@Excel(name = "字典编码", cellType = ColumnType.NUMERIC)
|
@ApiModelProperty(value = "字典编码")
|
||||||
|
@ExcelProperty(value = "字典编码")
|
||||||
private Long dictCode;
|
private Long dictCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典排序
|
* 字典排序
|
||||||
*/
|
*/
|
||||||
@Excel(name = "字典排序", cellType = ColumnType.NUMERIC)
|
@ApiModelProperty(value = "字典排序")
|
||||||
|
@ExcelProperty(value = "字典排序")
|
||||||
private Long dictSort;
|
private Long dictSort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典标签
|
* 字典标签
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "字典标签")
|
||||||
|
@ExcelProperty(value = "字典标签")
|
||||||
@NotBlank(message = "字典标签不能为空")
|
@NotBlank(message = "字典标签不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
||||||
@Excel(name = "字典标签")
|
|
||||||
private String dictLabel;
|
private String dictLabel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典键值
|
* 字典键值
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "字典键值")
|
||||||
|
@ExcelProperty(value = "字典键值")
|
||||||
@NotBlank(message = "字典键值不能为空")
|
@NotBlank(message = "字典键值不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
||||||
@Excel(name = "字典键值")
|
|
||||||
private String dictValue;
|
private String dictValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典类型
|
* 字典类型
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "字典类型")
|
||||||
|
@ExcelProperty(value = "字典类型")
|
||||||
@NotBlank(message = "字典类型不能为空")
|
@NotBlank(message = "字典类型不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
||||||
@Excel(name = "字典类型")
|
|
||||||
private String dictType;
|
private String dictType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 样式属性(其他样式扩展)
|
* 样式属性(其他样式扩展)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "样式属性(其他样式扩展)")
|
||||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
||||||
private String cssClass;
|
private String cssClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格字典样式
|
* 表格字典样式
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "表格字典样式")
|
||||||
private String listClass;
|
private String listClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否默认(Y是 N否)
|
* 是否默认(Y是 N否)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
|
@ApiModelProperty(value = "是否默认(Y是 N否)")
|
||||||
|
@ExcelProperty(value = "是否默认", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_yes_no")
|
||||||
private String isDefault;
|
private String isDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态(0正常 1停用)
|
* 状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
@ApiModelProperty(value = "状态(0正常 1停用)")
|
||||||
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_normal_disable")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
public boolean getDefault() {
|
public boolean getDefault() {
|
||||||
return UserConstants.YES.equals(this.isDefault) ? true : false;
|
return UserConstants.YES.equals(this.isDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
@ -14,41 +17,53 @@ import javax.validation.constraints.Size;
|
||||||
/**
|
/**
|
||||||
* 字典类型表 sys_dict_type
|
* 字典类型表 sys_dict_type
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@ApiModel("字典类型业务对象")
|
||||||
public class SysDictType extends BaseEntity {
|
public class SysDictType extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典主键
|
* 字典主键
|
||||||
*/
|
*/
|
||||||
@Excel(name = "字典主键", cellType = ColumnType.NUMERIC)
|
@ApiModelProperty(value = "字典主键")
|
||||||
|
@ExcelProperty(value = "字典主键")
|
||||||
private Long dictId;
|
private Long dictId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典名称
|
* 字典名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "字典名称")
|
||||||
|
@ExcelProperty(value = "字典名称")
|
||||||
@NotBlank(message = "字典名称不能为空")
|
@NotBlank(message = "字典名称不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||||
@Excel(name = "字典名称")
|
|
||||||
private String dictName;
|
private String dictName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典类型
|
* 字典类型
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "字典类型")
|
||||||
|
@ExcelProperty(value = "字典类型")
|
||||||
@NotBlank(message = "字典类型不能为空")
|
@NotBlank(message = "字典类型不能为空")
|
||||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||||
@Excel(name = "字典类型")
|
|
||||||
private String dictType;
|
private String dictType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态(0正常 1停用)
|
* 状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
@ApiModelProperty(value = "状态(0正常 1停用)")
|
||||||
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_normal_disable")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,60 +1,79 @@
|
||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统访问记录表 sys_logininfor
|
* 系统访问记录表 sys_logininfor
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class SysLogininfor extends BaseEntity {
|
@ExcelIgnoreUnannotated
|
||||||
|
@ApiModel("系统访问记录业务对象")
|
||||||
|
public class SysLogininfor implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "序号", cellType = ColumnType.NUMERIC)
|
@ApiModelProperty(value = "访问ID")
|
||||||
|
@ExcelProperty(value = "序号")
|
||||||
private Long infoId;
|
private Long infoId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户账号
|
* 用户账号
|
||||||
*/
|
*/
|
||||||
@Excel(name = "用户账号")
|
@ApiModelProperty(value = "用户账号")
|
||||||
|
@ExcelProperty(value = "用户账号")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态 0成功 1失败
|
* 状态 0成功 1失败
|
||||||
*/
|
*/
|
||||||
@Excel(name = "状态", readConverterExp = "0=成功,1=失败")
|
@ApiModelProperty(value = "状态 0成功 1失败")
|
||||||
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_common_status")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址
|
* 地址
|
||||||
*/
|
*/
|
||||||
@Excel(name = "地址")
|
@ApiModelProperty(value = "地址")
|
||||||
|
@ExcelProperty(value = "地址")
|
||||||
private String ipaddr;
|
private String ipaddr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述
|
* 描述
|
||||||
*/
|
*/
|
||||||
@Excel(name = "描述")
|
@ApiModelProperty(value = "描述")
|
||||||
|
@ExcelProperty(value = "描述")
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 访问时间
|
* 访问时间
|
||||||
*/
|
*/
|
||||||
@Excel(name = "访问时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
@ApiModelProperty(value = "访问时间")
|
||||||
|
@ExcelProperty(value = "访问时间")
|
||||||
private Date accessTime;
|
private Date accessTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "请求参数")
|
||||||
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,119 +1,151 @@
|
||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作日志记录表 oper_log
|
* 操作日志记录表 oper_log
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class SysOperLog extends BaseEntity {
|
@ExcelIgnoreUnannotated
|
||||||
|
@ApiModel("操作日志记录业务对象")
|
||||||
|
public class SysOperLog implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志主键
|
* 日志主键
|
||||||
*/
|
*/
|
||||||
@Excel(name = "操作序号", cellType = ColumnType.NUMERIC)
|
@ApiModelProperty(value = "日志主键")
|
||||||
|
@ExcelProperty(value = "日志主键")
|
||||||
private Long operId;
|
private Long operId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作模块
|
* 操作模块
|
||||||
*/
|
*/
|
||||||
@Excel(name = "操作模块")
|
@ApiModelProperty(value = "操作模块")
|
||||||
|
@ExcelProperty(value = "操作模块")
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务类型(0其它 1新增 2修改 3删除)
|
* 业务类型(0其它 1新增 2修改 3删除)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据")
|
@ApiModelProperty(value = "业务类型(0其它 1新增 2修改 3删除)")
|
||||||
|
@ExcelProperty(value = "业务类型", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_oper_type")
|
||||||
private Integer businessType;
|
private Integer businessType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务类型数组
|
* 业务类型数组
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "业务类型数组")
|
||||||
private Integer[] businessTypes;
|
private Integer[] businessTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求方法
|
* 请求方法
|
||||||
*/
|
*/
|
||||||
@Excel(name = "请求方法")
|
@ApiModelProperty(value = "请求方法")
|
||||||
|
@ExcelProperty(value = "请求方法")
|
||||||
private String method;
|
private String method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求方式
|
* 请求方式
|
||||||
*/
|
*/
|
||||||
@Excel(name = "请求方式")
|
@ApiModelProperty(value = "请求方式")
|
||||||
|
@ExcelProperty(value = "请求方式")
|
||||||
private String requestMethod;
|
private String requestMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作类别(0其它 1后台用户 2手机端用户)
|
* 操作类别(0其它 1后台用户 2手机端用户)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户")
|
@ApiModelProperty(value = "操作类别(0其它 1后台用户 2手机端用户)")
|
||||||
|
@ExcelProperty(value = "操作类别", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "0=其它,1=后台用户,2=手机端用户")
|
||||||
private Integer operatorType;
|
private Integer operatorType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作人员
|
* 操作人员
|
||||||
*/
|
*/
|
||||||
@Excel(name = "操作人员")
|
@ApiModelProperty(value = "操作人员")
|
||||||
|
@ExcelProperty(value = "操作人员")
|
||||||
private String operName;
|
private String operName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门名称
|
* 部门名称
|
||||||
*/
|
*/
|
||||||
@Excel(name = "部门名称")
|
@ApiModelProperty(value = "部门名称")
|
||||||
|
@ExcelProperty(value = "部门名称")
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求url
|
* 请求url
|
||||||
*/
|
*/
|
||||||
@Excel(name = "请求地址")
|
@ApiModelProperty(value = "请求url")
|
||||||
|
@ExcelProperty(value = "请求地址")
|
||||||
private String operUrl;
|
private String operUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作地址
|
* 操作地址
|
||||||
*/
|
*/
|
||||||
@Excel(name = "操作地址")
|
@ApiModelProperty(value = "操作地址")
|
||||||
|
@ExcelProperty(value = "操作地址")
|
||||||
private String operIp;
|
private String operIp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求参数
|
* 请求参数
|
||||||
*/
|
*/
|
||||||
@Excel(name = "请求参数")
|
@ApiModelProperty(value = "请求参数")
|
||||||
|
@ExcelProperty(value = "请求参数")
|
||||||
private String operParam;
|
private String operParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回参数
|
* 返回参数
|
||||||
*/
|
*/
|
||||||
@Excel(name = "返回参数")
|
@ApiModelProperty(value = "返回参数")
|
||||||
|
@ExcelProperty(value = "返回参数")
|
||||||
private String jsonResult;
|
private String jsonResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作状态(0正常 1异常)
|
* 操作状态(0正常 1异常)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "状态", readConverterExp = "0=正常,1=异常")
|
@ApiModelProperty(value = "操作状态(0正常 1异常)")
|
||||||
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_common_status")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误消息
|
* 错误消息
|
||||||
*/
|
*/
|
||||||
@Excel(name = "错误消息")
|
@ApiModelProperty(value = "错误消息")
|
||||||
|
@ExcelProperty(value = "错误消息")
|
||||||
private String errorMsg;
|
private String errorMsg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作时间
|
* 操作时间
|
||||||
*/
|
*/
|
||||||
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
@ApiModelProperty(value = "操作时间")
|
||||||
|
@ExcelProperty(value = "操作时间")
|
||||||
private Date operTime;
|
private Date operTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "请求参数")
|
||||||
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
@ -14,89 +17,112 @@ import javax.validation.constraints.Size;
|
||||||
/**
|
/**
|
||||||
* 角色表 sys_role
|
* 角色表 sys_role
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
public class SysRole extends BaseEntity {
|
public class SysRole extends BaseEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色ID
|
* 角色ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
|
@ApiModelProperty(value = "角色ID")
|
||||||
|
@ExcelProperty(value = "角色序号")
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色名称
|
* 角色名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色名称")
|
||||||
|
@ExcelProperty(value = "角色名称")
|
||||||
@NotBlank(message = "角色名称不能为空")
|
@NotBlank(message = "角色名称不能为空")
|
||||||
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
||||||
@Excel(name = "角色名称")
|
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色权限
|
* 角色权限
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色权限")
|
||||||
|
@ExcelProperty(value = "角色权限")
|
||||||
@NotBlank(message = "权限字符不能为空")
|
@NotBlank(message = "权限字符不能为空")
|
||||||
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
||||||
@Excel(name = "角色权限")
|
|
||||||
private String roleKey;
|
private String roleKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色排序
|
* 角色排序
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色排序")
|
||||||
|
@ExcelProperty(value = "角色排序")
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
@Excel(name = "角色排序")
|
|
||||||
private String roleSort;
|
private String roleSort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
@ApiModelProperty(value = "数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)")
|
||||||
|
@ExcelProperty(value = "数据范围", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
||||||
private String dataScope;
|
private String dataScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
|
* 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)")
|
||||||
private boolean menuCheckStrictly;
|
private boolean menuCheckStrictly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
|
* 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )")
|
||||||
private boolean deptCheckStrictly;
|
private boolean deptCheckStrictly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色状态(0正常 1停用)
|
* 角色状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
|
@ApiModelProperty(value = "角色状态(0正常 1停用)")
|
||||||
|
@ExcelProperty(value = "角色状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_common_status")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标志(0代表存在 2代表删除)
|
* 删除标志(0代表存在 2代表删除)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户是否存在此角色标识 默认不存在
|
* 用户是否存在此角色标识 默认不存在
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户是否存在此角色标识 默认不存在")
|
||||||
private boolean flag = false;
|
private boolean flag = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单组
|
* 菜单组
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "菜单组")
|
||||||
private Long[] menuIds;
|
private Long[] menuIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门组(数据权限)
|
* 部门组(数据权限)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "部门组(数据权限)")
|
||||||
private Long[] deptIds;
|
private Long[] deptIds;
|
||||||
|
|
||||||
public SysRole(Long roleId) {
|
public SysRole(Long roleId) {
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否管理员")
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
return isAdmin(this.roleId);
|
return isAdmin(this.roleId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
package com.ruoyi.system.api.domain;
|
package com.ruoyi.system.api.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
|
||||||
import com.ruoyi.common.core.annotation.Excel.Type;
|
|
||||||
import com.ruoyi.common.core.annotation.Excels;
|
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
import com.ruoyi.common.core.xss.Xss;
|
import com.ruoyi.common.core.xss.Xss;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
@ -21,131 +20,154 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* 用户对象 sys_user
|
* 用户对象 sys_user
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ApiModel("用户信息业务对象")
|
||||||
public class SysUser extends BaseEntity {
|
public class SysUser extends BaseEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
@ApiModelProperty(value = "用户ID")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "部门编号", type = Type.IMPORT)
|
@ApiModelProperty(value = "部门ID")
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户账号
|
* 用户账号
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户账号")
|
||||||
@Xss(message = "用户账号不能包含脚本字符")
|
@Xss(message = "用户账号不能包含脚本字符")
|
||||||
@NotBlank(message = "用户账号不能为空")
|
@NotBlank(message = "用户账号不能为空")
|
||||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
||||||
@Excel(name = "登录名称")
|
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户昵称
|
* 用户昵称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户昵称")
|
||||||
@Xss(message = "用户昵称不能包含脚本字符")
|
@Xss(message = "用户昵称不能包含脚本字符")
|
||||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||||
@Excel(name = "用户名称")
|
|
||||||
private String nickName;
|
private String nickName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户类型(sys_user系统用户)
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "用户类型")
|
||||||
|
private String userType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户邮箱
|
* 用户邮箱
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户邮箱")
|
||||||
@Email(message = "邮箱格式不正确")
|
@Email(message = "邮箱格式不正确")
|
||||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||||
@Excel(name = "用户邮箱")
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号码
|
* 手机号码
|
||||||
*/
|
*/
|
||||||
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
|
@ApiModelProperty(value = "手机号码")
|
||||||
@Excel(name = "手机号码")
|
|
||||||
private String phonenumber;
|
private String phonenumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户性别
|
* 用户性别
|
||||||
*/
|
*/
|
||||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
@ApiModelProperty(value = "用户性别")
|
||||||
private String sex;
|
private String sex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户头像
|
* 用户头像
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户头像")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码
|
* 密码
|
||||||
*/
|
*/
|
||||||
@JsonProperty
|
@ApiModelProperty(value = "密码")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@JsonProperty
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 帐号状态(0正常 1停用)
|
* 帐号状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
@ApiModelProperty(value = "帐号状态(0正常 1停用)")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标志(0代表存在 2代表删除)
|
* 删除标志(0代表存在 2代表删除)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最后登录IP
|
* 最后登录IP
|
||||||
*/
|
*/
|
||||||
@Excel(name = "最后登录IP", type = Type.EXPORT)
|
@ApiModelProperty(value = "最后登录IP")
|
||||||
private String loginIp;
|
private String loginIp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最后登录时间
|
* 最后登录时间
|
||||||
*/
|
*/
|
||||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
@ApiModelProperty(value = "最后登录时间")
|
||||||
private Date loginDate;
|
private Date loginDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门对象
|
* 部门对象
|
||||||
*/
|
*/
|
||||||
@Excels({
|
@ApiModelProperty(value = "部门对象")
|
||||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
|
||||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
|
|
||||||
})
|
|
||||||
private SysDept dept;
|
private SysDept dept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色对象
|
* 角色对象
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色对象")
|
||||||
private List<SysRole> roles;
|
private List<SysRole> roles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色组
|
* 角色组
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色组")
|
||||||
private Long[] roleIds;
|
private Long[] roleIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位组
|
* 岗位组
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "岗位组")
|
||||||
private Long[] postIds;
|
private Long[] postIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色ID
|
* 数据权限 当前角色ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色ID")
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
public SysUser(Long userId) {
|
public SysUser(Long userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否管理员")
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
return isAdmin(this.userId);
|
return isAdmin(this.userId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.auth.controller;
|
package com.ruoyi.auth.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.auth.form.LoginBody;
|
import com.ruoyi.auth.form.LoginBody;
|
||||||
import com.ruoyi.auth.form.RegisterBody;
|
import com.ruoyi.auth.form.RegisterBody;
|
||||||
import com.ruoyi.auth.service.SysLoginService;
|
import com.ruoyi.auth.service.SysLoginService;
|
||||||
|
|
@ -55,7 +56,7 @@ public class TokenController {
|
||||||
@PostMapping("refresh")
|
@PostMapping("refresh")
|
||||||
public R<?> refresh(HttpServletRequest request) {
|
public R<?> refresh(HttpServletRequest request) {
|
||||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||||
if (StringUtils.isNotNull(loginUser)) {
|
if (ObjectUtil.isNotNull(loginUser)) {
|
||||||
// 刷新令牌有效期
|
// 刷新令牌有效期
|
||||||
tokenService.refreshToken(loginUser);
|
tokenService.refreshToken(loginUser);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.auth.service;
|
package com.ruoyi.auth.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
|
|
@ -7,7 +8,6 @@ import com.ruoyi.common.core.enums.UserStatus;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.ip.IpUtils;
|
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.RemoteLogService;
|
import com.ruoyi.system.api.RemoteLogService;
|
||||||
import com.ruoyi.system.api.RemoteUserService;
|
import com.ruoyi.system.api.RemoteUserService;
|
||||||
|
|
@ -54,7 +54,7 @@ public class SysLoginService {
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
LoginUser userInfo = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
LoginUser userInfo = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||||
|
|
||||||
if (StringUtils.isNull(userInfo)) {
|
if (ObjectUtil.isNull(userInfo)) {
|
||||||
recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +117,7 @@ public class SysLoginService {
|
||||||
public void recordLogininfor(String username, String status, String message) {
|
public void recordLogininfor(String username, String status, String message) {
|
||||||
SysLogininfor logininfor = new SysLogininfor();
|
SysLogininfor logininfor = new SysLogininfor();
|
||||||
logininfor.setUserName(username);
|
logininfor.setUserName(username);
|
||||||
logininfor.setIpaddr(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
logininfor.setIpaddr(ServletUtils.getClientIP());
|
||||||
logininfor.setMsg(message);
|
logininfor.setMsg(message);
|
||||||
// 日志状态
|
// 日志状态
|
||||||
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) {
|
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
<module>ruoyi-common-bom</module>
|
<module>ruoyi-common-bom</module>
|
||||||
<module>ruoyi-common-log</module>
|
<module>ruoyi-common-log</module>
|
||||||
<module>ruoyi-common-dict</module>
|
<module>ruoyi-common-dict</module>
|
||||||
|
<module>ruoyi-common-excel</module>
|
||||||
<module>ruoyi-common-core</module>
|
<module>ruoyi-common-core</module>
|
||||||
<module>ruoyi-common-redis</module>
|
<module>ruoyi-common-redis</module>
|
||||||
<module>ruoyi-common-swagger</module>
|
<module>ruoyi-common-swagger</module>
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,13 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- excel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common-excel</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 缓存服务 -->
|
<!-- 缓存服务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
|
|
|
||||||
|
|
@ -93,10 +93,9 @@
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- excel工具 -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Java Servlet -->
|
<!-- Java Servlet -->
|
||||||
|
|
@ -126,6 +125,11 @@
|
||||||
<artifactId>hutool-jwt</artifactId>
|
<artifactId>hutool-jwt</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-http</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-extra</artifactId>
|
<artifactId>hutool-extra</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -1,162 +0,0 @@
|
||||||
package com.ruoyi.common.core.annotation;
|
|
||||||
|
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelHandlerAdapter;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义导出Excel数据注解
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
public @interface Excel {
|
|
||||||
/**
|
|
||||||
* 导出时在excel中排序
|
|
||||||
*/
|
|
||||||
public int sort() default Integer.MAX_VALUE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出到Excel中的名字.
|
|
||||||
*/
|
|
||||||
public String name() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日期格式, 如: yyyy-MM-dd
|
|
||||||
*/
|
|
||||||
public String dateFormat() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
|
||||||
*/
|
|
||||||
public String readConverterExp() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分隔符,读取字符串组内容
|
|
||||||
*/
|
|
||||||
public String separator() default ",";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
|
||||||
*/
|
|
||||||
public int scale() default -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
|
||||||
*/
|
|
||||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出类型(0数字 1字符串)
|
|
||||||
*/
|
|
||||||
public ColumnType cellType() default ColumnType.STRING;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出时在excel中每个列的高度 单位为字符
|
|
||||||
*/
|
|
||||||
public double height() default 14;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出时在excel中每个列的宽 单位为字符
|
|
||||||
*/
|
|
||||||
public double width() default 16;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文字后缀,如% 90 变成90%
|
|
||||||
*/
|
|
||||||
public String suffix() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当值为空时,字段的默认值
|
|
||||||
*/
|
|
||||||
public String defaultValue() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提示信息
|
|
||||||
*/
|
|
||||||
public String prompt() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置只能选择不能输入的列内容.
|
|
||||||
*/
|
|
||||||
public String[] combo() default {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
|
||||||
*/
|
|
||||||
public boolean isExport() default true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
|
||||||
*/
|
|
||||||
public String targetAttr() default "";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否自动统计数据,在最后追加一行统计数据总和
|
|
||||||
*/
|
|
||||||
public boolean isStatistics() default false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
|
|
||||||
*/
|
|
||||||
public Align align() default Align.AUTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义数据处理器
|
|
||||||
*/
|
|
||||||
public Class<?> handler() default ExcelHandlerAdapter.class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义数据处理器参数
|
|
||||||
*/
|
|
||||||
public String[] args() default {};
|
|
||||||
|
|
||||||
public enum Align {
|
|
||||||
AUTO(0), LEFT(1), CENTER(2), RIGHT(3);
|
|
||||||
private final int value;
|
|
||||||
|
|
||||||
Align(int value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int value() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
|
||||||
*/
|
|
||||||
Type type() default Type.ALL;
|
|
||||||
|
|
||||||
public enum Type {
|
|
||||||
ALL(0), EXPORT(1), IMPORT(2);
|
|
||||||
private final int value;
|
|
||||||
|
|
||||||
Type(int value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int value() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ColumnType {
|
|
||||||
NUMERIC(0), STRING(1), IMAGE(2);
|
|
||||||
private final int value;
|
|
||||||
|
|
||||||
ColumnType(int value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int value() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
package com.ruoyi.common.core.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel注解集
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface Excels {
|
|
||||||
Excel[] value();
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.ruoyi.common.core.config;
|
||||||
|
|
||||||
|
import org.hibernate.validator.HibernateValidator;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||||
|
|
||||||
|
import javax.validation.Validator;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验框架配置类
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class ValidatorConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageSource messageSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置校验框架 快速返回模式
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Validator validator() {
|
||||||
|
LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean();
|
||||||
|
// 国际化
|
||||||
|
factoryBean.setValidationMessageSource(messageSource);
|
||||||
|
// 设置使用 HibernateValidator 校验器
|
||||||
|
factoryBean.setProviderClass(HibernateValidator.class);
|
||||||
|
Properties properties = new Properties();
|
||||||
|
// 设置 快速异常返回
|
||||||
|
properties.setProperty("hibernate.validator.fail_fast", "true");
|
||||||
|
factoryBean.setValidationProperties(properties);
|
||||||
|
// 加载配置
|
||||||
|
factoryBean.afterPropertiesSet();
|
||||||
|
return factoryBean.getValidator();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.ruoyi.common.dict.service;
|
package com.ruoyi.common.core.service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典服务服务
|
* 字典服务服务
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
|
import cn.hutool.extra.cglib.CglibUtil;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bean深拷贝工具(基于 cglib 性能优异)
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class BeanCopyUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单对象基于class创建拷贝
|
||||||
|
*
|
||||||
|
* @param source 数据来源实体
|
||||||
|
* @param desc 描述对象 转换后的对象
|
||||||
|
* @return desc
|
||||||
|
*/
|
||||||
|
public static <T, V> V copy(T source, Class<V> desc) {
|
||||||
|
if (ObjectUtil.isNull(source)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNull(desc)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CglibUtil.copy(source, desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单对象基于对象创建拷贝
|
||||||
|
*
|
||||||
|
* @param source 数据来源实体
|
||||||
|
* @param desc 转换后的对象
|
||||||
|
* @return desc
|
||||||
|
*/
|
||||||
|
public static <T, V> V copy(T source, V desc) {
|
||||||
|
if (ObjectUtil.isNull(source)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNull(desc)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CglibUtil.copy(source, desc);
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表对象基于class创建拷贝
|
||||||
|
*
|
||||||
|
* @param sourceList 数据来源实体列表
|
||||||
|
* @param desc 描述对象 转换后的对象
|
||||||
|
* @return desc
|
||||||
|
*/
|
||||||
|
public static <T, V> List<V> copyList(List<T> sourceList, Class<V> desc) {
|
||||||
|
if (ObjectUtil.isNull(sourceList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(sourceList)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return CglibUtil.copyList(sourceList, () -> ReflectUtil.newInstanceIfPossible(desc));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bean拷贝到map
|
||||||
|
*
|
||||||
|
* @param bean 数据来源实体
|
||||||
|
* @return map对象
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public static <T> Map<String, Object> copyToMap(T bean) {
|
||||||
|
if (ObjectUtil.isNull(bean)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CglibUtil.toMap(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* map拷贝到bean
|
||||||
|
*
|
||||||
|
* @param map 数据来源
|
||||||
|
* @param beanClass bean类
|
||||||
|
* @return bean对象
|
||||||
|
*/
|
||||||
|
public static <T> T mapToBean(Map<String, Object> map, Class<T> beanClass) {
|
||||||
|
if (MapUtil.isEmpty(map)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNull(beanClass)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CglibUtil.toBean(map, beanClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* map拷贝到bean
|
||||||
|
*
|
||||||
|
* @param map 数据来源
|
||||||
|
* @param bean bean对象
|
||||||
|
* @return bean对象
|
||||||
|
*/
|
||||||
|
public static <T> T mapToBean(Map<String, Object> map, T bean) {
|
||||||
|
if (MapUtil.isEmpty(map)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNull(bean)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CglibUtil.fillBean(map, bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
|
@ -12,7 +14,9 @@ import java.util.Date;
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||||
|
|
||||||
public static String YYYY = "yyyy";
|
public static String YYYY = "yyyy";
|
||||||
|
|
||||||
public static String YYYY_MM = "yyyy-MM";
|
public static String YYYY_MM = "yyyy-MM";
|
||||||
|
|
@ -24,9 +28,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
private static String[] parsePatterns = {
|
private static String[] parsePatterns = {
|
||||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前Date型日期
|
* 获取当前Date型日期
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
@ -23,7 +24,7 @@ public class JsonUtils {
|
||||||
private static ObjectMapper objectMapper = SpringUtils.getBean(ObjectMapper.class);
|
private static ObjectMapper objectMapper = SpringUtils.getBean(ObjectMapper.class);
|
||||||
|
|
||||||
public static String toJsonString(Object object) {
|
public static String toJsonString(Object object) {
|
||||||
if (StringUtils.isNull(object)) {
|
if (ObjectUtil.isNull(object)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||||
import com.ruoyi.common.core.web.page.PageDomain;
|
import com.ruoyi.common.core.web.page.PageDomain;
|
||||||
|
|
@ -18,7 +19,7 @@ public class PageUtils extends PageHelper {
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
|
if (ObjectUtil.isNotNull(pageNum) && ObjectUtil.isNotNull(pageSize)) {
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
Boolean reasonable = pageDomain.getReasonable();
|
Boolean reasonable = pageDomain.getReasonable();
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
|
import cn.hutool.http.HttpStatus;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
@ -13,6 +18,7 @@ import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -22,7 +28,9 @@ import java.util.Map;
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class ServletUtils {
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class ServletUtils extends ServletUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取String参数
|
* 获取String参数
|
||||||
*/
|
*/
|
||||||
|
|
@ -133,9 +141,9 @@ public class ServletUtils {
|
||||||
*/
|
*/
|
||||||
public static String renderString(HttpServletResponse response, String string) {
|
public static String renderString(HttpServletResponse response, String string) {
|
||||||
try {
|
try {
|
||||||
response.setStatus(200);
|
response.setStatus(HttpStatus.HTTP_OK);
|
||||||
response.setContentType("application/json");
|
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding(StandardCharsets.UTF_8.toString());
|
||||||
response.getWriter().print(string);
|
response.getWriter().print(string);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -149,6 +157,7 @@ public class ServletUtils {
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
public static boolean isAjaxRequest(HttpServletRequest request) {
|
public static boolean isAjaxRequest(HttpServletRequest request) {
|
||||||
|
|
||||||
String accept = request.getHeader("accept");
|
String accept = request.getHeader("accept");
|
||||||
if (accept != null && accept.indexOf("application/json") != -1) {
|
if (accept != null && accept.indexOf("application/json") != -1) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -160,17 +169,21 @@ public class ServletUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
String uri = request.getRequestURI();
|
String uri = request.getRequestURI();
|
||||||
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) {
|
if (StringUtils.equalsAnyIgnoreCase(uri, ".json", ".xml")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ajax = request.getParameter("__ajax");
|
String ajax = request.getParameter("__ajax");
|
||||||
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) {
|
if (StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getClientIP() {
|
||||||
|
return getClientIP(getRequest());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内容编码
|
* 内容编码
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,15 @@ package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.map.MapUtil;
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.springframework.util.AntPathMatcher;
|
import org.springframework.util.AntPathMatcher;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串工具类
|
* 字符串工具类
|
||||||
|
|
@ -20,16 +20,6 @@ import java.util.*;
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取参数不为空值
|
|
||||||
*
|
|
||||||
* @param value defaultValue 要判断的value
|
|
||||||
* @return value 返回值
|
|
||||||
*/
|
|
||||||
public static <T> T nvl(T value, T defaultValue) {
|
|
||||||
return ObjectUtil.defaultIfNull(value, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取参数不为空值
|
* 获取参数不为空值
|
||||||
*
|
*
|
||||||
|
|
@ -40,86 +30,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
return StrUtil.blankToDefault(str, defaultValue);
|
return StrUtil.blankToDefault(str, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
|
||||||
*
|
|
||||||
* @param coll 要判断的Collection
|
|
||||||
* @return true:为空 false:非空
|
|
||||||
*/
|
|
||||||
public static boolean isEmpty(Collection<?> coll) {
|
|
||||||
return CollUtil.isEmpty(coll);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个Collection是否非空,包含List,Set,Queue
|
|
||||||
*
|
|
||||||
* @param coll 要判断的Collection
|
|
||||||
* @return true:非空 false:空
|
|
||||||
*/
|
|
||||||
public static boolean isNotEmpty(Collection<?> coll) {
|
|
||||||
return !isEmpty(coll);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个对象数组是否为空
|
|
||||||
*
|
|
||||||
* @param objects 要判断的对象数组
|
|
||||||
* * @return true:为空 false:非空
|
|
||||||
*/
|
|
||||||
public static boolean isEmpty(Object[] objects) {
|
|
||||||
return ArrayUtil.isEmpty(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个对象数组是否非空
|
|
||||||
*
|
|
||||||
* @param objects 要判断的对象数组
|
|
||||||
* @return true:非空 false:空
|
|
||||||
*/
|
|
||||||
public static boolean isNotEmpty(Object[] objects) {
|
|
||||||
return !isEmpty(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个对象是否为空
|
|
||||||
*
|
|
||||||
* @param object 要判断的对象数组
|
|
||||||
* * @return true:为空 false:非空
|
|
||||||
*/
|
|
||||||
public static boolean isEmpty(Object object) {
|
|
||||||
return ObjectUtil.isEmpty(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个对象是否非空
|
|
||||||
*
|
|
||||||
* @param object 要判断的对象数组
|
|
||||||
* @return true:非空 false:空
|
|
||||||
*/
|
|
||||||
public static boolean isNotEmpty(Object object) {
|
|
||||||
return !isEmpty(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个Map是否为空
|
|
||||||
*
|
|
||||||
* @param map 要判断的Map
|
|
||||||
* @return true:为空 false:非空
|
|
||||||
*/
|
|
||||||
public static boolean isEmpty(Map<?, ?> map) {
|
|
||||||
return MapUtil.isEmpty(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个Map是否为空
|
|
||||||
*
|
|
||||||
* @param map 要判断的Map
|
|
||||||
* @return true:非空 false:空
|
|
||||||
*/
|
|
||||||
public static boolean isNotEmpty(Map<?, ?> map) {
|
|
||||||
return !isEmpty(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个字符串是否为空串
|
* * 判断一个字符串是否为空串
|
||||||
*
|
*
|
||||||
|
|
@ -140,36 +50,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
return !isEmpty(str);
|
return !isEmpty(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个对象是否为空
|
|
||||||
*
|
|
||||||
* @param object Object
|
|
||||||
* @return true:为空 false:非空
|
|
||||||
*/
|
|
||||||
public static boolean isNull(Object object) {
|
|
||||||
return ObjectUtil.isNull(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个对象是否非空
|
|
||||||
*
|
|
||||||
* @param object Object
|
|
||||||
* @return true:非空 false:空
|
|
||||||
*/
|
|
||||||
public static boolean isNotNull(Object object) {
|
|
||||||
return !isNull(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
|
||||||
*
|
|
||||||
* @param object 对象
|
|
||||||
* @return true:是数组 false:不是数组
|
|
||||||
*/
|
|
||||||
public static boolean isArray(Object object) {
|
|
||||||
return ArrayUtil.isArray(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 去空格
|
* 去空格
|
||||||
*/
|
*/
|
||||||
|
|
@ -325,7 +205,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
* @return 是否匹配
|
* @return 是否匹配
|
||||||
*/
|
*/
|
||||||
public static boolean matches(String str, List<String> strs) {
|
public static boolean matches(String str, List<String> strs) {
|
||||||
if (isEmpty(str) || isEmpty(strs)) {
|
if (isEmpty(str) || CollUtil.isEmpty(strs)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (String pattern : strs) {
|
for (String pattern : strs) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
|
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||||
|
import cn.hutool.core.lang.tree.TreeUtil;
|
||||||
|
import cn.hutool.core.lang.tree.parser.NodeParser;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扩展 hutool TreeUtil 封装系统树构建
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class TreeBuildUtils extends TreeUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据前端定制差异化字段
|
||||||
|
*/
|
||||||
|
public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("label");
|
||||||
|
|
||||||
|
public static <T> List<Tree<Long>> build(List<T> list, Long parentId, NodeParser<T, Long> nodeParser) {
|
||||||
|
return TreeUtil.build(list, parentId, DEFAULT_CONFIG, nodeParser);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
import javax.validation.Validator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validator 校验框架工具
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class ValidatorUtils {
|
||||||
|
|
||||||
|
private static final Validator VALID = SpringUtils.getBean(Validator.class);
|
||||||
|
|
||||||
|
public static <T> void validate(T object, Class<?>... groups) {
|
||||||
|
Set<ConstraintViolation<T>> validate = VALID.validate(object, groups);
|
||||||
|
if (!validate.isEmpty()) {
|
||||||
|
throw new ConstraintViolationException("参数校验异常", validate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,104 +0,0 @@
|
||||||
package com.ruoyi.common.core.utils.bean;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bean 工具类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|
||||||
/**
|
|
||||||
* Bean方法名中属性名开始的下标
|
|
||||||
*/
|
|
||||||
private static final int BEAN_METHOD_PROP_INDEX = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 匹配getter方法的正则表达式
|
|
||||||
*/
|
|
||||||
private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 匹配setter方法的正则表达式
|
|
||||||
*/
|
|
||||||
private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bean属性复制工具方法。
|
|
||||||
*
|
|
||||||
* @param dest 目标对象
|
|
||||||
* @param src 源对象
|
|
||||||
*/
|
|
||||||
public static void copyBeanProp(Object dest, Object src) {
|
|
||||||
try {
|
|
||||||
copyProperties(src, dest);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对象的setter方法。
|
|
||||||
*
|
|
||||||
* @param obj 对象
|
|
||||||
* @return 对象的setter方法列表
|
|
||||||
*/
|
|
||||||
public static List<Method> getSetterMethods(Object obj) {
|
|
||||||
// setter方法列表
|
|
||||||
List<Method> setterMethods = new ArrayList<Method>();
|
|
||||||
|
|
||||||
// 获取所有方法
|
|
||||||
Method[] methods = obj.getClass().getMethods();
|
|
||||||
|
|
||||||
// 查找setter方法
|
|
||||||
|
|
||||||
for (Method method : methods) {
|
|
||||||
Matcher m = SET_PATTERN.matcher(method.getName());
|
|
||||||
if (m.matches() && (method.getParameterTypes().length == 1)) {
|
|
||||||
setterMethods.add(method);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 返回setter方法列表
|
|
||||||
return setterMethods;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对象的getter方法。
|
|
||||||
*
|
|
||||||
* @param obj 对象
|
|
||||||
* @return 对象的getter方法列表
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static List<Method> getGetterMethods(Object obj) {
|
|
||||||
// getter方法列表
|
|
||||||
List<Method> getterMethods = new ArrayList<Method>();
|
|
||||||
// 获取所有方法
|
|
||||||
Method[] methods = obj.getClass().getMethods();
|
|
||||||
// 查找getter方法
|
|
||||||
for (Method method : methods) {
|
|
||||||
Matcher m = GET_PATTERN.matcher(method.getName());
|
|
||||||
if (m.matches() && (method.getParameterTypes().length == 0)) {
|
|
||||||
getterMethods.add(method);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 返回getter方法列表
|
|
||||||
return getterMethods;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查Bean方法名中的属性名是否相等。<br>
|
|
||||||
* 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。
|
|
||||||
*
|
|
||||||
* @param m1 方法名1
|
|
||||||
* @param m2 方法名2
|
|
||||||
* @return 属性名一样返回true,否则返回false
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static boolean isMethodPropEquals(String m1, String m2) {
|
|
||||||
return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
package com.ruoyi.common.core.utils.bean;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintViolation;
|
|
||||||
import javax.validation.ConstraintViolationException;
|
|
||||||
import javax.validation.Validator;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bean对象属性验证
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class BeanValidators {
|
|
||||||
public static void validateWithException(Validator validator, Object object, Class<?>... groups)
|
|
||||||
throws ConstraintViolationException {
|
|
||||||
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
|
|
||||||
if (!constraintViolations.isEmpty()) {
|
|
||||||
throw new ConstraintViolationException(constraintViolations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,190 +1,21 @@
|
||||||
package com.ruoyi.common.core.utils.file;
|
package com.ruoyi.common.core.utils.file;
|
||||||
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件处理工具类
|
* 文件处理工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
public class FileUtils {
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
/**
|
public class FileUtils extends FileUtil {
|
||||||
* 字符常量:斜杠 {@code '/'}
|
|
||||||
*/
|
|
||||||
public static final char SLASH = '/';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符常量:反斜杠 {@code '\\'}
|
|
||||||
*/
|
|
||||||
public static final char BACKSLASH = '\\';
|
|
||||||
|
|
||||||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 输出指定文件的byte数组
|
|
||||||
*
|
|
||||||
* @param filePath 文件路径
|
|
||||||
* @param os 输出流
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static void writeBytes(String filePath, OutputStream os) throws IOException {
|
|
||||||
FileInputStream fis = null;
|
|
||||||
try {
|
|
||||||
File file = new File(filePath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
throw new FileNotFoundException(filePath);
|
|
||||||
}
|
|
||||||
fis = new FileInputStream(file);
|
|
||||||
byte[] b = new byte[1024];
|
|
||||||
int length;
|
|
||||||
while ((length = fis.read(b)) > 0) {
|
|
||||||
os.write(b, 0, length);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
if (os != null) {
|
|
||||||
try {
|
|
||||||
os.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fis != null) {
|
|
||||||
try {
|
|
||||||
fis.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除文件
|
|
||||||
*
|
|
||||||
* @param filePath 文件
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean deleteFile(String filePath) {
|
|
||||||
boolean flag = false;
|
|
||||||
File file = new File(filePath);
|
|
||||||
// 路径为文件且不为空则进行删除
|
|
||||||
if (file.isFile() && file.exists()) {
|
|
||||||
file.delete();
|
|
||||||
flag = true;
|
|
||||||
}
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件名称验证
|
|
||||||
*
|
|
||||||
* @param filename 文件名称
|
|
||||||
* @return true 正常 false 非法
|
|
||||||
*/
|
|
||||||
public static boolean isValidFilename(String filename) {
|
|
||||||
return filename.matches(FILENAME_PATTERN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查文件是否可下载
|
|
||||||
*
|
|
||||||
* @param resource 需要下载的文件
|
|
||||||
* @return true 正常 false 非法
|
|
||||||
*/
|
|
||||||
public static boolean checkAllowDownload(String resource) {
|
|
||||||
// 禁止目录上跳级别
|
|
||||||
if (StringUtils.contains(resource, "..")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查允许下载的文件规则
|
|
||||||
if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 不在允许下载的文件规则
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载文件名重新编码
|
|
||||||
*
|
|
||||||
* @param request 请求对象
|
|
||||||
* @param fileName 文件名
|
|
||||||
* @return 编码后的文件名
|
|
||||||
*/
|
|
||||||
public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException {
|
|
||||||
final String agent = request.getHeader("USER-AGENT");
|
|
||||||
String filename = fileName;
|
|
||||||
if (agent.contains("MSIE")) {
|
|
||||||
// IE浏览器
|
|
||||||
filename = URLEncoder.encode(filename, "utf-8");
|
|
||||||
filename = filename.replace("+", " ");
|
|
||||||
} else if (agent.contains("Firefox")) {
|
|
||||||
// 火狐浏览器
|
|
||||||
filename = new String(fileName.getBytes(), "ISO8859-1");
|
|
||||||
} else if (agent.contains("Chrome")) {
|
|
||||||
// google浏览器
|
|
||||||
filename = URLEncoder.encode(filename, "utf-8");
|
|
||||||
} else {
|
|
||||||
// 其它浏览器
|
|
||||||
filename = URLEncoder.encode(filename, "utf-8");
|
|
||||||
}
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回文件名
|
|
||||||
*
|
|
||||||
* @param filePath 文件
|
|
||||||
* @return 文件名
|
|
||||||
*/
|
|
||||||
public static String getName(String filePath) {
|
|
||||||
if (null == filePath) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int len = filePath.length();
|
|
||||||
if (0 == len) {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
if (isFileSeparator(filePath.charAt(len - 1))) {
|
|
||||||
// 以分隔符结尾的去掉结尾分隔符
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
int begin = 0;
|
|
||||||
char c;
|
|
||||||
for (int i = len - 1; i > -1; i--) {
|
|
||||||
c = filePath.charAt(i);
|
|
||||||
if (isFileSeparator(c)) {
|
|
||||||
// 查找最后一个路径分隔符(/或者\)
|
|
||||||
begin = i + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filePath.substring(begin, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为Windows或者Linux(Unix)文件分隔符<br>
|
|
||||||
* Windows平台下分隔符为\,Linux(Unix)为/
|
|
||||||
*
|
|
||||||
* @param c 字符
|
|
||||||
* @return 是否为Windows或者Linux(Unix)文件分隔符
|
|
||||||
*/
|
|
||||||
public static boolean isFileSeparator(char c) {
|
|
||||||
return SLASH == c || BACKSLASH == c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载文件名重新编码
|
* 下载文件名重新编码
|
||||||
|
|
@ -198,12 +29,14 @@ public class FileUtils {
|
||||||
|
|
||||||
StringBuilder contentDispositionValue = new StringBuilder();
|
StringBuilder contentDispositionValue = new StringBuilder();
|
||||||
contentDispositionValue.append("attachment; filename=")
|
contentDispositionValue.append("attachment; filename=")
|
||||||
.append(percentEncodedFileName)
|
.append(percentEncodedFileName)
|
||||||
.append(";")
|
.append(";")
|
||||||
.append("filename*=")
|
.append("filename*=")
|
||||||
.append("utf-8''")
|
.append("utf-8''")
|
||||||
.append(percentEncodedFileName);
|
.append(percentEncodedFileName);
|
||||||
|
|
||||||
|
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
|
||||||
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
||||||
response.setHeader("download-filename", percentEncodedFileName);
|
response.setHeader("download-filename", percentEncodedFileName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.ruoyi.common.core.utils.file;
|
package com.ruoyi.common.core.utils.file;
|
||||||
|
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,179 +0,0 @@
|
||||||
package com.ruoyi.common.core.utils.ip;
|
|
||||||
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取IP方法
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class IpUtils {
|
|
||||||
public static String getIpAddr(HttpServletRequest request) {
|
|
||||||
if (request == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
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.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean internalIp(String ip) {
|
|
||||||
byte[] addr = textToNumericFormatV4(ip);
|
|
||||||
return internalIp(addr) || "127.0.0.1".equals(ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean internalIp(byte[] addr) {
|
|
||||||
if (StringUtils.isNull(addr) || addr.length < 2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final byte b0 = addr[0];
|
|
||||||
final byte b1 = addr[1];
|
|
||||||
// 10.x.x.x/8
|
|
||||||
final byte SECTION_1 = 0x0A;
|
|
||||||
// 172.16.x.x/12
|
|
||||||
final byte SECTION_2 = (byte) 0xAC;
|
|
||||||
final byte SECTION_3 = (byte) 0x10;
|
|
||||||
final byte SECTION_4 = (byte) 0x1F;
|
|
||||||
// 192.168.x.x/16
|
|
||||||
final byte SECTION_5 = (byte) 0xC0;
|
|
||||||
final byte SECTION_6 = (byte) 0xA8;
|
|
||||||
switch (b0) {
|
|
||||||
case SECTION_1:
|
|
||||||
return true;
|
|
||||||
case SECTION_2:
|
|
||||||
if (b1 >= SECTION_3 && b1 <= SECTION_4) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case SECTION_5:
|
|
||||||
switch (b1) {
|
|
||||||
case SECTION_6:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将IPv4地址转换成字节
|
|
||||||
*
|
|
||||||
* @param text IPv4地址
|
|
||||||
* @return byte 字节
|
|
||||||
*/
|
|
||||||
public static byte[] textToNumericFormatV4(String text) {
|
|
||||||
if (text.length() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] bytes = new byte[4];
|
|
||||||
String[] elements = text.split("\\.", -1);
|
|
||||||
try {
|
|
||||||
long l;
|
|
||||||
int i;
|
|
||||||
switch (elements.length) {
|
|
||||||
case 1:
|
|
||||||
l = Long.parseLong(elements[0]);
|
|
||||||
if ((l < 0L) || (l > 4294967295L)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
|
|
||||||
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
|
|
||||||
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
|
||||||
bytes[3] = (byte) (int) (l & 0xFF);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
l = Integer.parseInt(elements[0]);
|
|
||||||
if ((l < 0L) || (l > 255L)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
bytes[0] = (byte) (int) (l & 0xFF);
|
|
||||||
l = Integer.parseInt(elements[1]);
|
|
||||||
if ((l < 0L) || (l > 16777215L)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
|
|
||||||
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
|
||||||
bytes[3] = (byte) (int) (l & 0xFF);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
for (i = 0; i < 2; ++i) {
|
|
||||||
l = Integer.parseInt(elements[i]);
|
|
||||||
if ((l < 0L) || (l > 255L)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
bytes[i] = (byte) (int) (l & 0xFF);
|
|
||||||
}
|
|
||||||
l = Integer.parseInt(elements[2]);
|
|
||||||
if ((l < 0L) || (l > 65535L)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
|
|
||||||
bytes[3] = (byte) (int) (l & 0xFF);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
for (i = 0; i < 4; ++i) {
|
|
||||||
l = Integer.parseInt(elements[i]);
|
|
||||||
if ((l < 0L) || (l > 255L)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
bytes[i] = (byte) (int) (l & 0xFF);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getHostIp() {
|
|
||||||
try {
|
|
||||||
return InetAddress.getLocalHost().getHostAddress();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
}
|
|
||||||
return "127.0.0.1";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getHostName() {
|
|
||||||
try {
|
|
||||||
return InetAddress.getLocalHost().getHostName();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
}
|
|
||||||
return "未知";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
package com.ruoyi.common.core.utils.poi;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel数据格式处理适配器
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public interface ExcelHandlerAdapter {
|
|
||||||
/**
|
|
||||||
* 格式化
|
|
||||||
*
|
|
||||||
* @param value 单元格数据值
|
|
||||||
* @param args excel注解args参数组
|
|
||||||
* @return 处理后的值
|
|
||||||
*/
|
|
||||||
Object format(Object value, String[] args);
|
|
||||||
}
|
|
||||||
|
|
@ -1,944 +0,0 @@
|
||||||
package com.ruoyi.common.core.utils.poi;
|
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
|
||||||
import com.ruoyi.common.core.annotation.Excel.Type;
|
|
||||||
import com.ruoyi.common.core.annotation.Excels;
|
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.core.utils.file.FileTypeUtils;
|
|
||||||
import com.ruoyi.common.core.utils.file.ImageUtils;
|
|
||||||
import com.ruoyi.common.core.utils.reflect.ReflectUtils;
|
|
||||||
import org.apache.poi.ss.usermodel.*;
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
|
||||||
import org.apache.poi.util.IOUtils;
|
|
||||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel相关处理
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class ExcelUtil<T> {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel sheet最大行数,默认65536
|
|
||||||
*/
|
|
||||||
public static final int sheetSize = 65536;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工作表名称
|
|
||||||
*/
|
|
||||||
private String sheetName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出类型(EXPORT:导出数据;IMPORT:导入模板)
|
|
||||||
*/
|
|
||||||
private Type type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工作薄对象
|
|
||||||
*/
|
|
||||||
private Workbook wb;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工作表对象
|
|
||||||
*/
|
|
||||||
private Sheet sheet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 样式列表
|
|
||||||
*/
|
|
||||||
private Map<String, CellStyle> styles;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入导出数据列表
|
|
||||||
*/
|
|
||||||
private List<T> list;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注解列表
|
|
||||||
*/
|
|
||||||
private List<Object[]> fields;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前行号
|
|
||||||
*/
|
|
||||||
private int rownum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标题
|
|
||||||
*/
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最大高度
|
|
||||||
*/
|
|
||||||
private short maxHeight;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统计列表
|
|
||||||
*/
|
|
||||||
private Map<Integer, Double> statistics = new HashMap<Integer, Double>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字格式
|
|
||||||
*/
|
|
||||||
private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实体对象
|
|
||||||
*/
|
|
||||||
public Class<T> clazz;
|
|
||||||
|
|
||||||
public ExcelUtil(Class<T> clazz) {
|
|
||||||
this.clazz = clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(List<T> list, String sheetName, String title, Type type) {
|
|
||||||
if (list == null) {
|
|
||||||
list = new ArrayList<T>();
|
|
||||||
}
|
|
||||||
this.list = list;
|
|
||||||
this.sheetName = sheetName;
|
|
||||||
this.type = type;
|
|
||||||
this.title = title;
|
|
||||||
createExcelField();
|
|
||||||
createWorkbook();
|
|
||||||
createTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建excel第一行标题
|
|
||||||
*/
|
|
||||||
public void createTitle() {
|
|
||||||
if (StringUtils.isNotEmpty(title)) {
|
|
||||||
Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0);
|
|
||||||
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(),
|
|
||||||
this.fields.size() - 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对excel表单默认第一个索引名转换成list
|
|
||||||
*
|
|
||||||
* @param is 输入流
|
|
||||||
* @return 转换后集合
|
|
||||||
*/
|
|
||||||
public List<T> importExcel(InputStream is) throws Exception {
|
|
||||||
return importExcel(is, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对excel表单默认第一个索引名转换成list
|
|
||||||
*
|
|
||||||
* @param is 输入流
|
|
||||||
* @param titleNum 标题占用行数
|
|
||||||
* @return 转换后集合
|
|
||||||
*/
|
|
||||||
public List<T> importExcel(InputStream is, int titleNum) throws Exception {
|
|
||||||
return importExcel(StringUtils.EMPTY, is, titleNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对excel表单指定表格索引名转换成list
|
|
||||||
*
|
|
||||||
* @param sheetName 表格索引名
|
|
||||||
* @param titleNum 标题占用行数
|
|
||||||
* @param is 输入流
|
|
||||||
* @return 转换后集合
|
|
||||||
*/
|
|
||||||
public List<T> importExcel(String sheetName, InputStream is, int titleNum) throws Exception {
|
|
||||||
this.type = Type.IMPORT;
|
|
||||||
this.wb = WorkbookFactory.create(is);
|
|
||||||
List<T> list = new ArrayList<T>();
|
|
||||||
// 如果指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet
|
|
||||||
Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0);
|
|
||||||
if (sheet == null) {
|
|
||||||
throw new IOException("文件sheet不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1
|
|
||||||
int rows = sheet.getLastRowNum();
|
|
||||||
|
|
||||||
if (rows > 0) {
|
|
||||||
// 定义一个map用于存放excel列的序号和field.
|
|
||||||
Map<String, Integer> cellMap = new HashMap<String, Integer>();
|
|
||||||
// 获取表头
|
|
||||||
Row heard = sheet.getRow(titleNum);
|
|
||||||
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) {
|
|
||||||
Cell cell = heard.getCell(i);
|
|
||||||
if (StringUtils.isNotNull(cell)) {
|
|
||||||
String value = this.getCellValue(heard, i).toString();
|
|
||||||
cellMap.put(value, i);
|
|
||||||
} else {
|
|
||||||
cellMap.put(null, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 有数据时才处理 得到类的所有field.
|
|
||||||
List<Object[]> fields = this.getFields();
|
|
||||||
Map<Integer, Object[]> fieldsMap = new HashMap<Integer, Object[]>();
|
|
||||||
for (Object[] objects : fields) {
|
|
||||||
Excel attr = (Excel) objects[1];
|
|
||||||
Integer column = cellMap.get(attr.name());
|
|
||||||
if (column != null) {
|
|
||||||
fieldsMap.put(column, objects);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = titleNum + 1; i <= rows; i++) {
|
|
||||||
// 从第2行开始取数据,默认第一行是表头.
|
|
||||||
Row row = sheet.getRow(i);
|
|
||||||
// 判断当前行是否是空行
|
|
||||||
if (isRowEmpty(row)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
T entity = null;
|
|
||||||
for (Map.Entry<Integer, Object[]> entry : fieldsMap.entrySet()) {
|
|
||||||
Object val = this.getCellValue(row, entry.getKey());
|
|
||||||
|
|
||||||
// 如果不存在实例则新建.
|
|
||||||
entity = (entity == null ? clazz.newInstance() : entity);
|
|
||||||
// 从map中得到对应列的field.
|
|
||||||
Field field = (Field) entry.getValue()[0];
|
|
||||||
Excel attr = (Excel) entry.getValue()[1];
|
|
||||||
// 取得类型,并根据对象类型设置值.
|
|
||||||
Class<?> fieldType = field.getType();
|
|
||||||
if (String.class == fieldType) {
|
|
||||||
String s = Convert.toStr(val);
|
|
||||||
if (StringUtils.endsWith(s, ".0")) {
|
|
||||||
val = StringUtils.substringBefore(s, ".0");
|
|
||||||
} else {
|
|
||||||
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
|
|
||||||
if (StringUtils.isNotEmpty(dateFormat)) {
|
|
||||||
val = DateUtils.parseDateToStr(dateFormat, (Date) val);
|
|
||||||
} else {
|
|
||||||
val = Convert.toStr(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) {
|
|
||||||
val = Convert.toInt(val);
|
|
||||||
} else if (Long.TYPE == fieldType || Long.class == fieldType) {
|
|
||||||
val = Convert.toLong(val);
|
|
||||||
} else if (Double.TYPE == fieldType || Double.class == fieldType) {
|
|
||||||
val = Convert.toDouble(val);
|
|
||||||
} else if (Float.TYPE == fieldType || Float.class == fieldType) {
|
|
||||||
val = Convert.toFloat(val);
|
|
||||||
} else if (BigDecimal.class == fieldType) {
|
|
||||||
val = Convert.toBigDecimal(val);
|
|
||||||
} else if (Date.class == fieldType) {
|
|
||||||
if (val instanceof String) {
|
|
||||||
val = DateUtils.parseDate(val);
|
|
||||||
} else if (val instanceof Double) {
|
|
||||||
val = DateUtil.getJavaDate((Double) val);
|
|
||||||
}
|
|
||||||
} else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) {
|
|
||||||
val = Convert.toBool(val, false);
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotNull(fieldType)) {
|
|
||||||
String propertyName = field.getName();
|
|
||||||
if (StringUtils.isNotEmpty(attr.targetAttr())) {
|
|
||||||
propertyName = field.getName() + "." + attr.targetAttr();
|
|
||||||
} else if (StringUtils.isNotEmpty(attr.readConverterExp())) {
|
|
||||||
val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
|
|
||||||
} else if (!attr.handler().equals(ExcelHandlerAdapter.class)) {
|
|
||||||
val = dataFormatHandlerAdapter(val, attr);
|
|
||||||
}
|
|
||||||
ReflectUtils.invokeSetter(entity, propertyName, val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list.add(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
|
||||||
*
|
|
||||||
* @param response 返回数据
|
|
||||||
* @param list 导出数据集合
|
|
||||||
* @param sheetName 工作表的名称
|
|
||||||
* @return 结果
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName) {
|
|
||||||
exportExcel(response, list, sheetName, StringUtils.EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
|
||||||
*
|
|
||||||
* @param response 返回数据
|
|
||||||
* @param list 导出数据集合
|
|
||||||
* @param sheetName 工作表的名称
|
|
||||||
* @param title 标题
|
|
||||||
* @return 结果
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title) {
|
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
||||||
response.setCharacterEncoding("utf-8");
|
|
||||||
this.init(list, sheetName, title, Type.EXPORT);
|
|
||||||
exportExcel(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
|
||||||
*
|
|
||||||
* @param sheetName 工作表的名称
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
|
||||||
*
|
|
||||||
* @param sheetName 工作表的名称
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public void importTemplateExcel(HttpServletResponse response, String sheetName) {
|
|
||||||
importTemplateExcel(response, sheetName, StringUtils.EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
|
||||||
*
|
|
||||||
* @param sheetName 工作表的名称
|
|
||||||
* @param title 标题
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) {
|
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
||||||
response.setCharacterEncoding("utf-8");
|
|
||||||
this.init(null, sheetName, title, Type.IMPORT);
|
|
||||||
exportExcel(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
|
||||||
*
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public void exportExcel(HttpServletResponse response) {
|
|
||||||
try {
|
|
||||||
writeSheet();
|
|
||||||
wb.write(response.getOutputStream());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("导出Excel异常{}", e.getMessage());
|
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(wb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建写入数据到Sheet
|
|
||||||
*/
|
|
||||||
public void writeSheet() {
|
|
||||||
// 取出一共有多少个sheet.
|
|
||||||
int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize));
|
|
||||||
for (int index = 0; index < sheetNo; index++) {
|
|
||||||
createSheet(sheetNo, index);
|
|
||||||
|
|
||||||
// 产生一行
|
|
||||||
Row row = sheet.createRow(rownum);
|
|
||||||
int column = 0;
|
|
||||||
// 写入各个字段的列头名称
|
|
||||||
for (Object[] os : fields) {
|
|
||||||
Excel excel = (Excel) os[1];
|
|
||||||
this.createCell(excel, row, column++);
|
|
||||||
}
|
|
||||||
if (Type.EXPORT.equals(type)) {
|
|
||||||
fillExcelData(index, row);
|
|
||||||
addStatisticsRow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 填充excel数据
|
|
||||||
*
|
|
||||||
* @param index 序号
|
|
||||||
* @param row 单元格行
|
|
||||||
*/
|
|
||||||
public void fillExcelData(int index, Row row) {
|
|
||||||
int startNo = index * sheetSize;
|
|
||||||
int endNo = Math.min(startNo + sheetSize, list.size());
|
|
||||||
for (int i = startNo; i < endNo; i++) {
|
|
||||||
row = sheet.createRow(i + 1 + rownum - startNo);
|
|
||||||
// 得到导出对象.
|
|
||||||
T vo = (T) list.get(i);
|
|
||||||
int column = 0;
|
|
||||||
for (Object[] os : fields) {
|
|
||||||
Field field = (Field) os[0];
|
|
||||||
Excel excel = (Excel) os[1];
|
|
||||||
this.addCell(excel, row, vo, field, column++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建表格样式
|
|
||||||
*
|
|
||||||
* @param wb 工作薄对象
|
|
||||||
* @return 样式列表
|
|
||||||
*/
|
|
||||||
private Map<String, CellStyle> createStyles(Workbook wb) {
|
|
||||||
// 写入各条记录,每条记录对应excel表中的一行
|
|
||||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
|
||||||
CellStyle style = wb.createCellStyle();
|
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
||||||
Font titleFont = wb.createFont();
|
|
||||||
titleFont.setFontName("Arial");
|
|
||||||
titleFont.setFontHeightInPoints((short) 16);
|
|
||||||
titleFont.setBold(true);
|
|
||||||
style.setFont(titleFont);
|
|
||||||
styles.put("title", style);
|
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
||||||
style.setBorderRight(BorderStyle.THIN);
|
|
||||||
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
|
||||||
style.setBorderLeft(BorderStyle.THIN);
|
|
||||||
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
|
||||||
style.setBorderTop(BorderStyle.THIN);
|
|
||||||
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
|
||||||
style.setBorderBottom(BorderStyle.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(HorizontalAlignment.CENTER);
|
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
||||||
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
|
||||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
||||||
Font headerFont = wb.createFont();
|
|
||||||
headerFont.setFontName("Arial");
|
|
||||||
headerFont.setFontHeightInPoints((short) 10);
|
|
||||||
headerFont.setBold(true);
|
|
||||||
headerFont.setColor(IndexedColors.WHITE.getIndex());
|
|
||||||
style.setFont(headerFont);
|
|
||||||
styles.put("header", style);
|
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
||||||
Font totalFont = wb.createFont();
|
|
||||||
totalFont.setFontName("Arial");
|
|
||||||
totalFont.setFontHeightInPoints((short) 10);
|
|
||||||
style.setFont(totalFont);
|
|
||||||
styles.put("total", style);
|
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
|
||||||
style.cloneStyleFrom(styles.get("data"));
|
|
||||||
style.setAlignment(HorizontalAlignment.LEFT);
|
|
||||||
styles.put("data1", style);
|
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
|
||||||
style.cloneStyleFrom(styles.get("data"));
|
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
styles.put("data2", style);
|
|
||||||
|
|
||||||
style = wb.createCellStyle();
|
|
||||||
style.cloneStyleFrom(styles.get("data"));
|
|
||||||
style.setAlignment(HorizontalAlignment.RIGHT);
|
|
||||||
styles.put("data3", style);
|
|
||||||
|
|
||||||
return styles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建单元格
|
|
||||||
*/
|
|
||||||
public Cell createCell(Excel attr, Row row, int column) {
|
|
||||||
// 创建列
|
|
||||||
Cell cell = row.createCell(column);
|
|
||||||
// 写入列信息
|
|
||||||
cell.setCellValue(attr.name());
|
|
||||||
setDataValidation(attr, row, column);
|
|
||||||
cell.setCellStyle(styles.get("header"));
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置单元格信息
|
|
||||||
*
|
|
||||||
* @param value 单元格值
|
|
||||||
* @param attr 注解相关
|
|
||||||
* @param cell 单元格信息
|
|
||||||
*/
|
|
||||||
public void setCellVo(Object value, Excel attr, Cell cell) {
|
|
||||||
if (ColumnType.STRING == attr.cellType()) {
|
|
||||||
cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
|
|
||||||
} else if (ColumnType.NUMERIC == attr.cellType()) {
|
|
||||||
if (StringUtils.isNotNull(value)) {
|
|
||||||
cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
|
|
||||||
}
|
|
||||||
} else if (ColumnType.IMAGE == attr.cellType()) {
|
|
||||||
ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1);
|
|
||||||
String imagePath = Convert.toStr(value);
|
|
||||||
if (StringUtils.isNotEmpty(imagePath)) {
|
|
||||||
byte[] data = ImageUtils.getImage(imagePath);
|
|
||||||
getDrawingPatriarch(cell.getSheet()).createPicture(anchor,
|
|
||||||
cell.getSheet().getWorkbook().addPicture(data, getImageType(data)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取画布
|
|
||||||
*/
|
|
||||||
public static Drawing<?> getDrawingPatriarch(Sheet sheet) {
|
|
||||||
if (sheet.getDrawingPatriarch() == null) {
|
|
||||||
sheet.createDrawingPatriarch();
|
|
||||||
}
|
|
||||||
return sheet.getDrawingPatriarch();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取图片类型,设置图片插入类型
|
|
||||||
*/
|
|
||||||
public int getImageType(byte[] value) {
|
|
||||||
String type = FileTypeUtils.getFileExtendName(value);
|
|
||||||
if ("JPG".equalsIgnoreCase(type)) {
|
|
||||||
return Workbook.PICTURE_TYPE_JPEG;
|
|
||||||
} else if ("PNG".equalsIgnoreCase(type)) {
|
|
||||||
return Workbook.PICTURE_TYPE_PNG;
|
|
||||||
}
|
|
||||||
return Workbook.PICTURE_TYPE_JPEG;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建表格样式
|
|
||||||
*/
|
|
||||||
public void setDataValidation(Excel attr, Row row, int column) {
|
|
||||||
if (attr.name().indexOf("注:") >= 0) {
|
|
||||||
sheet.setColumnWidth(column, 6000);
|
|
||||||
} else {
|
|
||||||
// 设置列宽
|
|
||||||
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
|
|
||||||
}
|
|
||||||
// 如果设置了提示信息则鼠标放上去提示.
|
|
||||||
if (StringUtils.isNotEmpty(attr.prompt())) {
|
|
||||||
// 这里默认设了2-101列提示.
|
|
||||||
setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
|
|
||||||
}
|
|
||||||
// 如果设置了combo属性则本列只能选择不能输入
|
|
||||||
if (attr.combo().length > 0) {
|
|
||||||
// 这里默认设了2-101列只能选择不能输入.
|
|
||||||
setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加单元格
|
|
||||||
*/
|
|
||||||
public Cell addCell(Excel attr, Row row, T vo, Field field, int column) {
|
|
||||||
Cell cell = null;
|
|
||||||
try {
|
|
||||||
// 设置行高
|
|
||||||
row.setHeight(maxHeight);
|
|
||||||
// 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
|
|
||||||
if (attr.isExport()) {
|
|
||||||
// 创建cell
|
|
||||||
cell = row.createCell(column);
|
|
||||||
int align = attr.align().value();
|
|
||||||
cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
|
|
||||||
|
|
||||||
// 用于读取对象中的属性
|
|
||||||
Object value = getTargetValue(vo, field, attr);
|
|
||||||
String dateFormat = attr.dateFormat();
|
|
||||||
String readConverterExp = attr.readConverterExp();
|
|
||||||
String separator = attr.separator();
|
|
||||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) {
|
|
||||||
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
|
||||||
} else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) {
|
|
||||||
cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
|
|
||||||
} else if (value instanceof BigDecimal && -1 != attr.scale()) {
|
|
||||||
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
|
|
||||||
} else if (!attr.handler().equals(ExcelHandlerAdapter.class)) {
|
|
||||||
cell.setCellValue(dataFormatHandlerAdapter(value, attr));
|
|
||||||
} else {
|
|
||||||
// 设置列类型
|
|
||||||
setCellVo(value, attr, cell);
|
|
||||||
}
|
|
||||||
addStatisticsData(column, Convert.toStr(value), attr);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("导出Excel失败{}", e);
|
|
||||||
}
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置 POI XSSFSheet 单元格提示
|
|
||||||
*
|
|
||||||
* @param sheet 表单
|
|
||||||
* @param promptTitle 提示标题
|
|
||||||
* @param promptContent 提示内容
|
|
||||||
* @param firstRow 开始行
|
|
||||||
* @param endRow 结束行
|
|
||||||
* @param firstCol 开始列
|
|
||||||
* @param endCol 结束列
|
|
||||||
*/
|
|
||||||
public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
|
|
||||||
int firstCol, int endCol) {
|
|
||||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
|
||||||
DataValidationConstraint constraint = helper.createCustomConstraint("DD1");
|
|
||||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
|
||||||
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
|
||||||
dataValidation.createPromptBox(promptTitle, promptContent);
|
|
||||||
dataValidation.setShowPromptBox(true);
|
|
||||||
sheet.addValidationData(dataValidation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置某些列的值只能输入预制的数据,显示下拉框.
|
|
||||||
*
|
|
||||||
* @param sheet 要设置的sheet.
|
|
||||||
* @param textlist 下拉框显示的内容
|
|
||||||
* @param firstRow 开始行
|
|
||||||
* @param endRow 结束行
|
|
||||||
* @param firstCol 开始列
|
|
||||||
* @param endCol 结束列
|
|
||||||
* @return 设置好的sheet.
|
|
||||||
*/
|
|
||||||
public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) {
|
|
||||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
|
||||||
// 加载下拉列表内容
|
|
||||||
DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist);
|
|
||||||
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
|
|
||||||
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
|
||||||
// 数据有效性对象
|
|
||||||
DataValidation dataValidation = helper.createValidation(constraint, regions);
|
|
||||||
// 处理Excel兼容性问题
|
|
||||||
if (dataValidation instanceof XSSFDataValidation) {
|
|
||||||
dataValidation.setSuppressDropDownArrow(true);
|
|
||||||
dataValidation.setShowErrorBox(true);
|
|
||||||
} else {
|
|
||||||
dataValidation.setSuppressDropDownArrow(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
sheet.addValidationData(dataValidation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析导出值 0=男,1=女,2=未知
|
|
||||||
*
|
|
||||||
* @param propertyValue 参数值
|
|
||||||
* @param converterExp 翻译注解
|
|
||||||
* @param separator 分隔符
|
|
||||||
* @return 解析后值
|
|
||||||
*/
|
|
||||||
public static String convertByExp(String propertyValue, String converterExp, String separator) {
|
|
||||||
StringBuilder propertyString = new StringBuilder();
|
|
||||||
String[] convertSource = converterExp.split(",");
|
|
||||||
for (String item : convertSource) {
|
|
||||||
String[] itemArray = item.split("=");
|
|
||||||
if (StringUtils.containsAny(separator, propertyValue)) {
|
|
||||||
for (String value : propertyValue.split(separator)) {
|
|
||||||
if (itemArray[0].equals(value)) {
|
|
||||||
propertyString.append(itemArray[1] + separator);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (itemArray[0].equals(propertyValue)) {
|
|
||||||
return itemArray[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 反向解析值 男=0,女=1,未知=2
|
|
||||||
*
|
|
||||||
* @param propertyValue 参数值
|
|
||||||
* @param converterExp 翻译注解
|
|
||||||
* @param separator 分隔符
|
|
||||||
* @return 解析后值
|
|
||||||
*/
|
|
||||||
public static String reverseByExp(String propertyValue, String converterExp, String separator) {
|
|
||||||
StringBuilder propertyString = new StringBuilder();
|
|
||||||
String[] convertSource = converterExp.split(",");
|
|
||||||
for (String item : convertSource) {
|
|
||||||
String[] itemArray = item.split("=");
|
|
||||||
if (StringUtils.containsAny(separator, propertyValue)) {
|
|
||||||
for (String value : propertyValue.split(separator)) {
|
|
||||||
if (itemArray[1].equals(value)) {
|
|
||||||
propertyString.append(itemArray[0] + separator);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (itemArray[1].equals(propertyValue)) {
|
|
||||||
return itemArray[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据处理器
|
|
||||||
*
|
|
||||||
* @param value 数据值
|
|
||||||
* @param excel 数据注解
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String dataFormatHandlerAdapter(Object value, Excel excel) {
|
|
||||||
try {
|
|
||||||
Object instance = excel.handler().newInstance();
|
|
||||||
Method formatMethod = excel.handler().getMethod("format", new Class[]{Object.class, String[].class});
|
|
||||||
value = formatMethod.invoke(instance, value, excel.args());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("不能格式化数据 " + excel.handler(), e.getMessage());
|
|
||||||
}
|
|
||||||
return Convert.toStr(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 合计统计信息
|
|
||||||
*/
|
|
||||||
private void addStatisticsData(Integer index, String text, Excel entity) {
|
|
||||||
if (entity != null && entity.isStatistics()) {
|
|
||||||
Double temp = 0D;
|
|
||||||
if (!statistics.containsKey(index)) {
|
|
||||||
statistics.put(index, temp);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
temp = Double.valueOf(text);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
statistics.put(index, statistics.get(index) + temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建统计行
|
|
||||||
*/
|
|
||||||
public void addStatisticsRow() {
|
|
||||||
if (statistics.size() > 0) {
|
|
||||||
Row row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
||||||
Set<Integer> keys = statistics.keySet();
|
|
||||||
Cell cell = row.createCell(0);
|
|
||||||
cell.setCellStyle(styles.get("total"));
|
|
||||||
cell.setCellValue("合计");
|
|
||||||
|
|
||||||
for (Integer key : keys) {
|
|
||||||
cell = row.createCell(key);
|
|
||||||
cell.setCellStyle(styles.get("total"));
|
|
||||||
cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key)));
|
|
||||||
}
|
|
||||||
statistics.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取bean中的属性值
|
|
||||||
*
|
|
||||||
* @param vo 实体对象
|
|
||||||
* @param field 字段
|
|
||||||
* @param excel 注解
|
|
||||||
* @return 最终的属性值
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
private Object getTargetValue(T vo, Field field, Excel excel) throws Exception {
|
|
||||||
Object o = field.get(vo);
|
|
||||||
if (StringUtils.isNotEmpty(excel.targetAttr())) {
|
|
||||||
String target = excel.targetAttr();
|
|
||||||
if (target.indexOf(".") > -1) {
|
|
||||||
String[] targets = target.split("[.]");
|
|
||||||
for (String name : targets) {
|
|
||||||
o = getValue(o, name);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
o = getValue(o, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 以类的属性的get方法方法形式获取值
|
|
||||||
*
|
|
||||||
* @param o
|
|
||||||
* @param name
|
|
||||||
* @return value
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
private Object getValue(Object o, String name) throws Exception {
|
|
||||||
if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) {
|
|
||||||
Class<?> clazz = o.getClass();
|
|
||||||
Field field = clazz.getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
o = field.get(o);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 得到所有定义字段
|
|
||||||
*/
|
|
||||||
private void createExcelField() {
|
|
||||||
this.fields = getFields();
|
|
||||||
this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList());
|
|
||||||
this.maxHeight = getRowHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字段注解信息
|
|
||||||
*/
|
|
||||||
public List<Object[]> getFields() {
|
|
||||||
List<Object[]> fields = new ArrayList<Object[]>();
|
|
||||||
List<Field> tempFields = new ArrayList<>();
|
|
||||||
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
|
|
||||||
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
|
||||||
for (Field field : tempFields) {
|
|
||||||
// 单注解
|
|
||||||
if (field.isAnnotationPresent(Excel.class)) {
|
|
||||||
Excel attr = field.getAnnotation(Excel.class);
|
|
||||||
if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
fields.add(new Object[]{field, attr});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 多注解
|
|
||||||
if (field.isAnnotationPresent(Excels.class)) {
|
|
||||||
Excels attrs = field.getAnnotation(Excels.class);
|
|
||||||
Excel[] excels = attrs.value();
|
|
||||||
for (Excel attr : excels) {
|
|
||||||
if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
fields.add(new Object[]{field, attr});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据注解获取最大行高
|
|
||||||
*/
|
|
||||||
public short getRowHeight() {
|
|
||||||
double maxHeight = 0;
|
|
||||||
for (Object[] os : this.fields) {
|
|
||||||
Excel excel = (Excel) os[1];
|
|
||||||
maxHeight = maxHeight > excel.height() ? maxHeight : excel.height();
|
|
||||||
}
|
|
||||||
return (short) (maxHeight * 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建一个工作簿
|
|
||||||
*/
|
|
||||||
public void createWorkbook() {
|
|
||||||
this.wb = new SXSSFWorkbook(500);
|
|
||||||
this.sheet = wb.createSheet();
|
|
||||||
wb.setSheetName(0, sheetName);
|
|
||||||
this.styles = createStyles(wb);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建工作表
|
|
||||||
*
|
|
||||||
* @param sheetNo sheet数量
|
|
||||||
* @param index 序号
|
|
||||||
*/
|
|
||||||
public void createSheet(int sheetNo, int index) {
|
|
||||||
// 设置工作表的名称.
|
|
||||||
if (sheetNo > 1 && index > 0) {
|
|
||||||
this.sheet = wb.createSheet();
|
|
||||||
this.createTitle();
|
|
||||||
wb.setSheetName(index, sheetName + index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单元格值
|
|
||||||
*
|
|
||||||
* @param row 获取的行
|
|
||||||
* @param column 获取单元格列号
|
|
||||||
* @return 单元格值
|
|
||||||
*/
|
|
||||||
public Object getCellValue(Row row, int column) {
|
|
||||||
if (row == null) {
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
Object val = "";
|
|
||||||
try {
|
|
||||||
Cell cell = row.getCell(column);
|
|
||||||
if (StringUtils.isNotNull(cell)) {
|
|
||||||
if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) {
|
|
||||||
val = cell.getNumericCellValue();
|
|
||||||
if (DateUtil.isCellDateFormatted(cell)) {
|
|
||||||
val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
|
|
||||||
} else {
|
|
||||||
if ((Double) val % 1 != 0) {
|
|
||||||
val = new BigDecimal(val.toString());
|
|
||||||
} else {
|
|
||||||
val = new DecimalFormat("0").format(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (cell.getCellType() == CellType.STRING) {
|
|
||||||
val = cell.getStringCellValue();
|
|
||||||
} else if (cell.getCellType() == CellType.BOOLEAN) {
|
|
||||||
val = cell.getBooleanCellValue();
|
|
||||||
} else if (cell.getCellType() == CellType.ERROR) {
|
|
||||||
val = cell.getErrorCellValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否是空行
|
|
||||||
*
|
|
||||||
* @param row 判断的行
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean isRowEmpty(Row row) {
|
|
||||||
if (row == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) {
|
|
||||||
Cell cell = row.getCell(i);
|
|
||||||
if (cell != null && cell.getCellType() != CellType.BLANK) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,22 +2,26 @@ package com.ruoyi.common.core.utils.sql;
|
||||||
|
|
||||||
import com.ruoyi.common.core.exception.UtilException;
|
import com.ruoyi.common.core.exception.UtilException;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sql操作工具类
|
* sql操作工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class SqlUtil {
|
public class SqlUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定义常用的 sql关键字
|
* 定义常用的 sql关键字
|
||||||
*/
|
*/
|
||||||
public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
|
public static final String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
||||||
*/
|
*/
|
||||||
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
|
public static final String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查字符,防止注入绕过
|
* 检查字符,防止注入绕过
|
||||||
|
|
@ -44,8 +48,8 @@ public class SqlUtil {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
||||||
for (int i = 0; i < sqlKeywords.length; i++) {
|
for (String sqlKeyword : sqlKeywords) {
|
||||||
if (StringUtils.indexOfIgnoreCase(value, sqlKeywords[i]) > -1) {
|
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) {
|
||||||
throw new UtilException("参数存在SQL注入风险");
|
throw new UtilException("参数存在SQL注入风险");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.common.core.web.domain;
|
package com.ruoyi.common.core.web.domain;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.HttpStatus;
|
import com.ruoyi.common.core.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ public class AjaxResult extends HashMap<String, Object> {
|
||||||
public AjaxResult(int code, String msg, Object data) {
|
public AjaxResult(int code, String msg, Object data) {
|
||||||
super.put(CODE_TAG, code);
|
super.put(CODE_TAG, code);
|
||||||
super.put(MSG_TAG, msg);
|
super.put(MSG_TAG, msg);
|
||||||
if (StringUtils.isNotNull(data)) {
|
if (ObjectUtil.isNotNull(data)) {
|
||||||
super.put(DATA_TAG, data);
|
super.put(DATA_TAG, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.common.core.web.domain;
|
package com.ruoyi.common.core.web.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -10,52 +12,49 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Entity基类
|
* Entity基类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
public class BaseEntity implements Serializable {
|
public class BaseEntity implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索值
|
* 搜索值
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "搜索值")
|
||||||
private String searchValue;
|
private String searchValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建者
|
* 创建者
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "创建者")
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新者
|
* 更新者
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "更新者")
|
||||||
private String updateBy;
|
private String updateBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求参数
|
* 请求参数
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> params;
|
@ApiModelProperty(value = "请求参数")
|
||||||
|
private Map<String, Object> params = new HashMap<>();
|
||||||
public Map<String, Object> getParams() {
|
|
||||||
if (params == null) {
|
|
||||||
params = new HashMap<>();
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.ruoyi.common.core.web.domain;
|
package com.ruoyi.common.core.web.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -9,36 +11,32 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Tree基类
|
* Tree基类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
public class TreeEntity extends BaseEntity {
|
public class TreeEntity extends BaseEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父菜单名称
|
* 父菜单名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "父菜单名称")
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父菜单ID
|
* 父菜单ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "父菜单ID")
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示顺序
|
|
||||||
*/
|
|
||||||
private Integer orderNum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 祖级列表
|
|
||||||
*/
|
|
||||||
private String ancestors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子部门
|
* 子部门
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "子部门")
|
||||||
private List<?> children = new ArrayList<>();
|
private List<?> children = new ArrayList<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.common.core.web.page;
|
package com.ruoyi.common.core.web.page;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ public class PageDomain {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getReasonable() {
|
public Boolean getReasonable() {
|
||||||
if (StringUtils.isNull(reasonable)) {
|
if (ObjectUtil.isNull(reasonable)) {
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
return reasonable;
|
return reasonable;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.ruoyi.common.core.utils.SpringUtils,\
|
com.ruoyi.common.core.utils.SpringUtils,\
|
||||||
com.ruoyi.common.core.config.JacksonConfig
|
com.ruoyi.common.core.config.JacksonConfig,\
|
||||||
|
com.ruoyi.common.core.config.ValidatorConfig
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.common.datascope.aspect;
|
package com.ruoyi.common.datascope.aspect;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||||
|
|
@ -59,10 +60,10 @@ public class DataScopeAspect {
|
||||||
protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope) {
|
protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope) {
|
||||||
// 获取当前的用户
|
// 获取当前的用户
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (StringUtils.isNotNull(loginUser)) {
|
if (ObjectUtil.isNotNull(loginUser)) {
|
||||||
SysUser currentUser = loginUser.getSysUser();
|
SysUser currentUser = loginUser.getSysUser();
|
||||||
// 如果是超级管理员,则不过滤数据
|
// 如果是超级管理员,则不过滤数据
|
||||||
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) {
|
if (ObjectUtil.isNotNull(currentUser) && !currentUser.isAdmin()) {
|
||||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
||||||
controllerDataScope.userAlias());
|
controllerDataScope.userAlias());
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +108,7 @@ public class DataScopeAspect {
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(sqlString.toString())) {
|
if (StringUtils.isNotBlank(sqlString.toString())) {
|
||||||
Object params = joinPoint.getArgs()[0];
|
Object params = joinPoint.getArgs()[0];
|
||||||
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
|
if (ObjectUtil.isNotNull(params) && params instanceof BaseEntity) {
|
||||||
BaseEntity baseEntity = (BaseEntity) params;
|
BaseEntity baseEntity = (BaseEntity) params;
|
||||||
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +120,7 @@ public class DataScopeAspect {
|
||||||
*/
|
*/
|
||||||
private void clearDataScope(final JoinPoint joinPoint) {
|
private void clearDataScope(final JoinPoint joinPoint) {
|
||||||
Object params = joinPoint.getArgs()[0];
|
Object params = joinPoint.getArgs()[0];
|
||||||
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
|
if (ObjectUtil.isNotNull(params) && params instanceof BaseEntity) {
|
||||||
BaseEntity baseEntity = (BaseEntity) params;
|
BaseEntity baseEntity = (BaseEntity) params;
|
||||||
baseEntity.getParams().put(DATA_SCOPE, "");
|
baseEntity.getParams().put(DATA_SCOPE, "");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.ruoyi.common.dict.service.impl;
|
package com.ruoyi.common.dict.service.impl;
|
||||||
|
|
||||||
import com.ruoyi.common.dict.service.DictService;
|
import com.ruoyi.common.core.service.DictService;
|
||||||
import com.ruoyi.system.api.RemoteDictService;
|
import com.ruoyi.system.api.RemoteDictService;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.ruoyi.common.dict.utils;
|
package com.ruoyi.common.dict.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.system.api.domain.SysDictData;
|
import com.ruoyi.system.api.domain.SysDictData;
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class DictUtils {
|
||||||
*/
|
*/
|
||||||
public static List<SysDictData> getDictCache(String key) {
|
public static List<SysDictData> getDictCache(String key) {
|
||||||
List<SysDictData> dictDatas = RedisUtils.getCacheObject(getCacheKey(key));
|
List<SysDictData> dictDatas = RedisUtils.getCacheObject(getCacheKey(key));
|
||||||
if (StringUtils.isNotNull(dictDatas)) {
|
if (ObjectUtil.isNotNull(dictDatas)) {
|
||||||
return dictDatas;
|
return dictDatas;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common</artifactId>
|
||||||
|
<version>0.3.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-common-excel</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
ruoyi-common-excel
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- excel工具 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.ruoyi.common.excel.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典格式化
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Inherited
|
||||||
|
public @interface ExcelDictFormat {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||||
|
*/
|
||||||
|
String dictType() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||||
|
*/
|
||||||
|
String readConverterExp() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分隔符,读取字符串组内容
|
||||||
|
*/
|
||||||
|
String separator() default ",";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.ruoyi.common.excel.convert;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.excel.converters.Converter;
|
||||||
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||||
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
|
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||||
|
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||||
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大数值转换
|
||||||
|
* Excel 数值长度位15位 大于15位的数值转换位字符串
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class ExcelBigNumberConvert implements Converter<Long> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Long> supportJavaTypeKey() {
|
||||||
|
return Long.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellDataTypeEnum supportExcelTypeKey() {
|
||||||
|
return CellDataTypeEnum.STRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
|
return Convert.toLong(cellData.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WriteCellData<Object> convertToExcelData(Long object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
|
if (ObjectUtil.isNotNull(object)) {
|
||||||
|
String str = Convert.toStr(object);
|
||||||
|
if (str.length() > 15) {
|
||||||
|
return new WriteCellData<>(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WriteCellData<Object> cellData = new WriteCellData<>(new BigDecimal(object));
|
||||||
|
cellData.setType(CellDataTypeEnum.NUMBER);
|
||||||
|
return cellData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.ruoyi.common.excel.convert;
|
||||||
|
|
||||||
|
import cn.hutool.core.annotation.AnnotationUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.excel.converters.Converter;
|
||||||
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||||
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||||
|
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||||
|
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||||
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||||
|
import com.ruoyi.common.core.service.DictService;
|
||||||
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典格式化转换处理
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class ExcelDictConvert implements Converter<Object> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Object> supportJavaTypeKey() {
|
||||||
|
return Object.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellDataTypeEnum supportExcelTypeKey() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
|
ExcelDictFormat anno = getAnnotation(contentProperty.getField());
|
||||||
|
String type = anno.dictType();
|
||||||
|
String label = cellData.getStringValue();
|
||||||
|
String value;
|
||||||
|
if (StringUtils.isBlank(type)) {
|
||||||
|
value = ExcelUtil.reverseByExp(label, anno.readConverterExp(), anno.separator());
|
||||||
|
} else {
|
||||||
|
value = SpringUtils.getBean(DictService.class).getDictValue(type, label, anno.separator());
|
||||||
|
}
|
||||||
|
return Convert.convert(contentProperty.getField().getType(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WriteCellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||||
|
if (ObjectUtil.isNull(object)) {
|
||||||
|
return new WriteCellData<>("");
|
||||||
|
}
|
||||||
|
ExcelDictFormat anno = getAnnotation(contentProperty.getField());
|
||||||
|
String type = anno.dictType();
|
||||||
|
String value = Convert.toStr(object);
|
||||||
|
String label;
|
||||||
|
if (StringUtils.isBlank(type)) {
|
||||||
|
label = ExcelUtil.convertByExp(value, anno.readConverterExp(), anno.separator());
|
||||||
|
} else {
|
||||||
|
label = SpringUtils.getBean(DictService.class).getDictLabel(type, value, anno.separator());
|
||||||
|
}
|
||||||
|
return new WriteCellData<>(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExcelDictFormat getAnnotation(Field field) {
|
||||||
|
return AnnotationUtil.getAnnotation(field, ExcelDictFormat.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.ruoyi.common.excel.core;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.alibaba.excel.exception.ExcelAnalysisException;
|
||||||
|
import com.alibaba.excel.exception.ExcelDataConvertException;
|
||||||
|
import com.ruoyi.common.core.utils.JsonUtils;
|
||||||
|
import com.ruoyi.common.core.utils.ValidatorUtils;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel 导入监听
|
||||||
|
*
|
||||||
|
* @author Yjoioooo
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements ExcelListener<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否Validator检验,默认为是
|
||||||
|
*/
|
||||||
|
private Boolean isValidate = Boolean.TRUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* excel 表头数据
|
||||||
|
*/
|
||||||
|
private Map<Integer, String> headMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入回执
|
||||||
|
*/
|
||||||
|
private ExcelResult<T> excelResult;
|
||||||
|
|
||||||
|
public DefaultExcelListener(boolean isValidate) {
|
||||||
|
this.excelResult = new DefautExcelResult<>();
|
||||||
|
this.isValidate = isValidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理异常
|
||||||
|
*
|
||||||
|
* @param exception ExcelDataConvertException
|
||||||
|
* @param context Excel 上下文
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onException(Exception exception, AnalysisContext context) throws Exception {
|
||||||
|
String errMsg = null;
|
||||||
|
if (exception instanceof ExcelDataConvertException) {
|
||||||
|
// 如果是某一个单元格的转换异常 能获取到具体行号
|
||||||
|
ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception;
|
||||||
|
Integer rowIndex = excelDataConvertException.getRowIndex();
|
||||||
|
Integer columnIndex = excelDataConvertException.getColumnIndex();
|
||||||
|
errMsg = StrUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
|
||||||
|
rowIndex + 1, columnIndex + 1, headMap.get(columnIndex));
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.error(errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (exception instanceof ConstraintViolationException) {
|
||||||
|
ConstraintViolationException constraintViolationException = (ConstraintViolationException) exception;
|
||||||
|
Set<ConstraintViolation<?>> constraintViolations = constraintViolationException.getConstraintViolations();
|
||||||
|
String constraintViolationsMsg = constraintViolations.stream()
|
||||||
|
.map(ConstraintViolation::getMessage)
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
|
errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.error(errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
excelResult.getErrorList().add(errMsg);
|
||||||
|
throw new ExcelAnalysisException(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
|
||||||
|
this.headMap = headMap;
|
||||||
|
log.debug("解析到一条表头数据: {}", JsonUtils.toJsonString(headMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(T data, AnalysisContext context) {
|
||||||
|
if (isValidate) {
|
||||||
|
ValidatorUtils.validate(data);
|
||||||
|
}
|
||||||
|
excelResult.getList().add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||||
|
log.debug("所有数据解析完成!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExcelResult<T> getExcelResult() {
|
||||||
|
return excelResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.ruoyi.common.excel.core;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认excel返回对象
|
||||||
|
*
|
||||||
|
* @author Yjoioooo
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public class DefautExcelResult<T> implements ExcelResult<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据对象list
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private List<T> list;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误信息列表
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private List<String> errorList;
|
||||||
|
|
||||||
|
public DefautExcelResult() {
|
||||||
|
this.list = new ArrayList<>();
|
||||||
|
this.errorList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefautExcelResult(List<T> list, List<String> errorList) {
|
||||||
|
this.list = list;
|
||||||
|
this.errorList = errorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefautExcelResult(ExcelResult<T> excelResult) {
|
||||||
|
this.list = excelResult.getList();
|
||||||
|
this.errorList = excelResult.getErrorList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getErrorList() {
|
||||||
|
return errorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取导入回执
|
||||||
|
*
|
||||||
|
* @return 导入回执
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getAnalysis() {
|
||||||
|
int successCount = list.size();
|
||||||
|
int errorCount = errorList.size();
|
||||||
|
if (successCount == 0) {
|
||||||
|
return "读取失败,未解析到数据";
|
||||||
|
} else {
|
||||||
|
if (errorCount == 0) {
|
||||||
|
return StrUtil.format("恭喜您,全部读取成功!共{}条", successCount);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.ruoyi.common.excel.core;
|
||||||
|
|
||||||
|
import com.alibaba.excel.read.listener.ReadListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel 导入监听
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public interface ExcelListener<T> extends ReadListener<T> {
|
||||||
|
|
||||||
|
ExcelResult<T> getExcelResult();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.ruoyi.common.excel.core;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* excel返回对象
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
public interface ExcelResult<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象列表
|
||||||
|
*/
|
||||||
|
List<T> getList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误列表
|
||||||
|
*/
|
||||||
|
List<String> getErrorList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入回执
|
||||||
|
*/
|
||||||
|
String getAnalysis();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,158 @@
|
||||||
|
package com.ruoyi.common.excel.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelBigNumberConvert;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.file.FileUtils;
|
||||||
|
import com.ruoyi.common.excel.core.DefaultExcelListener;
|
||||||
|
import com.ruoyi.common.excel.core.ExcelListener;
|
||||||
|
import com.ruoyi.common.excel.core.ExcelResult;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel相关处理
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public class ExcelUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步导入(适用于小数据量)
|
||||||
|
*
|
||||||
|
* @param is 输入流
|
||||||
|
* @return 转换后集合
|
||||||
|
*/
|
||||||
|
public static <T> List<T> importExcel(InputStream is, Class<T> clazz) {
|
||||||
|
return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet().doReadSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用校验监听器 异步导入 同步返回
|
||||||
|
*
|
||||||
|
* @param is 输入流
|
||||||
|
* @param clazz 对象类型
|
||||||
|
* @param isValidate 是否 Validator 检验 默认为是
|
||||||
|
* @return 转换后集合
|
||||||
|
*/
|
||||||
|
public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, boolean isValidate) {
|
||||||
|
DefaultExcelListener<T> listener = new DefaultExcelListener<>(isValidate);
|
||||||
|
EasyExcel.read(is, clazz, listener).sheet().doRead();
|
||||||
|
return listener.getExcelResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用自定义监听器 异步导入 自定义返回
|
||||||
|
*
|
||||||
|
* @param is 输入流
|
||||||
|
* @param clazz 对象类型
|
||||||
|
* @param listener 自定义监听器
|
||||||
|
* @return 转换后集合
|
||||||
|
*/
|
||||||
|
public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, ExcelListener<T> listener) {
|
||||||
|
EasyExcel.read(is, clazz, listener).sheet().doRead();
|
||||||
|
return listener.getExcelResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param list 导出数据集合
|
||||||
|
* @param sheetName 工作表的名称
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
String filename = encodingFilename(sheetName);
|
||||||
|
response.reset();
|
||||||
|
FileUtils.setAttachmentResponseHeader(response, filename);
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
|
||||||
|
ServletOutputStream os = response.getOutputStream();
|
||||||
|
EasyExcel.write(os, clazz)
|
||||||
|
.autoCloseStream(false)
|
||||||
|
// 自动适配
|
||||||
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||||
|
// 大数值自动转换 防止失真
|
||||||
|
.registerConverter(new ExcelBigNumberConvert())
|
||||||
|
.sheet(sheetName).doWrite(list);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("导出Excel异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析导出值 0=男,1=女,2=未知
|
||||||
|
*
|
||||||
|
* @param propertyValue 参数值
|
||||||
|
* @param converterExp 翻译注解
|
||||||
|
* @param separator 分隔符
|
||||||
|
* @return 解析后值
|
||||||
|
*/
|
||||||
|
public static String convertByExp(String propertyValue, String converterExp, String separator) {
|
||||||
|
StringBuilder propertyString = new StringBuilder();
|
||||||
|
String[] convertSource = converterExp.split(",");
|
||||||
|
for (String item : convertSource) {
|
||||||
|
String[] itemArray = item.split("=");
|
||||||
|
if (StringUtils.containsAny(separator, propertyValue)) {
|
||||||
|
for (String value : propertyValue.split(separator)) {
|
||||||
|
if (itemArray[0].equals(value)) {
|
||||||
|
propertyString.append(itemArray[1] + separator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (itemArray[0].equals(propertyValue)) {
|
||||||
|
return itemArray[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反向解析值 男=0,女=1,未知=2
|
||||||
|
*
|
||||||
|
* @param propertyValue 参数值
|
||||||
|
* @param converterExp 翻译注解
|
||||||
|
* @param separator 分隔符
|
||||||
|
* @return 解析后值
|
||||||
|
*/
|
||||||
|
public static String reverseByExp(String propertyValue, String converterExp, String separator) {
|
||||||
|
StringBuilder propertyString = new StringBuilder();
|
||||||
|
String[] convertSource = converterExp.split(",");
|
||||||
|
for (String item : convertSource) {
|
||||||
|
String[] itemArray = item.split("=");
|
||||||
|
if (StringUtils.containsAny(separator, propertyValue)) {
|
||||||
|
for (String value : propertyValue.split(separator)) {
|
||||||
|
if (itemArray[1].equals(value)) {
|
||||||
|
propertyString.append(itemArray[0] + separator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (itemArray[1].equals(propertyValue)) {
|
||||||
|
return itemArray[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编码文件名
|
||||||
|
*/
|
||||||
|
public static String encodingFilename(String filename) {
|
||||||
|
return IdUtil.fastSimpleUUID() + "_" + filename + ".xlsx";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package com.ruoyi.common.log.aspect;
|
package com.ruoyi.common.log.aspect;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.utils.JsonUtils;
|
import com.ruoyi.common.core.utils.JsonUtils;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.ip.IpUtils;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessStatus;
|
import com.ruoyi.common.log.enums.BusinessStatus;
|
||||||
import com.ruoyi.common.log.service.AsyncLogService;
|
import com.ruoyi.common.log.service.AsyncLogService;
|
||||||
|
|
@ -65,8 +65,7 @@ public class LogAspect {
|
||||||
SysOperLog operLog = new SysOperLog();
|
SysOperLog operLog = new SysOperLog();
|
||||||
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
||||||
// 请求的地址
|
// 请求的地址
|
||||||
String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
|
operLog.setOperIp(ServletUtils.getClientIP());
|
||||||
operLog.setOperIp(ip);
|
|
||||||
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
|
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
|
||||||
String username = SecurityUtils.getUsername();
|
String username = SecurityUtils.getUsername();
|
||||||
if (StringUtils.isNotBlank(username)) {
|
if (StringUtils.isNotBlank(username)) {
|
||||||
|
|
@ -115,7 +114,7 @@ public class LogAspect {
|
||||||
setRequestValue(joinPoint, operLog);
|
setRequestValue(joinPoint, operLog);
|
||||||
}
|
}
|
||||||
// 是否需要保存response,参数和值
|
// 是否需要保存response,参数和值
|
||||||
if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) {
|
if (log.isSaveResponseData() && ObjectUtil.isNotNull(jsonResult)) {
|
||||||
operLog.setJsonResult(StringUtils.substring(JsonUtils.toJsonString(jsonResult), 0, 2000));
|
operLog.setJsonResult(StringUtils.substring(JsonUtils.toJsonString(jsonResult), 0, 2000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +140,7 @@ public class LogAspect {
|
||||||
StringBuilder params = new StringBuilder();
|
StringBuilder params = new StringBuilder();
|
||||||
if (paramsArray != null && paramsArray.length > 0) {
|
if (paramsArray != null && paramsArray.length > 0) {
|
||||||
for (Object o : paramsArray) {
|
for (Object o : paramsArray) {
|
||||||
if (StringUtils.isNotNull(o) && !isFilterObject(o)) {
|
if (ObjectUtil.isNotNull(o) && !isFilterObject(o)) {
|
||||||
try {
|
try {
|
||||||
params.append(JsonUtils.toJsonString(o)).append(" ");
|
params.append(JsonUtils.toJsonString(o)).append(" ");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,17 @@
|
||||||
<groupId>com.esotericsoftware</groupId>
|
<groupId>com.esotericsoftware</groupId>
|
||||||
<artifactId>kryo</artifactId>
|
<artifactId>kryo</artifactId>
|
||||||
<version>4.0.2</version>
|
<version>4.0.2</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>asm</artifactId>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.javakaffee</groupId>
|
<groupId>de.javakaffee</groupId>
|
||||||
<artifactId>kryo-serializers</artifactId>
|
<artifactId>kryo-serializers</artifactId>
|
||||||
<version>0.45</version>
|
<version>0.43</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-api-system</artifactId>
|
<artifactId>ruoyi-api-system</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- RuoYi Common Redis-->
|
<!-- RuoYi Common Redis-->
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
package com.ruoyi.common.security.handler;
|
package com.ruoyi.common.security.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.HttpStatus;
|
import com.ruoyi.common.core.constant.HttpStatus;
|
||||||
import com.ruoyi.common.core.exception.DemoModeException;
|
import com.ruoyi.common.core.exception.DemoModeException;
|
||||||
import com.ruoyi.common.core.exception.InnerAuthException;
|
import com.ruoyi.common.core.exception.InnerAuthException;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.exception.auth.NotPermissionException;
|
import com.ruoyi.common.core.exception.auth.NotPermissionException;
|
||||||
import com.ruoyi.common.core.exception.auth.NotRoleException;
|
import com.ruoyi.common.core.exception.auth.NotRoleException;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
|
|
@ -64,7 +64,7 @@ public class GlobalExceptionHandler {
|
||||||
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
|
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
Integer code = e.getCode();
|
Integer code = e.getCode();
|
||||||
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
return ObjectUtil.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.common.security.interceptor;
|
package com.ruoyi.common.security.interceptor;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.context.SecurityContextHolder;
|
import com.ruoyi.common.core.context.SecurityContextHolder;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
|
|
@ -33,7 +34,7 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor {
|
||||||
String token = SecurityUtils.getToken();
|
String token = SecurityUtils.getToken();
|
||||||
if (StringUtils.isNotEmpty(token)) {
|
if (StringUtils.isNotEmpty(token)) {
|
||||||
LoginUser loginUser = AuthUtil.getLoginUser(token);
|
LoginUser loginUser = AuthUtil.getLoginUser(token);
|
||||||
if (StringUtils.isNotNull(loginUser)) {
|
if (ObjectUtil.isNotNull(loginUser)) {
|
||||||
AuthUtil.verifyLoginUserExpire(loginUser);
|
AuthUtil.verifyLoginUserExpire(loginUser);
|
||||||
SecurityContextHolder.set(SecurityConstants.LOGIN_USER, loginUser);
|
SecurityContextHolder.set(SecurityConstants.LOGIN_USER, loginUser);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
package com.ruoyi.common.security.service;
|
package com.ruoyi.common.security.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.CacheConstants;
|
import com.ruoyi.common.core.constant.CacheConstants;
|
||||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
import com.ruoyi.common.core.utils.JwtUtils;
|
import com.ruoyi.common.core.utils.JwtUtils;
|
||||||
import com.ruoyi.common.core.utils.ServletUtils;
|
import com.ruoyi.common.core.utils.ServletUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.ip.IpUtils;
|
|
||||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
|
|
@ -45,7 +45,7 @@ public class TokenService {
|
||||||
loginUser.setToken(token);
|
loginUser.setToken(token);
|
||||||
loginUser.setUserid(userId);
|
loginUser.setUserid(userId);
|
||||||
loginUser.setUsername(userName);
|
loginUser.setUsername(userName);
|
||||||
loginUser.setIpaddr(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
loginUser.setIpaddr(ServletUtils.getClientIP());
|
||||||
refreshToken(loginUser);
|
refreshToken(loginUser);
|
||||||
|
|
||||||
// Jwt存储信息
|
// Jwt存储信息
|
||||||
|
|
@ -103,7 +103,7 @@ public class TokenService {
|
||||||
* 设置用户身份信息
|
* 设置用户身份信息
|
||||||
*/
|
*/
|
||||||
public void setLoginUser(LoginUser loginUser) {
|
public void setLoginUser(LoginUser loginUser) {
|
||||||
if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) {
|
if (ObjectUtil.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) {
|
||||||
refreshToken(loginUser);
|
refreshToken(loginUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ruoyi.gen.service;
|
package com.ruoyi.gen.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.GenConstants;
|
import com.ruoyi.common.core.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
|
|
@ -261,7 +263,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
|
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
|
||||||
|
|
||||||
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||||
if (StringUtils.isEmpty(dbTableColumns)) {
|
if (CollUtil.isEmpty(dbTableColumns)) {
|
||||||
throw new ServiceException("同步数据失败,原表结构不存在");
|
throw new ServiceException("同步数据失败,原表结构不存在");
|
||||||
}
|
}
|
||||||
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||||
|
|
@ -282,7 +284,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
});
|
});
|
||||||
|
|
||||||
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
||||||
if (StringUtils.isNotEmpty(delColumns)) {
|
if (CollUtil.isNotEmpty(delColumns)) {
|
||||||
genTableColumnMapper.deleteGenTableColumns(delColumns);
|
genTableColumnMapper.deleteGenTableColumns(delColumns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -377,7 +379,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNull(table.getPkColumn())) {
|
if (ObjectUtil.isNull(table.getPkColumn())) {
|
||||||
table.setPkColumn(table.getColumns().get(0));
|
table.setPkColumn(table.getColumns().get(0));
|
||||||
}
|
}
|
||||||
if (GenConstants.TPL_SUB.equals(table.getTplCategory())) {
|
if (GenConstants.TPL_SUB.equals(table.getTplCategory())) {
|
||||||
|
|
@ -387,7 +389,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
|
if (ObjectUtil.isNull(table.getSubTable().getPkColumn())) {
|
||||||
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
|
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -412,7 +414,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
*/
|
*/
|
||||||
public void setTableFromOptions(GenTable genTable) {
|
public void setTableFromOptions(GenTable genTable) {
|
||||||
Map<String, String> paramsObj = JsonUtils.parseMap(genTable.getOptions());
|
Map<String, String> paramsObj = JsonUtils.parseMap(genTable.getOptions());
|
||||||
if (StringUtils.isNotNull(paramsObj)) {
|
if (ObjectUtil.isNotNull(paramsObj)) {
|
||||||
String treeCode = paramsObj.get(GenConstants.TREE_CODE);
|
String treeCode = paramsObj.get(GenConstants.TREE_CODE);
|
||||||
String treeParentCode = paramsObj.get(GenConstants.TREE_PARENT_CODE);
|
String treeParentCode = paramsObj.get(GenConstants.TREE_PARENT_CODE);
|
||||||
String treeName = paramsObj.get(GenConstants.TREE_NAME);
|
String treeName = paramsObj.get(GenConstants.TREE_NAME);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ruoyi.gen.util;
|
package com.ruoyi.gen.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.GenConstants;
|
import com.ruoyi.common.core.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.JsonUtils;
|
import com.ruoyi.common.core.utils.JsonUtils;
|
||||||
|
|
@ -209,7 +211,7 @@ public class VelocityUtils {
|
||||||
List<GenTableColumn> columns = genTable.getColumns();
|
List<GenTableColumn> columns = genTable.getColumns();
|
||||||
GenTable subGenTable = genTable.getSubTable();
|
GenTable subGenTable = genTable.getSubTable();
|
||||||
HashSet<String> importList = new HashSet<String>();
|
HashSet<String> importList = new HashSet<String>();
|
||||||
if (StringUtils.isNotNull(subGenTable)) {
|
if (ObjectUtil.isNotNull(subGenTable)) {
|
||||||
importList.add("java.util.List");
|
importList.add("java.util.List");
|
||||||
}
|
}
|
||||||
for (GenTableColumn column : columns) {
|
for (GenTableColumn column : columns) {
|
||||||
|
|
@ -259,7 +261,7 @@ public class VelocityUtils {
|
||||||
* @return 上级菜单ID字段
|
* @return 上级菜单ID字段
|
||||||
*/
|
*/
|
||||||
public static String getParentMenuId(Map<String, String> paramsObj) {
|
public static String getParentMenuId(Map<String, String> paramsObj) {
|
||||||
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
|
if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
|
||||||
&& StringUtils.isNotEmpty(paramsObj.get(GenConstants.PARENT_MENU_ID))) {
|
&& StringUtils.isNotEmpty(paramsObj.get(GenConstants.PARENT_MENU_ID))) {
|
||||||
return paramsObj.get(GenConstants.PARENT_MENU_ID);
|
return paramsObj.get(GenConstants.PARENT_MENU_ID);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package ${packageName}.controller;
|
package ${packageName}.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,11 @@
|
||||||
<artifactId>ruoyi-api-file</artifactId>
|
<artifactId>ruoyi-api-file</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
|
@ -47,8 +47,7 @@ public class SysConfigController extends BaseController {
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysConfig config) {
|
public void export(HttpServletResponse response, SysConfig config) {
|
||||||
List<SysConfig> list = configService.selectConfigList(config);
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
ExcelUtil.exportExcel(list, "参数数据", SysConfig.class, response);
|
||||||
util.exportExcel(response, list, "参数数据");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
|
@ -47,8 +47,7 @@ public class SysDictDataController extends BaseController {
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysDictData dictData) {
|
public void export(HttpServletResponse response, SysDictData dictData) {
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
ExcelUtil.exportExcel(list, "字典数据", SysDictData.class, response);
|
||||||
util.exportExcel(response, list, "字典数据");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,7 +65,7 @@ public class SysDictDataController extends BaseController {
|
||||||
@GetMapping(value = "/type/{dictType}")
|
@GetMapping(value = "/type/{dictType}")
|
||||||
public AjaxResult dictType(@PathVariable String dictType) {
|
public AjaxResult dictType(@PathVariable String dictType) {
|
||||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||||
if (StringUtils.isNull(data)) {
|
if (ObjectUtil.isNull(data)) {
|
||||||
data = new ArrayList<SysDictData>();
|
data = new ArrayList<SysDictData>();
|
||||||
}
|
}
|
||||||
return AjaxResult.success(data);
|
return AjaxResult.success(data);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
|
@ -44,8 +44,7 @@ public class SysDictTypeController extends BaseController {
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysDictType dictType) {
|
public void export(HttpServletResponse response, SysDictType dictType) {
|
||||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
ExcelUtil.exportExcel(list, "字典类型", SysDictType.class, response);
|
||||||
util.exportExcel(response, list, "字典类型");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.InnerAuth;
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||||
|
|
@ -42,8 +42,7 @@ public class SysLogininforController extends BaseController {
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysLogininfor logininfor) {
|
public void export(HttpServletResponse response, SysLogininfor logininfor) {
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response);
|
||||||
util.exportExcel(response, list, "登录日志");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:logininfor:remove")
|
@RequiresPermissions("system:logininfor:remove")
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.InnerAuth;
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||||
|
|
@ -41,8 +41,7 @@ public class SysOperlogController extends BaseController {
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysOperLog operLog) {
|
public void export(HttpServletResponse response, SysOperLog operLog) {
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response);
|
||||||
util.exportExcel(response, list, "操作日志");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
|
@ -47,8 +47,7 @@ public class SysPostController extends BaseController {
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysPost post) {
|
public void export(HttpServletResponse response, SysPost post) {
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
ExcelUtil.exportExcel(list, "岗位数据", SysPost.class, response);
|
||||||
util.exportExcel(response, list, "岗位数据");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
|
|
@ -118,7 +119,7 @@ public class SysProfileController extends BaseController {
|
||||||
if (!file.isEmpty()) {
|
if (!file.isEmpty()) {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
SysFile sysFile = remoteFileService.upload(file.getName(), file.getOriginalFilename(), file.getContentType(), file.getBytes());
|
SysFile sysFile = remoteFileService.upload(file.getName(), file.getOriginalFilename(), file.getContentType(), file.getBytes());
|
||||||
if (StringUtils.isNull(sysFile)) {
|
if (ObjectUtil.isNull(sysFile)) {
|
||||||
return AjaxResult.error("文件服务异常,请联系管理员");
|
return AjaxResult.error("文件服务异常,请联系管理员");
|
||||||
}
|
}
|
||||||
String url = sysFile.getUrl();
|
String url = sysFile.getUrl();
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
|
@ -48,8 +48,7 @@ public class SysRoleController extends BaseController {
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysRole role) {
|
public void export(HttpServletResponse response, SysRole role) {
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
ExcelUtil.exportExcel(list, "角色数据", SysRole.class, response);
|
||||||
util.exportExcel(response, list, "角色数据");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,24 @@
|
||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.excel.core.ExcelResult;
|
||||||
|
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.system.api.domain.SysDept;
|
||||||
import com.ruoyi.system.api.domain.SysRole;
|
import com.ruoyi.system.api.domain.SysRole;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
|
import com.ruoyi.system.domain.vo.SysUserExportVo;
|
||||||
|
import com.ruoyi.system.domain.vo.SysUserImportVo;
|
||||||
|
import com.ruoyi.system.listener.SysUserImportListener;
|
||||||
import com.ruoyi.system.service.*;
|
import com.ruoyi.system.service.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
@ -22,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -58,25 +66,29 @@ public class SysUserController extends BaseController {
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, SysUser user) {
|
public void export(HttpServletResponse response, SysUser user) {
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class);
|
||||||
util.exportExcel(response, list, "用户数据");
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
SysDept dept = list.get(i).getDept();
|
||||||
|
SysUserExportVo vo = listVo.get(i);
|
||||||
|
if (ObjectUtil.isNotEmpty(dept)) {
|
||||||
|
vo.setDeptName(dept.getDeptName());
|
||||||
|
vo.setLeader(dept.getLeader());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||||
@RequiresPermissions("system:user:import")
|
@RequiresPermissions("system:user:import")
|
||||||
@PostMapping("/importData")
|
@PostMapping("/importData")
|
||||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
|
||||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
return AjaxResult.success(result.getAnalysis());
|
||||||
String operName = SecurityUtils.getUsername();
|
|
||||||
String message = userService.importUser(userList, updateSupport, operName);
|
|
||||||
return AjaxResult.success(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/importTemplate")
|
@PostMapping("/importTemplate")
|
||||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
|
||||||
util.importTemplateExcel(response, "用户数据");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -109,7 +121,7 @@ public class SysUserController extends BaseController {
|
||||||
List<SysRole> roles = roleService.selectRoleAll();
|
List<SysRole> roles = roleService.selectRoleAll();
|
||||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
ajax.put("posts", postService.selectPostAll());
|
ajax.put("posts", postService.selectPostAll());
|
||||||
if (StringUtils.isNotNull(userId)) {
|
if (ObjectUtil.isNotNull(userId)) {
|
||||||
SysUser sysUser = userService.selectUserById(userId);
|
SysUser sysUser = userService.selectUserById(userId);
|
||||||
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
@ -14,49 +17,62 @@ import javax.validation.constraints.Size;
|
||||||
/**
|
/**
|
||||||
* 参数配置表 sys_config
|
* 参数配置表 sys_config
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@ApiModel("参数配置业务对象")
|
||||||
public class SysConfig extends BaseEntity {
|
public class SysConfig extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数主键
|
* 参数主键
|
||||||
*/
|
*/
|
||||||
@Excel(name = "参数主键", cellType = ColumnType.NUMERIC)
|
@ApiModelProperty(value = "参数主键")
|
||||||
|
@ExcelProperty(value = "参数主键")
|
||||||
private Long configId;
|
private Long configId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数名称
|
* 参数名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "参数名称")
|
||||||
|
@ExcelProperty(value = "参数名称")
|
||||||
@NotBlank(message = "参数名称不能为空")
|
@NotBlank(message = "参数名称不能为空")
|
||||||
@Size(min = 0, max = 100, message = "参数名称不能超过100个字符")
|
@Size(min = 0, max = 100, message = "参数名称不能超过100个字符")
|
||||||
@Excel(name = "参数名称")
|
|
||||||
private String configName;
|
private String configName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数键名
|
* 参数键名
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "参数键名")
|
||||||
|
@ExcelProperty(value = "参数键名")
|
||||||
@NotBlank(message = "参数键名长度不能为空")
|
@NotBlank(message = "参数键名长度不能为空")
|
||||||
@Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符")
|
||||||
@Excel(name = "参数键名")
|
|
||||||
private String configKey;
|
private String configKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数键值
|
* 参数键值
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "参数键值")
|
||||||
|
@ExcelProperty(value = "参数键值")
|
||||||
@NotBlank(message = "参数键值不能为空")
|
@NotBlank(message = "参数键值不能为空")
|
||||||
@Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符")
|
@Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符")
|
||||||
@Excel(name = "参数键值")
|
|
||||||
private String configValue;
|
private String configValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统内置(Y是 N否)
|
* 系统内置(Y是 N否)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "系统内置", readConverterExp = "Y=是,N=否")
|
@ApiModelProperty(value = "系统内置(Y是 N否)")
|
||||||
|
@ExcelProperty(value = "系统内置", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_yes_no")
|
||||||
private String configType;
|
private String configType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,113 +1,116 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.TreeEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单权限表 sys_menu
|
* 菜单权限表 sys_menu
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class SysMenu extends BaseEntity {
|
@ApiModel("菜单权限业务对象")
|
||||||
private static final long serialVersionUID = 1L;
|
public class SysMenu extends TreeEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单ID
|
* 菜单ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "菜单ID")
|
||||||
private Long menuId;
|
private Long menuId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单名称
|
* 菜单名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "菜单名称")
|
||||||
@NotBlank(message = "菜单名称不能为空")
|
@NotBlank(message = "菜单名称不能为空")
|
||||||
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
||||||
private String menuName;
|
private String menuName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 父菜单名称
|
|
||||||
*/
|
|
||||||
private String parentName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父菜单ID
|
|
||||||
*/
|
|
||||||
private Long parentId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示顺序
|
* 显示顺序
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "显示顺序")
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
private String orderNum;
|
private String orderNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由地址
|
* 路由地址
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "路由地址")
|
||||||
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
|
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件路径
|
* 组件路径
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "组件路径")
|
||||||
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
|
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
|
||||||
private String component;
|
private String component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由参数
|
* 路由参数
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "路由参数")
|
||||||
private String query;
|
private String query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为外链(0是 1否)
|
* 是否为外链(0是 1否)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "是否为外链(0是 1否)")
|
||||||
private String isFrame;
|
private String isFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否缓存(0缓存 1不缓存)
|
* 是否缓存(0缓存 1不缓存)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "是否缓存(0缓存 1不缓存)")
|
||||||
private String isCache;
|
private String isCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型(M目录 C菜单 F按钮)
|
* 类型(M目录 C菜单 F按钮)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "类型(M目录 C菜单 F按钮)")
|
||||||
@NotBlank(message = "菜单类型不能为空")
|
@NotBlank(message = "菜单类型不能为空")
|
||||||
private String menuType;
|
private String menuType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示状态(0显示 1隐藏)
|
* 显示状态(0显示 1隐藏)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "显示状态(0显示 1隐藏)")
|
||||||
private String visible;
|
private String visible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单状态(0显示 1隐藏)
|
* 菜单状态(0显示 1隐藏)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "菜单状态(0显示 1隐藏)")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限字符串
|
* 权限字符串
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "权限字符串")
|
||||||
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
||||||
private String perms;
|
private String perms;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单图标
|
* 菜单图标
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "菜单图标")
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子菜单
|
* 备注
|
||||||
*/
|
*/
|
||||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,35 +2,36 @@ package com.ruoyi.system.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
import com.ruoyi.common.core.xss.Xss;
|
import com.ruoyi.common.core.xss.Xss;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知公告表 sys_notice
|
* 通知公告表 sys_notice
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class SysNotice extends BaseEntity {
|
public class SysNotice extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告ID
|
* 公告ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "公告ID")
|
||||||
private Long noticeId;
|
private Long noticeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告标题
|
* 公告标题
|
||||||
*/
|
*/
|
||||||
@Xss(message = "公告标题不能包含脚本字符")
|
@Xss(message = "公告标题不能包含脚本字符")
|
||||||
|
@ApiModelProperty(value = "公告标题")
|
||||||
@NotBlank(message = "公告标题不能为空")
|
@NotBlank(message = "公告标题不能为空")
|
||||||
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
|
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
|
||||||
private String noticeTitle;
|
private String noticeTitle;
|
||||||
|
|
@ -38,16 +39,25 @@ public class SysNotice extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 公告类型(1通知 2公告)
|
* 公告类型(1通知 2公告)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "公告类型(1通知 2公告)")
|
||||||
private String noticeType;
|
private String noticeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告内容
|
* 公告内容
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "公告内容")
|
||||||
private String noticeContent;
|
private String noticeContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告状态(0正常 1关闭)
|
* 公告状态(0正常 1关闭)
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "公告状态(0正常 1关闭)")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
@ -14,53 +17,67 @@ import javax.validation.constraints.Size;
|
||||||
/**
|
/**
|
||||||
* 岗位表 sys_post
|
* 岗位表 sys_post
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@ApiModel("岗位信息业务对象")
|
||||||
public class SysPost extends BaseEntity {
|
public class SysPost extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位序号
|
* 岗位序号
|
||||||
*/
|
*/
|
||||||
@Excel(name = "岗位序号", cellType = ColumnType.NUMERIC)
|
@ApiModelProperty(value = "岗位序号")
|
||||||
|
@ExcelProperty(value = "岗位序号")
|
||||||
private Long postId;
|
private Long postId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位编码
|
* 岗位编码
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "岗位编码")
|
||||||
|
@ExcelProperty(value = "岗位编码")
|
||||||
@NotBlank(message = "岗位编码不能为空")
|
@NotBlank(message = "岗位编码不能为空")
|
||||||
@Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符")
|
@Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符")
|
||||||
@Excel(name = "岗位编码")
|
|
||||||
private String postCode;
|
private String postCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位名称
|
* 岗位名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "岗位名称")
|
||||||
|
@ExcelProperty(value = "岗位名称")
|
||||||
@NotBlank(message = "岗位名称不能为空")
|
@NotBlank(message = "岗位名称不能为空")
|
||||||
@Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符")
|
||||||
@Excel(name = "岗位名称")
|
|
||||||
private String postName;
|
private String postName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位排序
|
* 岗位排序
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "岗位排序")
|
||||||
|
@ExcelProperty(value = "岗位排序")
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
@NotBlank(message = "显示顺序不能为空")
|
||||||
@Excel(name = "岗位排序")
|
|
||||||
private String postSort;
|
private String postSort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态(0正常 1停用)
|
* 状态(0正常 1停用)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
@ApiModelProperty(value = "状态(0正常 1停用)")
|
||||||
|
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_common_status")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户是否存在此岗位标识 默认不存在
|
* 用户是否存在此岗位标识 默认不存在
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户是否存在此岗位标识 默认不存在")
|
||||||
private boolean flag = false;
|
private boolean flag = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,31 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色和部门关联 sys_role_dept
|
* 角色和部门关联 sys_role_dept
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ApiModel("角色和部门关联")
|
||||||
public class SysRoleDept {
|
public class SysRoleDept {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色ID
|
* 角色ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色ID")
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "部门ID")
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,31 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色和菜单关联 sys_role_menu
|
* 角色和菜单关联 sys_role_menu
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ApiModel("角色和菜单关联")
|
||||||
public class SysRoleMenu {
|
public class SysRoleMenu {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色ID
|
* 角色ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色ID")
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单ID
|
* 菜单ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色ID")
|
||||||
private Long menuId;
|
private Long menuId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,67 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前在线会话
|
* 当前在线会话
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ApiModel("当前在线会话业务对象")
|
||||||
public class SysUserOnline {
|
public class SysUserOnline {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会话编号
|
* 会话编号
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "会话编号")
|
||||||
private String tokenId;
|
private String tokenId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名称
|
* 用户名称
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户名称")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录IP地址
|
* 登录IP地址
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "登录IP地址")
|
||||||
private String ipaddr;
|
private String ipaddr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录地址
|
* 登录地址
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "登录地址")
|
||||||
private String loginLocation;
|
private String loginLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 浏览器类型
|
* 浏览器类型
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "浏览器类型")
|
||||||
private String browser;
|
private String browser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作系统
|
* 操作系统
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "操作系统")
|
||||||
private String os;
|
private String os;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录时间
|
* 登录时间
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "登录时间")
|
||||||
private Long loginTime;
|
private Long loginTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,31 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户和岗位关联 sys_user_post
|
* 用户和岗位关联 sys_user_post
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ApiModel("用户和岗位关联")
|
||||||
public class SysUserPost {
|
public class SysUserPost {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户ID")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位ID
|
* 岗位ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "岗位ID")
|
||||||
private Long postId;
|
private Long postId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,31 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户和角色关联 sys_user_role
|
* 用户和角色关联 sys_user_role
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@ApiModel("用户和角色关联")
|
||||||
public class SysUserRole {
|
public class SysUserRole {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "用户ID")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色ID
|
* 角色ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "角色ID")
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
package com.ruoyi.system.domain.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户对象导出VO
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class SysUserExportVo implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "用户序号")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账号
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "登录名称")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "用户名称")
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户邮箱
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "用户邮箱")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号码
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "手机号码")
|
||||||
|
private String phonenumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户性别
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "用户性别", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_user_sex")
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 帐号状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_common_status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后登录IP
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "最后登录IP")
|
||||||
|
private String loginIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后登录时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "最后登录时间")
|
||||||
|
private Date loginDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 负责人
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "部门负责人")
|
||||||
|
private String leader;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.ruoyi.system.domain.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户对象导入VO
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
// @Accessors(chain = true) // 导入不允许使用 会找不到set方法
|
||||||
|
public class SysUserImportVo implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "用户序号")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "部门编号")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账号
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "登录名称")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "用户名称")
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户邮箱
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "用户邮箱")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号码
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "手机号码")
|
||||||
|
private String phonenumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户性别
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "用户性别", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_user_sex")
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 帐号状态(0正常 1停用)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "sys_normal_disable")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
package com.ruoyi.system.domain.vo;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import com.ruoyi.system.api.domain.SysDept;
|
|
||||||
import com.ruoyi.system.domain.SysMenu;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Treeselect树结构实体类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
|
||||||
public class TreeSelect implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 节点ID
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 节点名称
|
|
||||||
*/
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 子节点
|
|
||||||
*/
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
|
||||||
private List<TreeSelect> children;
|
|
||||||
|
|
||||||
public TreeSelect(SysDept dept) {
|
|
||||||
this.id = dept.getDeptId();
|
|
||||||
this.label = dept.getDeptName();
|
|
||||||
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TreeSelect(SysMenu menu) {
|
|
||||||
this.id = menu.getMenuId();
|
|
||||||
this.label = menu.getMenuName();
|
|
||||||
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.ruoyi.system.dubbo;
|
package com.ruoyi.system.dubbo;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.system.api.RemoteUserService;
|
import com.ruoyi.system.api.RemoteUserService;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
|
|
@ -33,7 +33,7 @@ public class RemoteUserServiceImpl implements RemoteUserService {
|
||||||
@Override
|
@Override
|
||||||
public LoginUser getUserInfo(String username, String source) {
|
public LoginUser getUserInfo(String username, String source) {
|
||||||
SysUser sysUser = userService.selectUserByUserName(username);
|
SysUser sysUser = userService.selectUserByUserName(username);
|
||||||
if (StringUtils.isNull(sysUser)) {
|
if (ObjectUtil.isNull(sysUser)) {
|
||||||
throw new ServiceException("用户名或密码错误");
|
throw new ServiceException("用户名或密码错误");
|
||||||
}
|
}
|
||||||
// 角色集合
|
// 角色集合
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
package com.ruoyi.system.listener;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.ValidatorUtils;
|
||||||
|
import com.ruoyi.common.excel.core.ExcelListener;
|
||||||
|
import com.ruoyi.common.excel.core.ExcelResult;
|
||||||
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
|
import com.ruoyi.system.domain.vo.SysUserImportVo;
|
||||||
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户自定义导入
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo> implements ExcelListener<SysUserImportVo> {
|
||||||
|
|
||||||
|
private final ISysUserService userService;
|
||||||
|
|
||||||
|
private final String password;
|
||||||
|
|
||||||
|
private final Boolean isUpdateSupport;
|
||||||
|
|
||||||
|
private final String operName;
|
||||||
|
|
||||||
|
private int successNum = 0;
|
||||||
|
private int failureNum = 0;
|
||||||
|
private final StringBuilder successMsg = new StringBuilder();
|
||||||
|
private final StringBuilder failureMsg = new StringBuilder();
|
||||||
|
|
||||||
|
public SysUserImportListener(Boolean isUpdateSupport) {
|
||||||
|
String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword");
|
||||||
|
this.userService = SpringUtils.getBean(ISysUserService.class);
|
||||||
|
this.password = SecurityUtils.encryptPassword(initPassword);
|
||||||
|
this.isUpdateSupport = isUpdateSupport;
|
||||||
|
this.operName = SecurityUtils.getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(SysUserImportVo userVo, AnalysisContext context) {
|
||||||
|
SysUser user = this.userService.selectUserByUserName(userVo.getUserName());
|
||||||
|
try {
|
||||||
|
// 验证是否存在这个用户
|
||||||
|
if (ObjectUtil.isNull(user)) {
|
||||||
|
user = BeanUtil.toBean(userVo, SysUser.class);
|
||||||
|
ValidatorUtils.validate(user);
|
||||||
|
user.setPassword(password);
|
||||||
|
user.setCreateBy(operName);
|
||||||
|
userService.insertUser(user);
|
||||||
|
successNum++;
|
||||||
|
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
|
||||||
|
} else if (isUpdateSupport) {
|
||||||
|
ValidatorUtils.validate(user);
|
||||||
|
user.setUpdateBy(operName);
|
||||||
|
userService.updateUser(user);
|
||||||
|
successNum++;
|
||||||
|
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
|
||||||
|
} else {
|
||||||
|
failureNum++;
|
||||||
|
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(user.getUserName()).append(" 已存在");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
failureNum++;
|
||||||
|
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||||
|
failureMsg.append(msg).append(e.getMessage());
|
||||||
|
log.error(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExcelResult<SysUserImportVo> getExcelResult() {
|
||||||
|
return new ExcelResult<SysUserImportVo>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAnalysis() {
|
||||||
|
if (failureNum > 0) {
|
||||||
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
|
throw new ServiceException(failureMsg.toString());
|
||||||
|
} else {
|
||||||
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
|
}
|
||||||
|
return successMsg.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysUserImportVo> getList() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getErrorList() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import com.ruoyi.system.api.domain.SysDept;
|
import com.ruoyi.system.api.domain.SysDept;
|
||||||
import com.ruoyi.system.domain.vo.TreeSelect;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ public interface ISysDeptService {
|
||||||
* @param depts 部门列表
|
* @param depts 部门列表
|
||||||
* @return 下拉树结构列表
|
* @return 下拉树结构列表
|
||||||
*/
|
*/
|
||||||
List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
|
List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色ID查询部门树信息
|
* 根据角色ID查询部门树信息
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import com.ruoyi.system.domain.SysMenu;
|
import com.ruoyi.system.domain.SysMenu;
|
||||||
import com.ruoyi.system.domain.vo.RouterVo;
|
import com.ruoyi.system.domain.vo.RouterVo;
|
||||||
import com.ruoyi.system.domain.vo.TreeSelect;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -62,21 +62,13 @@ public interface ISysMenuService {
|
||||||
*/
|
*/
|
||||||
List<RouterVo> buildMenus(List<SysMenu> menus);
|
List<RouterVo> buildMenus(List<SysMenu> menus);
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建前端所需要树结构
|
|
||||||
*
|
|
||||||
* @param menus 菜单列表
|
|
||||||
* @return 树结构列表
|
|
||||||
*/
|
|
||||||
List<SysMenu> buildMenuTree(List<SysMenu> menus);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端所需要下拉树结构
|
* 构建前端所需要下拉树结构
|
||||||
*
|
*
|
||||||
* @param menus 菜单列表
|
* @param menus 菜单列表
|
||||||
* @return 下拉树结构列表
|
* @return 下拉树结构列表
|
||||||
*/
|
*/
|
||||||
List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus);
|
List<Tree<Long>> buildMenuTreeSelect(List<SysMenu> menus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单ID查询信息
|
* 根据菜单ID查询信息
|
||||||
|
|
|
||||||
|
|
@ -194,13 +194,4 @@ public interface ISysUserService {
|
||||||
*/
|
*/
|
||||||
int deleteUserByIds(Long[] userIds);
|
int deleteUserByIds(Long[] userIds);
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入用户数据
|
|
||||||
*
|
|
||||||
* @param userList 用户数据列表
|
|
||||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
|
||||||
* @param operName 操作用户
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
|
|
@ -64,7 +65,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
||||||
SysConfig config = new SysConfig();
|
SysConfig config = new SysConfig();
|
||||||
config.setConfigKey(configKey);
|
config.setConfigKey(configKey);
|
||||||
SysConfig retConfig = configMapper.selectConfig(config);
|
SysConfig retConfig = configMapper.selectConfig(config);
|
||||||
if (StringUtils.isNotNull(retConfig)) {
|
if (ObjectUtil.isNotNull(retConfig)) {
|
||||||
RedisUtils.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
RedisUtils.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
||||||
return retConfig.getConfigValue();
|
return retConfig.getConfigValue();
|
||||||
}
|
}
|
||||||
|
|
@ -167,9 +168,9 @@ public class SysConfigServiceImpl implements ISysConfigService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkConfigKeyUnique(SysConfig config) {
|
public String checkConfigKeyUnique(SysConfig config) {
|
||||||
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
|
Long configId = ObjectUtil.isNull(config.getConfigId()) ? -1L : config.getConfigId();
|
||||||
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
|
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
|
||||||
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.TreeBuildUtils;
|
||||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.domain.SysDept;
|
import com.ruoyi.system.api.domain.SysDept;
|
||||||
import com.ruoyi.system.api.domain.SysRole;
|
import com.ruoyi.system.api.domain.SysRole;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
import com.ruoyi.system.domain.vo.TreeSelect;
|
|
||||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
|
@ -21,7 +24,6 @@ import org.springframework.stereotype.Service;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门管理 服务实现
|
* 部门管理 服务实现
|
||||||
|
|
@ -81,9 +83,16 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
* @return 下拉树结构列表
|
* @return 下拉树结构列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
|
public List<Tree<Long>> buildDeptTreeSelect(List<SysDept> depts) {
|
||||||
List<SysDept> deptTrees = buildDeptTree(depts);
|
if (CollUtil.isEmpty(depts)) {
|
||||||
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
Long parentId = depts.get(0).getParentId();
|
||||||
|
return TreeBuildUtils.build(depts, parentId, (dept, tree) ->
|
||||||
|
tree.setId(dept.getDeptId())
|
||||||
|
.setParentId(dept.getParentId())
|
||||||
|
.setName(dept.getDeptName())
|
||||||
|
.setWeight(dept.getOrderNum()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -152,9 +161,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkDeptNameUnique(SysDept dept) {
|
public String checkDeptNameUnique(SysDept dept) {
|
||||||
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
||||||
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
|
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
|
||||||
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
@ -171,7 +180,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
SysDept dept = new SysDept();
|
SysDept dept = new SysDept();
|
||||||
dept.setDeptId(deptId);
|
dept.setDeptId(deptId);
|
||||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||||
if (StringUtils.isEmpty(depts)) {
|
if (CollUtil.isEmpty(depts)) {
|
||||||
throw new ServiceException("没有权限访问部门数据!");
|
throw new ServiceException("没有权限访问部门数据!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -204,7 +213,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
public int updateDept(SysDept dept) {
|
public int updateDept(SysDept dept) {
|
||||||
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
||||||
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
|
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
|
||||||
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
|
if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) {
|
||||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||||
String oldAncestors = oldDept.getAncestors();
|
String oldAncestors = oldDept.getAncestors();
|
||||||
dept.setAncestors(newAncestors);
|
dept.setAncestors(newAncestors);
|
||||||
|
|
@ -277,10 +286,8 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
||||||
*/
|
*/
|
||||||
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
|
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
|
||||||
List<SysDept> tlist = new ArrayList<SysDept>();
|
List<SysDept> tlist = new ArrayList<SysDept>();
|
||||||
Iterator<SysDept> it = list.iterator();
|
for (SysDept n : list) {
|
||||||
while (it.hasNext()) {
|
if (ObjectUtil.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
|
||||||
SysDept n = (SysDept) it.next();
|
|
||||||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
|
|
||||||
tlist.add(n);
|
tlist.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.dict.utils.DictUtils;
|
import com.ruoyi.common.dict.utils.DictUtils;
|
||||||
import com.ruoyi.system.api.domain.SysDictData;
|
import com.ruoyi.system.api.domain.SysDictData;
|
||||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||||
|
|
@ -55,7 +54,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||||
@Override
|
@Override
|
||||||
public List<SysDictData> selectDictDataByType(String dictType) {
|
public List<SysDictData> selectDictDataByType(String dictType) {
|
||||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
if (CollUtil.isNotEmpty(dictDatas)) {
|
||||||
return dictDatas;
|
return dictDatas;
|
||||||
}
|
}
|
||||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
@ -70,11 +72,11 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
||||||
@Override
|
@Override
|
||||||
public List<SysDictData> selectDictDataByType(String dictType) {
|
public List<SysDictData> selectDictDataByType(String dictType) {
|
||||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
if (CollUtil.isNotEmpty(dictDatas)) {
|
||||||
return dictDatas;
|
return dictDatas;
|
||||||
}
|
}
|
||||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
if (CollUtil.isNotEmpty(dictDatas)) {
|
||||||
DictUtils.setDictCache(dictType, dictDatas);
|
DictUtils.setDictCache(dictType, dictDatas);
|
||||||
return dictDatas;
|
return dictDatas;
|
||||||
}
|
}
|
||||||
|
|
@ -193,9 +195,9 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkDictTypeUnique(SysDictType dict) {
|
public String checkDictTypeUnique(SysDictType dict) {
|
||||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
Long dictId = ObjectUtil.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||||
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
|
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
|
||||||
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) {
|
if (ObjectUtil.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.utils.TreeBuildUtils;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.domain.SysRole;
|
import com.ruoyi.system.api.domain.SysRole;
|
||||||
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.domain.SysUser;
|
||||||
import com.ruoyi.system.domain.SysMenu;
|
import com.ruoyi.system.domain.SysMenu;
|
||||||
import com.ruoyi.system.domain.vo.MetaVo;
|
import com.ruoyi.system.domain.vo.MetaVo;
|
||||||
import com.ruoyi.system.domain.vo.RouterVo;
|
import com.ruoyi.system.domain.vo.RouterVo;
|
||||||
import com.ruoyi.system.domain.vo.TreeSelect;
|
|
||||||
import com.ruoyi.system.mapper.SysMenuMapper;
|
import com.ruoyi.system.mapper.SysMenuMapper;
|
||||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||||
|
|
@ -19,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单 业务层处理
|
* 菜单 业务层处理
|
||||||
|
|
@ -128,7 +130,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||||
router.setComponent(getComponent(menu));
|
router.setComponent(getComponent(menu));
|
||||||
router.setQuery(menu.getQuery());
|
router.setQuery(menu.getQuery());
|
||||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||||
List<SysMenu> cMenus = menu.getChildren();
|
List<SysMenu> cMenus = (List<SysMenu>) menu.getChildren();
|
||||||
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
|
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
|
||||||
router.setAlwaysShow(true);
|
router.setAlwaysShow(true);
|
||||||
router.setRedirect("noRedirect");
|
router.setRedirect("noRedirect");
|
||||||
|
|
@ -162,33 +164,6 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||||
return routers;
|
return routers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建前端所需要树结构
|
|
||||||
*
|
|
||||||
* @param menus 菜单列表
|
|
||||||
* @return 树结构列表
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysMenu> buildMenuTree(List<SysMenu> menus) {
|
|
||||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
|
||||||
List<Long> tempList = new ArrayList<Long>();
|
|
||||||
for (SysMenu dept : menus) {
|
|
||||||
tempList.add(dept.getMenuId());
|
|
||||||
}
|
|
||||||
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext(); ) {
|
|
||||||
SysMenu menu = (SysMenu) iterator.next();
|
|
||||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
|
||||||
if (!tempList.contains(menu.getParentId())) {
|
|
||||||
recursionFn(menus, menu);
|
|
||||||
returnList.add(menu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (returnList.isEmpty()) {
|
|
||||||
returnList = menus;
|
|
||||||
}
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端所需要下拉树结构
|
* 构建前端所需要下拉树结构
|
||||||
*
|
*
|
||||||
|
|
@ -196,9 +171,16 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||||
* @return 下拉树结构列表
|
* @return 下拉树结构列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus) {
|
public List<Tree<Long>> buildMenuTreeSelect(List<SysMenu> menus) {
|
||||||
List<SysMenu> menuTrees = buildMenuTree(menus);
|
if (CollUtil.isEmpty(menus)) {
|
||||||
return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
Long parentId = menus.get(0).getParentId();
|
||||||
|
return TreeBuildUtils.build(menus, parentId, (menu, tree) ->
|
||||||
|
tree.setId(menu.getMenuId())
|
||||||
|
.setParentId(menu.getParentId())
|
||||||
|
.setName(menu.getMenuName())
|
||||||
|
.setWeight(menu.getOrderNum()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -277,9 +259,9 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkMenuNameUnique(SysMenu menu) {
|
public String checkMenuNameUnique(SysMenu menu) {
|
||||||
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
Long menuId = ObjectUtil.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
||||||
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
|
||||||
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
@ -382,8 +364,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||||
*/
|
*/
|
||||||
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
|
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
|
||||||
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
List<SysMenu> returnList = new ArrayList<SysMenu>();
|
||||||
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) {
|
for (SysMenu t : list) {
|
||||||
SysMenu t = (SysMenu) iterator.next();
|
|
||||||
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
|
||||||
if (t.getParentId() == parentId) {
|
if (t.getParentId() == parentId) {
|
||||||
recursionFn(list, t);
|
recursionFn(list, t);
|
||||||
|
|
@ -415,9 +396,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||||
*/
|
*/
|
||||||
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) {
|
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) {
|
||||||
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
List<SysMenu> tlist = new ArrayList<SysMenu>();
|
||||||
Iterator<SysMenu> it = list.iterator();
|
for (SysMenu n : list) {
|
||||||
while (it.hasNext()) {
|
|
||||||
SysMenu n = (SysMenu) it.next();
|
|
||||||
if (n.getParentId().longValue() == t.getMenuId().longValue()) {
|
if (n.getParentId().longValue() == t.getMenuId().longValue()) {
|
||||||
tlist.add(n);
|
tlist.add(n);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
import com.ruoyi.system.mapper.SysPostMapper;
|
import com.ruoyi.system.mapper.SysPostMapper;
|
||||||
import com.ruoyi.system.mapper.SysUserPostMapper;
|
import com.ruoyi.system.mapper.SysUserPostMapper;
|
||||||
|
|
@ -76,9 +76,9 @@ public class SysPostServiceImpl implements ISysPostService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkPostNameUnique(SysPost post) {
|
public String checkPostNameUnique(SysPost post) {
|
||||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
Long postId = ObjectUtil.isNull(post.getPostId()) ? -1L : post.getPostId();
|
||||||
SysPost info = postMapper.checkPostNameUnique(post.getPostName());
|
SysPost info = postMapper.checkPostNameUnique(post.getPostName());
|
||||||
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
@ -92,9 +92,9 @@ public class SysPostServiceImpl implements ISysPostService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkPostCodeUnique(SysPost post) {
|
public String checkPostCodeUnique(SysPost post) {
|
||||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
Long postId = ObjectUtil.isNull(post.getPostId()) ? -1L : post.getPostId();
|
||||||
SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
|
SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
|
||||||
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.domain.SysRole;
|
import com.ruoyi.system.api.domain.SysRole;
|
||||||
|
|
@ -81,7 +82,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||||
List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
|
List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
|
||||||
Set<String> permsSet = new HashSet<>();
|
Set<String> permsSet = new HashSet<>();
|
||||||
for (SysRole perm : perms) {
|
for (SysRole perm : perms) {
|
||||||
if (StringUtils.isNotNull(perm)) {
|
if (ObjectUtil.isNotNull(perm)) {
|
||||||
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
|
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -128,9 +129,9 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkRoleNameUnique(SysRole role) {
|
public String checkRoleNameUnique(SysRole role) {
|
||||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
Long roleId = ObjectUtil.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||||
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
|
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
|
||||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
@ -144,9 +145,9 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkRoleKeyUnique(SysRole role) {
|
public String checkRoleKeyUnique(SysRole role) {
|
||||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
Long roleId = ObjectUtil.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||||
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
|
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
|
||||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
@ -159,7 +160,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkRoleAllowed(SysRole role) {
|
public void checkRoleAllowed(SysRole role) {
|
||||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) {
|
if (ObjectUtil.isNotNull(role.getRoleId()) && role.isAdmin()) {
|
||||||
throw new ServiceException("不允许操作超级管理员角色");
|
throw new ServiceException("不允许操作超级管理员角色");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +176,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||||
SysRole role = new SysRole();
|
SysRole role = new SysRole();
|
||||||
role.setRoleId(roleId);
|
role.setRoleId(roleId);
|
||||||
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||||
if (StringUtils.isEmpty(roles)) {
|
if (CollUtil.isEmpty(roles)) {
|
||||||
throw new ServiceException("没有权限访问角色数据!");
|
throw new ServiceException("没有权限访问角色数据!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
import com.ruoyi.system.domain.SysUserOnline;
|
import com.ruoyi.system.domain.SysUserOnline;
|
||||||
|
|
@ -67,7 +68,7 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysUserOnline loginUserToUserOnline(LoginUser user) {
|
public SysUserOnline loginUserToUserOnline(LoginUser user) {
|
||||||
if (StringUtils.isNull(user)) {
|
if (ObjectUtil.isNull(user)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
SysUserOnline sysUserOnline = new SysUserOnline();
|
SysUserOnline sysUserOnline = new SysUserOnline();
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.exception.ServiceException;
|
import com.ruoyi.common.core.exception.ServiceException;
|
||||||
import com.ruoyi.common.core.utils.SpringUtils;
|
import com.ruoyi.common.core.utils.SpringUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.utils.bean.BeanValidators;
|
|
||||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.system.api.domain.SysRole;
|
import com.ruoyi.system.api.domain.SysRole;
|
||||||
|
|
@ -156,9 +157,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkPhoneUnique(SysUser user) {
|
public String checkPhoneUnique(SysUser user) {
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = ObjectUtil.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
@ -172,9 +173,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String checkEmailUnique(SysUser user) {
|
public String checkEmailUnique(SysUser user) {
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = ObjectUtil.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
||||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
if (ObjectUtil.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
|
|
@ -187,7 +188,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkUserAllowed(SysUser user) {
|
public void checkUserAllowed(SysUser user) {
|
||||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
|
if (ObjectUtil.isNotNull(user.getUserId()) && user.isAdmin()) {
|
||||||
throw new ServiceException("不允许操作超级管理员用户");
|
throw new ServiceException("不允许操作超级管理员用户");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +204,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
SysUser user = new SysUser();
|
SysUser user = new SysUser();
|
||||||
user.setUserId(userId);
|
user.setUserId(userId);
|
||||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||||
if (StringUtils.isEmpty(users)) {
|
if (CollUtil.isEmpty(users)) {
|
||||||
throw new ServiceException("没有权限访问用户数据!");
|
throw new ServiceException("没有权限访问用户数据!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +337,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
*/
|
*/
|
||||||
public void insertUserRole(SysUser user) {
|
public void insertUserRole(SysUser user) {
|
||||||
Long[] roles = user.getRoleIds();
|
Long[] roles = user.getRoleIds();
|
||||||
if (StringUtils.isNotNull(roles)) {
|
if (ObjectUtil.isNotNull(roles)) {
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||||
for (Long roleId : roles) {
|
for (Long roleId : roles) {
|
||||||
|
|
@ -358,7 +359,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
*/
|
*/
|
||||||
public void insertUserPost(SysUser user) {
|
public void insertUserPost(SysUser user) {
|
||||||
Long[] posts = user.getPostIds();
|
Long[] posts = user.getPostIds();
|
||||||
if (StringUtils.isNotNull(posts)) {
|
if (ObjectUtil.isNotNull(posts)) {
|
||||||
// 新增用户与岗位管理
|
// 新增用户与岗位管理
|
||||||
List<SysUserPost> list = new ArrayList<SysUserPost>();
|
List<SysUserPost> list = new ArrayList<SysUserPost>();
|
||||||
for (Long postId : posts) {
|
for (Long postId : posts) {
|
||||||
|
|
@ -380,7 +381,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
* @param roleIds 角色组
|
* @param roleIds 角色组
|
||||||
*/
|
*/
|
||||||
public void insertUserRole(Long userId, Long[] roleIds) {
|
public void insertUserRole(Long userId, Long[] roleIds) {
|
||||||
if (StringUtils.isNotNull(roleIds)) {
|
if (ObjectUtil.isNotNull(roleIds)) {
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||||
for (Long roleId : roleIds) {
|
for (Long roleId : roleIds) {
|
||||||
|
|
@ -430,59 +431,4 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
return userMapper.deleteUserByIds(userIds);
|
return userMapper.deleteUserByIds(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入用户数据
|
|
||||||
*
|
|
||||||
* @param userList 用户数据列表
|
|
||||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
|
||||||
* @param operName 操作用户
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
|
|
||||||
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
|
||||||
throw new ServiceException("导入用户数据不能为空!");
|
|
||||||
}
|
|
||||||
int successNum = 0;
|
|
||||||
int failureNum = 0;
|
|
||||||
StringBuilder successMsg = new StringBuilder();
|
|
||||||
StringBuilder failureMsg = new StringBuilder();
|
|
||||||
String password = configService.selectConfigByKey("sys.user.initPassword");
|
|
||||||
for (SysUser user : userList) {
|
|
||||||
try {
|
|
||||||
// 验证是否存在这个用户
|
|
||||||
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
|
||||||
if (StringUtils.isNull(u)) {
|
|
||||||
BeanValidators.validateWithException(validator, user);
|
|
||||||
user.setPassword(SecurityUtils.encryptPassword(password));
|
|
||||||
user.setCreateBy(operName);
|
|
||||||
this.insertUser(user);
|
|
||||||
successNum++;
|
|
||||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
|
||||||
} else if (isUpdateSupport) {
|
|
||||||
BeanValidators.validateWithException(validator, user);
|
|
||||||
user.setUpdateBy(operName);
|
|
||||||
this.updateUser(user);
|
|
||||||
successNum++;
|
|
||||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
|
||||||
} else {
|
|
||||||
failureNum++;
|
|
||||||
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
failureNum++;
|
|
||||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
|
||||||
failureMsg.append(msg + e.getMessage());
|
|
||||||
log.error(msg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (failureNum > 0) {
|
|
||||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
||||||
throw new ServiceException(failureMsg.toString());
|
|
||||||
} else {
|
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
||||||
}
|
|
||||||
return successMsg.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,37 @@ spring:
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: @profiles.active@
|
active: @profiles.active@
|
||||||
|
---
|
||||||
|
spring:
|
||||||
|
rabbitmq:
|
||||||
|
host: 81.70.150.73
|
||||||
|
port: 5672
|
||||||
|
username: lihongbo
|
||||||
|
password: lihongbo.123
|
||||||
|
cloud:
|
||||||
|
stream:
|
||||||
|
function:
|
||||||
|
# 重点配置 与 binding 名与消费者对应
|
||||||
|
definition: delay
|
||||||
|
rabbit:
|
||||||
|
bindings:
|
||||||
|
delay-in-0:
|
||||||
|
consumer:
|
||||||
|
delayedExchange: true
|
||||||
|
delay-out-0:
|
||||||
|
producer:
|
||||||
|
delayedExchange: true
|
||||||
|
bindings:
|
||||||
|
delay-in-0:
|
||||||
|
destination: delay.exchange.cloud
|
||||||
|
content-type: application/json
|
||||||
|
group: delay-group
|
||||||
|
binder: rabbit
|
||||||
|
delay-out-0:
|
||||||
|
destination: delay.exchange.cloud
|
||||||
|
content-type: application/json
|
||||||
|
group: delay-group
|
||||||
|
binder: rabbit
|
||||||
|
|
||||||
--- # nacos 配置
|
--- # nacos 配置
|
||||||
spring:
|
spring:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Tomcat
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
port: 18000
|
port: 18001
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue