update 统一代码间隔符

This commit is contained in:
疯狂的狮子li 2022-01-11 16:58:47 +08:00
parent fc8c96399f
commit 26fc652d33
51 changed files with 2184 additions and 2182 deletions

View File

@ -13,73 +13,73 @@ import com.ruoyi.common.utils.StringUtils;
*/ */
public class UnsignedMathGenerator implements CodeGenerator { public class UnsignedMathGenerator implements CodeGenerator {
private static final long serialVersionUID = -5514819971774091076L; private static final long serialVersionUID = -5514819971774091076L;
private static final String operators = "+-*"; private static final String operators = "+-*";
/** /**
* 参与计算数字最大长度 * 参与计算数字最大长度
*/ */
private final int numberLength; private final int numberLength;
/** /**
* 构造 * 构造
*/ */
public UnsignedMathGenerator() { public UnsignedMathGenerator() {
this(2); this(2);
} }
/** /**
* 构造 * 构造
* *
* @param numberLength 参与计算最大数字位数 * @param numberLength 参与计算最大数字位数
*/ */
public UnsignedMathGenerator(int numberLength) { public UnsignedMathGenerator(int numberLength) {
this.numberLength = numberLength; this.numberLength = numberLength;
} }
@Override @Override
public String generate() { public String generate() {
final int limit = getLimit(); final int limit = getLimit();
int min = RandomUtil.randomInt(limit); int min = RandomUtil.randomInt(limit);
int max = RandomUtil.randomInt(min, limit); int max = RandomUtil.randomInt(min, limit);
String number1 = Integer.toString(max); String number1 = Integer.toString(max);
String number2 = Integer.toString(min); String number2 = Integer.toString(min);
number1 = StringUtils.rightPad(number1, this.numberLength, CharUtil.SPACE); number1 = StringUtils.rightPad(number1, this.numberLength, CharUtil.SPACE);
number2 = StringUtils.rightPad(number2, this.numberLength, CharUtil.SPACE); number2 = StringUtils.rightPad(number2, this.numberLength, CharUtil.SPACE);
return number1 + RandomUtil.randomChar(operators) + number2 + '='; return number1 + RandomUtil.randomChar(operators) + number2 + '=';
} }
@Override @Override
public boolean verify(String code, String userInputCode) { public boolean verify(String code, String userInputCode) {
int result; int result;
try { try {
result = Integer.parseInt(userInputCode); result = Integer.parseInt(userInputCode);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// 用户输入非数字 // 用户输入非数字
return false; return false;
} }
final int calculateResult = (int) Calculator.conversion(code); final int calculateResult = (int) Calculator.conversion(code);
return result == calculateResult; return result == calculateResult;
} }
/** /**
* 获取验证码长度 * 获取验证码长度
* *
* @return 验证码长度 * @return 验证码长度
*/ */
public int getLength() { public int getLength() {
return this.numberLength * 2 + 2; return this.numberLength * 2 + 2;
} }
/** /**
* 根据长度获取参与计算数字最大值 * 根据长度获取参与计算数字最大值
* *
* @return 最大值 * @return 最大值
*/ */
private int getLimit() { private int getLimit() {
return Integer.parseInt("1" + StringUtils.repeat('0', this.numberLength)); return Integer.parseInt("1" + StringUtils.repeat('0', this.numberLength));
} }
} }

View File

@ -20,32 +20,32 @@ import java.math.BigDecimal;
@Slf4j @Slf4j
public class ExcelBigNumberConvert implements Converter<Long> { public class ExcelBigNumberConvert implements Converter<Long> {
@Override @Override
public Class<Long> supportJavaTypeKey() { public Class<Long> supportJavaTypeKey() {
return Long.class; return Long.class;
} }
@Override @Override
public CellDataTypeEnum supportExcelTypeKey() { public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING; return CellDataTypeEnum.STRING;
} }
@Override @Override
public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
return Convert.toLong(cellData.getData()); return Convert.toLong(cellData.getData());
} }
@Override @Override
public CellData<Object> convertToExcelData(Long object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { public CellData<Object> convertToExcelData(Long object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
if (ObjectUtil.isNotNull(object)) { if (ObjectUtil.isNotNull(object)) {
String str = Convert.toStr(object); String str = Convert.toStr(object);
if (str.length() > 15) { if (str.length() > 15) {
return new CellData<>(str); return new CellData<>(str);
} }
} }
CellData<Object> cellData = new CellData<>(new BigDecimal(object)); CellData<Object> cellData = new CellData<>(new BigDecimal(object));
cellData.setType(CellDataTypeEnum.NUMBER); cellData.setType(CellDataTypeEnum.NUMBER);
return cellData; return cellData;
} }
} }

View File

@ -24,48 +24,48 @@ import java.lang.reflect.Field;
@Slf4j @Slf4j
public class ExcelDictConvert implements Converter<Object> { public class ExcelDictConvert implements Converter<Object> {
@Override @Override
public Class<Object> supportJavaTypeKey() { public Class<Object> supportJavaTypeKey() {
return Object.class; return Object.class;
} }
@Override @Override
public CellDataTypeEnum supportExcelTypeKey() { public CellDataTypeEnum supportExcelTypeKey() {
return null; return null;
} }
@Override @Override
public Object convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { public Object convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
ExcelDictFormat anno = getAnnotation(contentProperty.getField()); ExcelDictFormat anno = getAnnotation(contentProperty.getField());
String type = anno.dictType(); String type = anno.dictType();
String label = cellData.getStringValue(); String label = cellData.getStringValue();
String value; String value;
if (StringUtils.isBlank(type)) { if (StringUtils.isBlank(type)) {
value = ExcelUtil.reverseByExp(label, anno.readConverterExp(), anno.separator()); value = ExcelUtil.reverseByExp(label, anno.readConverterExp(), anno.separator());
} else { } else {
value = SpringUtils.getBean(DictService.class).getDictValue(type, label, anno.separator()); value = SpringUtils.getBean(DictService.class).getDictValue(type, label, anno.separator());
} }
return Convert.convert(contentProperty.getField().getType(), value); return Convert.convert(contentProperty.getField().getType(), value);
} }
@Override @Override
public CellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { public CellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
if (StringUtils.isNull(object)) { if (StringUtils.isNull(object)) {
return new CellData<>(""); return new CellData<>("");
} }
ExcelDictFormat anno = getAnnotation(contentProperty.getField()); ExcelDictFormat anno = getAnnotation(contentProperty.getField());
String type = anno.dictType(); String type = anno.dictType();
String value = Convert.toStr(object); String value = Convert.toStr(object);
String label; String label;
if (StringUtils.isBlank(type)) { if (StringUtils.isBlank(type)) {
label = ExcelUtil.convertByExp(value, anno.readConverterExp(), anno.separator()); label = ExcelUtil.convertByExp(value, anno.readConverterExp(), anno.separator());
} else { } else {
label = SpringUtils.getBean(DictService.class).getDictLabel(type, value, anno.separator()); label = SpringUtils.getBean(DictService.class).getDictLabel(type, value, anno.separator());
} }
return new CellData<>(label); return new CellData<>(label);
} }
private ExcelDictFormat getAnnotation(Field field) { private ExcelDictFormat getAnnotation(Field field) {
return AnnotationUtil.getAnnotation(field, ExcelDictFormat.class); return AnnotationUtil.getAnnotation(field, ExcelDictFormat.class);
} }
} }

View File

@ -20,115 +20,115 @@ import lombok.experimental.Accessors;
@ApiModel("请求响应对象") @ApiModel("请求响应对象")
public class AjaxResult<T> { public class AjaxResult<T> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 状态码 * 状态码
*/ */
@ApiModelProperty("消息状态码") @ApiModelProperty("消息状态码")
private int code; private int code;
/** /**
* 返回内容 * 返回内容
*/ */
@ApiModelProperty("消息内容") @ApiModelProperty("消息内容")
private String msg; private String msg;
/** /**
* 数据对象 * 数据对象
*/ */
@ApiModelProperty("数据对象") @ApiModelProperty("数据对象")
private T data; private T data;
/** /**
* 初始化一个新创建的 AjaxResult 对象 * 初始化一个新创建的 AjaxResult 对象
* *
* @param code 状态码 * @param code 状态码
* @param msg 返回内容 * @param msg 返回内容
*/ */
public AjaxResult(int code, String msg) { public AjaxResult(int code, String msg) {
this.code = code; this.code = code;
this.msg = msg; this.msg = msg;
} }
/** /**
* 返回成功消息 * 返回成功消息
* *
* @return 成功消息 * @return 成功消息
*/ */
public static AjaxResult<Void> success() { public static AjaxResult<Void> success() {
return AjaxResult.success("操作成功"); return AjaxResult.success("操作成功");
} }
/** /**
* 返回成功数据 * 返回成功数据
* *
* @return 成功消息 * @return 成功消息
*/ */
public static <T> AjaxResult<T> success(T data) { public static <T> AjaxResult<T> success(T data) {
return AjaxResult.success("操作成功", data); return AjaxResult.success("操作成功", data);
} }
/** /**
* 返回成功消息 * 返回成功消息
* *
* @param msg 返回内容 * @param msg 返回内容
* @return 成功消息 * @return 成功消息
*/ */
public static AjaxResult<Void> success(String msg) { public static AjaxResult<Void> success(String msg) {
return AjaxResult.success(msg, null); return AjaxResult.success(msg, null);
} }
/** /**
* 返回成功消息 * 返回成功消息
* *
* @param msg 返回内容 * @param msg 返回内容
* @param data 数据对象 * @param data 数据对象
* @return 成功消息 * @return 成功消息
*/ */
public static <T> AjaxResult<T> success(String msg, T data) { public static <T> AjaxResult<T> success(String msg, T data) {
return new AjaxResult<>(HttpStatus.HTTP_OK, msg, data); return new AjaxResult<>(HttpStatus.HTTP_OK, msg, data);
} }
/** /**
* 返回错误消息 * 返回错误消息
* *
* @return * @return
*/ */
public static AjaxResult<Void> error() { public static AjaxResult<Void> error() {
return AjaxResult.error("操作失败"); return AjaxResult.error("操作失败");
} }
/** /**
* 返回错误消息 * 返回错误消息
* *
* @param msg 返回内容 * @param msg 返回内容
* @return 警告消息 * @return 警告消息
*/ */
public static AjaxResult<Void> error(String msg) { public static AjaxResult<Void> error(String msg) {
return AjaxResult.error(msg, null); return AjaxResult.error(msg, null);
} }
/** /**
* 返回错误消息 * 返回错误消息
* *
* @param msg 返回内容 * @param msg 返回内容
* @param data 数据对象 * @param data 数据对象
* @return 警告消息 * @return 警告消息
*/ */
public static <T> AjaxResult<T> error(String msg, T data) { public static <T> AjaxResult<T> error(String msg, T data) {
return new AjaxResult<>(HttpStatus.HTTP_INTERNAL_ERROR, msg, data); return new AjaxResult<>(HttpStatus.HTTP_INTERNAL_ERROR, msg, data);
} }
/** /**
* 返回错误消息 * 返回错误消息
* *
* @param code 状态码 * @param code 状态码
* @param msg 返回内容 * @param msg 返回内容
* @return 警告消息 * @return 警告消息
*/ */
public static AjaxResult<Void> error(int code, String msg) { public static AjaxResult<Void> error(int code, String msg) {
return new AjaxResult<>(code, msg, null); return new AjaxResult<>(code, msg, null);
} }
} }

View File

@ -21,48 +21,48 @@ import java.util.Map;
@Accessors(chain = true) @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 = "搜索值") @ApiModelProperty(value = "搜索值")
@TableField(exist = false) @TableField(exist = false)
private String searchValue; private String searchValue;
/** /**
* 创建者 * 创建者
*/ */
@ApiModelProperty(value = "创建者") @ApiModelProperty(value = "创建者")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private String createBy; private String createBy;
/** /**
* 创建时间 * 创建时间
*/ */
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
/** /**
* 更新者 * 更新者
*/ */
@ApiModelProperty(value = "更新者") @ApiModelProperty(value = "更新者")
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy; private String updateBy;
/** /**
* 更新时间 * 更新时间
*/ */
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "更新时间")
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime; private Date updateTime;
/** /**
* 请求参数 * 请求参数
*/ */
@ApiModelProperty(value = "请求参数") @ApiModelProperty(value = "请求参数")
@TableField(exist = false) @TableField(exist = false)
private Map<String, Object> params = new HashMap<>(); private Map<String, Object> params = new HashMap<>();
} }

View File

@ -21,7 +21,7 @@ import java.io.Serializable;
@Accessors(chain = true) @Accessors(chain = true)
public class PageQuery implements Serializable { public class PageQuery implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 分页大小 * 分页大小

View File

@ -20,26 +20,26 @@ import java.util.List;
@Accessors(chain = 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;
/** /**
* 父菜单名称 * 父菜单名称
*/ */
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "父菜单名称") @ApiModelProperty(value = "父菜单名称")
private String parentName; private String parentName;
/** /**
* 父菜单ID * 父菜单ID
*/ */
@ApiModelProperty(value = "父菜单ID") @ApiModelProperty(value = "父菜单ID")
private Long parentId; private Long parentId;
/** /**
* 子部门 * 子部门
*/ */
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "子部门") @ApiModelProperty(value = "子部门")
private List<?> children = new ArrayList<>(); private List<?> children = new ArrayList<>();
} }

View File

@ -26,68 +26,68 @@ import javax.validation.constraints.Size;
@TableName("sys_dept") @TableName("sys_dept")
@ApiModel("部门业务对象") @ApiModel("部门业务对象")
public class SysDept extends TreeEntity { public class SysDept extends TreeEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 部门ID * 部门ID
*/ */
@ApiModelProperty(value = "部门id") @ApiModelProperty(value = "部门id")
@TableId(value = "dept_id") @TableId(value = "dept_id")
private Long deptId; private Long deptId;
/** /**
* 部门名称 * 部门名称
*/ */
@ApiModelProperty(value = "部门名称") @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;
/** /**
* 显示顺序 * 显示顺序
*/ */
@ApiModelProperty(value = "显示顺序") @ApiModelProperty(value = "显示顺序")
@NotBlank(message = "显示顺序不能为空") @NotBlank(message = "显示顺序不能为空")
private String orderNum; private String orderNum;
/** /**
* 负责人 * 负责人
*/ */
@ApiModelProperty(value = "负责人") @ApiModelProperty(value = "负责人")
private String leader; private String leader;
/** /**
* 联系电话 * 联系电话
*/ */
@ApiModelProperty(value = "联系电话") @ApiModelProperty(value = "联系电话")
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
private String phone; private String phone;
/** /**
* 邮箱 * 邮箱
*/ */
@ApiModelProperty(value = "邮箱") @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;
/** /**
* 部门状态:0正常,1停用 * 部门状态:0正常,1停用
*/ */
@ApiModelProperty(value = "部门状态:0正常,1停用") @ApiModelProperty(value = "部门状态:0正常,1停用")
private String status; private String status;
/** /**
* 删除标志0代表存在 2代表删除 * 删除标志0代表存在 2代表删除
*/ */
@ApiModelProperty(value = "删除标志0代表存在 2代表删除") @ApiModelProperty(value = "删除标志0代表存在 2代表删除")
@TableLogic @TableLogic
private String delFlag; private String delFlag;
/** /**
* 祖级列表 * 祖级列表
*/ */
@ApiModelProperty(value = "祖级列表") @ApiModelProperty(value = "祖级列表")
private String ancestors; private String ancestors;
} }

View File

@ -31,85 +31,85 @@ import javax.validation.constraints.Size;
@ApiModel("字典数据业务对象") @ApiModel("字典数据业务对象")
public class SysDictData extends BaseEntity { public class SysDictData extends BaseEntity {
/** /**
* 字典编码 * 字典编码
*/ */
@ApiModelProperty(value = "字典编码") @ApiModelProperty(value = "字典编码")
@ExcelProperty(value = "字典编码") @ExcelProperty(value = "字典编码")
@TableId(value = "dict_code") @TableId(value = "dict_code")
private Long dictCode; private Long dictCode;
/** /**
* 字典排序 * 字典排序
*/ */
@ApiModelProperty(value = "字典排序") @ApiModelProperty(value = "字典排序")
@ExcelProperty(value = "字典排序") @ExcelProperty(value = "字典排序")
private Long dictSort; private Long dictSort;
/** /**
* 字典标签 * 字典标签
*/ */
@ApiModelProperty(value = "字典标签") @ApiModelProperty(value = "字典标签")
@ExcelProperty(value = "字典标签") @ExcelProperty(value = "字典标签")
@NotBlank(message = "字典标签不能为空") @NotBlank(message = "字典标签不能为空")
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
private String dictLabel; private String dictLabel;
/** /**
* 字典键值 * 字典键值
*/ */
@ApiModelProperty(value = "字典键值") @ApiModelProperty(value = "字典键值")
@ExcelProperty(value = "字典键值") @ExcelProperty(value = "字典键值")
@NotBlank(message = "字典键值不能为空") @NotBlank(message = "字典键值不能为空")
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
private String dictValue; private String dictValue;
/** /**
* 字典类型 * 字典类型
*/ */
@ApiModelProperty(value = "字典类型") @ApiModelProperty(value = "字典类型")
@ExcelProperty(value = "字典类型") @ExcelProperty(value = "字典类型")
@NotBlank(message = "字典类型不能为空") @NotBlank(message = "字典类型不能为空")
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
private String dictType; private String dictType;
/** /**
* 样式属性其他样式扩展 * 样式属性其他样式扩展
*/ */
@ApiModelProperty(value = "样式属性(其他样式扩展)") @ApiModelProperty(value = "样式属性(其他样式扩展)")
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
private String cssClass; private String cssClass;
/** /**
* 表格字典样式 * 表格字典样式
*/ */
@ApiModelProperty(value = "表格字典样式") @ApiModelProperty(value = "表格字典样式")
private String listClass; private String listClass;
/** /**
* 是否默认Y是 N否 * 是否默认Y是 N否
*/ */
@ApiModelProperty(value = "是否默认Y是 N否") @ApiModelProperty(value = "是否默认Y是 N否")
@ExcelProperty(value = "是否默认", converter = ExcelDictConvert.class) @ExcelProperty(value = "是否默认", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_yes_no") @ExcelDictFormat(dictType = "sys_yes_no")
private String isDefault; private String isDefault;
/** /**
* 状态0正常 1停用 * 状态0正常 1停用
*/ */
@ApiModelProperty(value = "状态0正常 1停用") @ApiModelProperty(value = "状态0正常 1停用")
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class) @ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_normal_disable") @ExcelDictFormat(dictType = "sys_normal_disable")
private String status; private String status;
/** /**
* 备注 * 备注
*/ */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remark; private String remark;
public boolean getDefault() { public boolean getDefault() {
return UserConstants.YES.equals(this.isDefault); return UserConstants.YES.equals(this.isDefault);
} }
} }

View File

@ -30,44 +30,44 @@ import javax.validation.constraints.Size;
@ApiModel("字典类型业务对象") @ApiModel("字典类型业务对象")
public class SysDictType extends BaseEntity { public class SysDictType extends BaseEntity {
/** /**
* 字典主键 * 字典主键
*/ */
@ApiModelProperty(value = "字典主键") @ApiModelProperty(value = "字典主键")
@ExcelProperty(value = "字典主键") @ExcelProperty(value = "字典主键")
@TableId(value = "dict_id") @TableId(value = "dict_id")
private Long dictId; private Long dictId;
/** /**
* 字典名称 * 字典名称
*/ */
@ApiModelProperty(value = "字典名称") @ApiModelProperty(value = "字典名称")
@ExcelProperty(value = "字典名称") @ExcelProperty(value = "字典名称")
@NotBlank(message = "字典名称不能为空") @NotBlank(message = "字典名称不能为空")
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
private String dictName; private String dictName;
/** /**
* 字典类型 * 字典类型
*/ */
@ApiModelProperty(value = "字典类型") @ApiModelProperty(value = "字典类型")
@ExcelProperty(value = "字典类型") @ExcelProperty(value = "字典类型")
@NotBlank(message = "字典类型不能为空") @NotBlank(message = "字典类型不能为空")
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
private String dictType; private String dictType;
/** /**
* 状态0正常 1停用 * 状态0正常 1停用
*/ */
@ApiModelProperty(value = "状态0正常 1停用") @ApiModelProperty(value = "状态0正常 1停用")
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class) @ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_normal_disable") @ExcelDictFormat(dictType = "sys_normal_disable")
private String status; private String status;
/** /**
* 备注 * 备注
*/ */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remark; private String remark;
} }

View File

@ -26,97 +26,97 @@ import javax.validation.constraints.Size;
@ApiModel("菜单权限业务对象") @ApiModel("菜单权限业务对象")
public class SysMenu extends TreeEntity { public class SysMenu extends TreeEntity {
/** /**
* 菜单ID * 菜单ID
*/ */
@ApiModelProperty(value = "菜单ID") @ApiModelProperty(value = "菜单ID")
@TableId(value = "menu_id") @TableId(value = "menu_id")
private Long menuId; private Long menuId;
/** /**
* 菜单名称 * 菜单名称
*/ */
@ApiModelProperty(value = "菜单名称") @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;
/** /**
* 显示顺序 * 显示顺序
*/ */
@ApiModelProperty(value = "显示顺序") @ApiModelProperty(value = "显示顺序")
@NotBlank(message = "显示顺序不能为空") @NotBlank(message = "显示顺序不能为空")
private String orderNum; private String orderNum;
/** /**
* 路由地址 * 路由地址
*/ */
@ApiModelProperty(value = "路由地址") @ApiModelProperty(value = "路由地址")
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符") @Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
private String path; private String path;
/** /**
* 组件路径 * 组件路径
*/ */
@ApiModelProperty(value = "组件路径") @ApiModelProperty(value = "组件路径")
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符") @Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
private String component; private String component;
/** /**
* 路由参数 * 路由参数
*/ */
@ApiModelProperty(value = "路由参数") @ApiModelProperty(value = "路由参数")
@TableField("`query`") @TableField("`query`")
private String query; private String query;
/** /**
* 是否为外链0是 1否 * 是否为外链0是 1否
*/ */
@ApiModelProperty(value = "是否为外链0是 1否") @ApiModelProperty(value = "是否为外链0是 1否")
private String isFrame; private String isFrame;
/** /**
* 是否缓存0缓存 1不缓存 * 是否缓存0缓存 1不缓存
*/ */
@ApiModelProperty(value = "是否缓存0缓存 1不缓存") @ApiModelProperty(value = "是否缓存0缓存 1不缓存")
private String isCache; private String isCache;
/** /**
* 类型M目录 C菜单 F按钮 * 类型M目录 C菜单 F按钮
*/ */
@ApiModelProperty(value = "类型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隐藏") @ApiModelProperty(value = "显示状态0显示 1隐藏")
private String visible; private String visible;
/** /**
* 菜单状态0显示 1隐藏 * 菜单状态0显示 1隐藏
*/ */
@ApiModelProperty(value = "菜单状态0显示 1隐藏") @ApiModelProperty(value = "菜单状态0显示 1隐藏")
private String status; private String status;
/** /**
* 权限字符串 * 权限字符串
*/ */
@ApiModelProperty(value = "权限字符串") @ApiModelProperty(value = "权限字符串")
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符") @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
private String perms; private String perms;
/** /**
* 菜单图标 * 菜单图标
*/ */
@ApiModelProperty(value = "菜单图标") @ApiModelProperty(value = "菜单图标")
private String icon; private String icon;
/** /**
* 备注 * 备注
*/ */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remark; private String remark;
} }

View File

@ -32,113 +32,113 @@ import javax.validation.constraints.Size;
@ExcelIgnoreUnannotated @ExcelIgnoreUnannotated
public class SysRole extends BaseEntity { public class SysRole extends BaseEntity {
/** /**
* 角色ID * 角色ID
*/ */
@ApiModelProperty(value = "角色ID") @ApiModelProperty(value = "角色ID")
@ExcelProperty(value = "角色序号") @ExcelProperty(value = "角色序号")
@TableId(value = "role_id") @TableId(value = "role_id")
private Long roleId; private Long roleId;
/** /**
* 角色名称 * 角色名称
*/ */
@ApiModelProperty(value = "角色名称") @ApiModelProperty(value = "角色名称")
@ExcelProperty(value = "角色名称") @ExcelProperty(value = "角色名称")
@NotBlank(message = "角色名称不能为空") @NotBlank(message = "角色名称不能为空")
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
private String roleName; private String roleName;
/** /**
* 角色权限 * 角色权限
*/ */
@ApiModelProperty(value = "角色权限") @ApiModelProperty(value = "角色权限")
@ExcelProperty(value = "角色权限") @ExcelProperty(value = "角色权限")
@NotBlank(message = "权限字符不能为空") @NotBlank(message = "权限字符不能为空")
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
private String roleKey; private String roleKey;
/** /**
* 角色排序 * 角色排序
*/ */
@ApiModelProperty(value = "角色排序") @ApiModelProperty(value = "角色排序")
@ExcelProperty(value = "角色排序") @ExcelProperty(value = "角色排序")
@NotBlank(message = "显示顺序不能为空") @NotBlank(message = "显示顺序不能为空")
private String roleSort; private String roleSort;
/** /**
* 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限5仅本人数据权限 * 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限5仅本人数据权限
*/ */
@ApiModelProperty(value = "数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限5仅本人数据权限") @ApiModelProperty(value = "数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限5仅本人数据权限")
@ExcelProperty(value = "数据范围", converter = ExcelDictConvert.class) @ExcelProperty(value = "数据范围", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") @ExcelDictFormat(readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
private String dataScope; private String dataScope;
/** /**
* 菜单树选择项是否关联显示 0父子不互相关联显示 1父子互相关联显示 * 菜单树选择项是否关联显示 0父子不互相关联显示 1父子互相关联显示
*/ */
@ApiModelProperty(value = "菜单树选择项是否关联显示( 0父子不互相关联显示 1父子互相关联显示") @ApiModelProperty(value = "菜单树选择项是否关联显示( 0父子不互相关联显示 1父子互相关联显示")
private boolean menuCheckStrictly; private boolean menuCheckStrictly;
/** /**
* 部门树选择项是否关联显示0父子不互相关联显示 1父子互相关联显示 * 部门树选择项是否关联显示0父子不互相关联显示 1父子互相关联显示
*/ */
@ApiModelProperty(value = "部门树选择项是否关联显示0父子不互相关联显示 1父子互相关联显示 ") @ApiModelProperty(value = "部门树选择项是否关联显示0父子不互相关联显示 1父子互相关联显示 ")
private boolean deptCheckStrictly; private boolean deptCheckStrictly;
/** /**
* 角色状态0正常 1停用 * 角色状态0正常 1停用
*/ */
@ApiModelProperty(value = "角色状态0正常 1停用") @ApiModelProperty(value = "角色状态0正常 1停用")
@ExcelProperty(value = "角色状态", converter = ExcelDictConvert.class) @ExcelProperty(value = "角色状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_common_status") @ExcelDictFormat(dictType = "sys_common_status")
private String status; private String status;
/** /**
* 删除标志0代表存在 2代表删除 * 删除标志0代表存在 2代表删除
*/ */
@ApiModelProperty(value = "删除标志0代表存在 2代表删除") @ApiModelProperty(value = "删除标志0代表存在 2代表删除")
@TableLogic @TableLogic
private String delFlag; private String delFlag;
/** /**
* 备注 * 备注
*/ */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remark; private String remark;
/** /**
* 用户是否存在此角色标识 默认不存在 * 用户是否存在此角色标识 默认不存在
*/ */
@ApiModelProperty(value = "用户是否存在此角色标识 默认不存在") @ApiModelProperty(value = "用户是否存在此角色标识 默认不存在")
@TableField(exist = false) @TableField(exist = false)
private boolean flag = false; private boolean flag = false;
/** /**
* 菜单组 * 菜单组
*/ */
@ApiModelProperty(value = "菜单组") @ApiModelProperty(value = "菜单组")
@TableField(exist = false) @TableField(exist = false)
private Long[] menuIds; private Long[] menuIds;
/** /**
* 部门组数据权限 * 部门组数据权限
*/ */
@ApiModelProperty(value = "部门组(数据权限)") @ApiModelProperty(value = "部门组(数据权限)")
@TableField(exist = false) @TableField(exist = false)
private Long[] deptIds; private Long[] deptIds;
public SysRole(Long roleId) { public SysRole(Long roleId) {
this.roleId = roleId; this.roleId = roleId;
} }
@ApiModelProperty(value = "是否管理员") @ApiModelProperty(value = "是否管理员")
public boolean isAdmin() { public boolean isAdmin() {
return isAdmin(this.roleId); return isAdmin(this.roleId);
} }
public static boolean isAdmin(Long roleId) { public static boolean isAdmin(Long roleId) {
return roleId != null && 1L == roleId; return roleId != null && 1L == roleId;
} }
} }

View File

@ -34,158 +34,158 @@ import java.util.List;
@ApiModel("用户信息业务对象") @ApiModel("用户信息业务对象")
public class SysUser extends BaseEntity { public class SysUser extends BaseEntity {
/** /**
* 用户ID * 用户ID
*/ */
@ApiModelProperty(value = "用户ID") @ApiModelProperty(value = "用户ID")
@TableId(value = "user_id") @TableId(value = "user_id")
private Long userId; private Long userId;
/** /**
* 部门ID * 部门ID
*/ */
@ApiModelProperty(value = "部门ID") @ApiModelProperty(value = "部门ID")
private Long deptId; private Long deptId;
/** /**
* 用户账号 * 用户账号
*/ */
@ApiModelProperty(value = "用户账号") @ApiModelProperty(value = "用户账号")
@Xss(message = "用户账号不能包含脚本字符") @Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空") @NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符") @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
private String userName; private String userName;
/** /**
* 用户昵称 * 用户昵称
*/ */
@ApiModelProperty(value = "用户昵称") @ApiModelProperty(value = "用户昵称")
@Xss(message = "用户昵称不能包含脚本字符") @Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
private String nickName; private String nickName;
/** /**
* 用户邮箱 * 用户邮箱
*/ */
@Sensitive(strategy = SensitiveStrategy.EMAIL) @Sensitive(strategy = SensitiveStrategy.EMAIL)
@ApiModelProperty(value = "用户邮箱") @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;
/** /**
* 手机号码 * 手机号码
*/ */
@Sensitive(strategy = SensitiveStrategy.PHONE) @Sensitive(strategy = SensitiveStrategy.PHONE)
@ApiModelProperty(value = "手机号码") @ApiModelProperty(value = "手机号码")
private String phonenumber; private String phonenumber;
/** /**
* 用户性别 * 用户性别
*/ */
@ApiModelProperty(value = "用户性别") @ApiModelProperty(value = "用户性别")
private String sex; private String sex;
/** /**
* 用户头像 * 用户头像
*/ */
@ApiModelProperty(value = "用户头像") @ApiModelProperty(value = "用户头像")
private String avatar; private String avatar;
/** /**
* 密码 * 密码
*/ */
@ApiModelProperty(value = "密码") @ApiModelProperty(value = "密码")
@TableField( @TableField(
insertStrategy = FieldStrategy.NOT_EMPTY, insertStrategy = FieldStrategy.NOT_EMPTY,
updateStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY,
whereStrategy = FieldStrategy.NOT_EMPTY whereStrategy = FieldStrategy.NOT_EMPTY
) )
private String password; private String password;
@JsonIgnore @JsonIgnore
@JsonProperty @JsonProperty
public String getPassword() { public String getPassword() {
return password; return password;
} }
/** /**
* 帐号状态0正常 1停用 * 帐号状态0正常 1停用
*/ */
@ApiModelProperty(value = "帐号状态0正常 1停用") @ApiModelProperty(value = "帐号状态0正常 1停用")
private String status; private String status;
/** /**
* 删除标志0代表存在 2代表删除 * 删除标志0代表存在 2代表删除
*/ */
@ApiModelProperty(value = "删除标志0代表存在 2代表删除") @ApiModelProperty(value = "删除标志0代表存在 2代表删除")
@TableLogic @TableLogic
private String delFlag; private String delFlag;
/** /**
* 最后登录IP * 最后登录IP
*/ */
@ApiModelProperty(value = "最后登录IP") @ApiModelProperty(value = "最后登录IP")
private String loginIp; private String loginIp;
/** /**
* 最后登录时间 * 最后登录时间
*/ */
@ApiModelProperty(value = "最后登录时间") @ApiModelProperty(value = "最后登录时间")
private Date loginDate; private Date loginDate;
/** /**
* 备注 * 备注
*/ */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remark; private String remark;
/** /**
* 部门对象 * 部门对象
*/ */
@ApiModelProperty(value = "部门对象") @ApiModelProperty(value = "部门对象")
@TableField(exist = false) @TableField(exist = false)
private SysDept dept; private SysDept dept;
/** /**
* 角色对象 * 角色对象
*/ */
@ApiModelProperty(value = "角色对象") @ApiModelProperty(value = "角色对象")
@TableField(exist = false) @TableField(exist = false)
private List<SysRole> roles; private List<SysRole> roles;
/** /**
* 角色组 * 角色组
*/ */
@ApiModelProperty(value = "角色组") @ApiModelProperty(value = "角色组")
@TableField(exist = false) @TableField(exist = false)
private Long[] roleIds; private Long[] roleIds;
/** /**
* 岗位组 * 岗位组
*/ */
@ApiModelProperty(value = "岗位组") @ApiModelProperty(value = "岗位组")
@TableField(exist = false) @TableField(exist = false)
private Long[] postIds; private Long[] postIds;
/** /**
* 数据权限 当前角色ID * 数据权限 当前角色ID
*/ */
@ApiModelProperty(value = "角色ID") @ApiModelProperty(value = "角色ID")
@TableField(exist = false) @TableField(exist = false)
private Long roleId; private Long roleId;
public SysUser(Long userId) { public SysUser(Long userId) {
this.userId = userId; this.userId = userId;
} }
@ApiModelProperty(value = "是否管理员") @ApiModelProperty(value = "是否管理员")
public boolean isAdmin() { public boolean isAdmin() {
return isAdmin(this.userId); return isAdmin(this.userId);
} }
public static boolean isAdmin(Long userId) { public static boolean isAdmin(Long userId) {
return userId != null && 1L == userId; return userId != null && 1L == userId;
} }
} }

View File

@ -22,15 +22,15 @@ import java.util.Map;
*/ */
public interface BaseMapperPlus<T> extends BaseMapper<T> { public interface BaseMapperPlus<T> extends BaseMapper<T> {
/** /**
* 单sql批量插入( 全量填充 ) * 单sql批量插入( 全量填充 )
*/ */
int insertAll(@Param("list") Collection<T> batchList); int insertAll(@Param("list") Collection<T> batchList);
/** /**
* 根据 ID 查询 * 根据 ID 查询
*/ */
default <V> V selectVoById(Serializable id, Class<V> voClass){ default <V> V selectVoById(Serializable id, Class<V> voClass) {
T obj = this.selectById(id); T obj = this.selectById(id);
if (ObjectUtil.isNull(obj)) { if (ObjectUtil.isNull(obj)) {
return null; return null;
@ -41,7 +41,7 @@ public interface BaseMapperPlus<T> extends BaseMapper<T> {
/** /**
* 查询根据ID 批量查询 * 查询根据ID 批量查询
*/ */
default <V> List<V> selectVoBatchIds(Collection<? extends Serializable> idList, Class<V> voClass){ default <V> List<V> selectVoBatchIds(Collection<? extends Serializable> idList, Class<V> voClass) {
List<T> list = this.selectBatchIds(idList); List<T> list = this.selectBatchIds(idList);
if (CollUtil.isEmpty(list)) { if (CollUtil.isEmpty(list)) {
return CollUtil.newArrayList(); return CollUtil.newArrayList();
@ -52,7 +52,7 @@ public interface BaseMapperPlus<T> extends BaseMapper<T> {
/** /**
* 查询根据 columnMap 条件 * 查询根据 columnMap 条件
*/ */
default <V> List<V> selectVoByMap(Map<String, Object> map, Class<V> voClass){ default <V> List<V> selectVoByMap(Map<String, Object> map, Class<V> voClass) {
List<T> list = this.selectByMap(map); List<T> list = this.selectByMap(map);
if (CollUtil.isEmpty(list)) { if (CollUtil.isEmpty(list)) {
return CollUtil.newArrayList(); return CollUtil.newArrayList();

View File

@ -19,98 +19,98 @@ import java.util.function.Function;
*/ */
public interface IServicePlus<T, V> extends IService<T> { public interface IServicePlus<T, V> extends IService<T> {
/** /**
* @param id 主键id * @param id 主键id
* @return V对象 * @return V对象
*/ */
V getVoById(Serializable id); V getVoById(Serializable id);
/** /**
* @param convertor 自定义转换器 * @param convertor 自定义转换器
*/ */
default V getVoById(Serializable id, Function<T, V> convertor) { default V getVoById(Serializable id, Function<T, V> convertor) {
return convertor.apply(getById(id)); return convertor.apply(getById(id));
} }
/** /**
* @param idList id列表 * @param idList id列表
* @return V对象 * @return V对象
*/ */
List<V> listVoByIds(Collection<? extends Serializable> idList); List<V> listVoByIds(Collection<? extends Serializable> idList);
/** /**
* @param convertor 自定义转换器 * @param convertor 自定义转换器
*/ */
default List<V> listVoByIds(Collection<? extends Serializable> idList, default List<V> listVoByIds(Collection<? extends Serializable> idList,
Function<Collection<T>, List<V>> convertor) { Function<Collection<T>, List<V>> convertor) {
List<T> list = getBaseMapper().selectBatchIds(idList); List<T> list = getBaseMapper().selectBatchIds(idList);
if (list == null) { if (list == null) {
return null; return null;
} }
return convertor.apply(list); return convertor.apply(list);
} }
/** /**
* @param columnMap 表字段 map 对象 * @param columnMap 表字段 map 对象
* @return V对象 * @return V对象
*/ */
List<V> listVoByMap(Map<String, Object> columnMap); List<V> listVoByMap(Map<String, Object> columnMap);
/** /**
* @param convertor 自定义转换器 * @param convertor 自定义转换器
*/ */
default List<V> listVoByMap(Map<String, Object> columnMap, default List<V> listVoByMap(Map<String, Object> columnMap,
Function<Collection<T>, List<V>> convertor) { Function<Collection<T>, List<V>> convertor) {
List<T> list = getBaseMapper().selectByMap(columnMap); List<T> list = getBaseMapper().selectByMap(columnMap);
if (list == null) { if (list == null) {
return null; return null;
} }
return convertor.apply(list); return convertor.apply(list);
} }
/** /**
* @param queryWrapper 查询条件 * @param queryWrapper 查询条件
* @return V对象 * @return V对象
*/ */
V getVoOne(Wrapper<T> queryWrapper); V getVoOne(Wrapper<T> queryWrapper);
/** /**
* @param convertor 自定义转换器 * @param convertor 自定义转换器
*/ */
default V getVoOne(Wrapper<T> queryWrapper, Function<T, V> convertor) { default V getVoOne(Wrapper<T> queryWrapper, Function<T, V> convertor) {
return convertor.apply(getOne(queryWrapper, true)); return convertor.apply(getOne(queryWrapper, true));
} }
/** /**
* @param queryWrapper 查询条件 * @param queryWrapper 查询条件
* @return V对象 * @return V对象
*/ */
List<V> listVo(Wrapper<T> queryWrapper); List<V> listVo(Wrapper<T> queryWrapper);
/** /**
* @param convertor 自定义转换器 * @param convertor 自定义转换器
*/ */
default List<V> listVo(Wrapper<T> queryWrapper, Function<Collection<T>, List<V>> convertor) { default List<V> listVo(Wrapper<T> queryWrapper, Function<Collection<T>, List<V>> convertor) {
List<T> list = getBaseMapper().selectList(queryWrapper); List<T> list = getBaseMapper().selectList(queryWrapper);
if (list == null) { if (list == null) {
return null; return null;
} }
return convertor.apply(list); return convertor.apply(list);
} }
default List<V> listVo() { default List<V> listVo() {
return listVo(Wrappers.emptyWrapper()); return listVo(Wrappers.emptyWrapper());
} }
/** /**
* @param convertor 自定义转换器 * @param convertor 自定义转换器
*/ */
default List<V> listVo(Function<Collection<T>, List<V>> convertor) { default List<V> listVo(Function<Collection<T>, List<V>> convertor) {
return listVo(Wrappers.emptyWrapper(), convertor); return listVo(Wrappers.emptyWrapper(), convertor);
} }
boolean saveAll(Collection<T> entityList); boolean saveAll(Collection<T> entityList);
boolean saveOrUpdateAll(Collection<T> entityList); boolean saveOrUpdateAll(Collection<T> entityList);
} }

View File

@ -31,172 +31,172 @@ import java.util.Map;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, V> extends ServiceImpl<M, T> implements IServicePlus<T, V> { public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, V> extends ServiceImpl<M, T> implements IServicePlus<T, V> {
@Autowired @Autowired
protected M baseMapper; protected M baseMapper;
@Override @Override
public M getBaseMapper() { public M getBaseMapper() {
return baseMapper; return baseMapper;
} }
protected Class<T> entityClass = currentModelClass(); protected Class<T> entityClass = currentModelClass();
@Override @Override
public Class<T> getEntityClass() { public Class<T> getEntityClass() {
return entityClass; return entityClass;
} }
protected Class<M> mapperClass = currentMapperClass(); protected Class<M> mapperClass = currentMapperClass();
protected Class<V> voClass = currentVoClass(); protected Class<V> voClass = currentVoClass();
public Class<V> getVoClass() { public Class<V> getVoClass() {
return voClass; return voClass;
} }
@Override @Override
protected Class<M> currentMapperClass() { protected Class<M> currentMapperClass() {
return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 0); return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 0);
} }
@Override @Override
protected Class<T> currentModelClass() { protected Class<T> currentModelClass() {
return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 1); return (Class<T>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 1);
} }
protected Class<V> currentVoClass() { protected Class<V> currentVoClass() {
return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 2); return (Class<V>) ReflectionKit.getSuperClassGenericType(this.getClass(), ServicePlusImpl.class, 2);
} }
/** /**
* 单条执行性能差 适用于列表对象内容不确定 * 单条执行性能差 适用于列表对象内容不确定
*/ */
@Override @Override
public boolean saveBatch(Collection<T> entityList, int batchSize) { public boolean saveBatch(Collection<T> entityList, int batchSize) {
return super.saveBatch(entityList, batchSize); return super.saveBatch(entityList, batchSize);
} }
@Override @Override
public boolean saveOrUpdate(T entity) { public boolean saveOrUpdate(T entity) {
return super.saveOrUpdate(entity); return super.saveOrUpdate(entity);
} }
/** /**
* 单条执行性能差 适用于列表对象内容不确定 * 单条执行性能差 适用于列表对象内容不确定
*/ */
@Override @Override
public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) { public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) {
return super.saveOrUpdateBatch(entityList, batchSize); return super.saveOrUpdateBatch(entityList, batchSize);
} }
@Override @Override
public boolean updateBatchById(Collection<T> entityList, int batchSize) { public boolean updateBatchById(Collection<T> entityList, int batchSize) {
return super.updateBatchById(entityList, batchSize); return super.updateBatchById(entityList, batchSize);
} }
/** /**
* 单sql批量插入( 全量填充 无视数据库默认值 ) * 单sql批量插入( 全量填充 无视数据库默认值 )
* 适用于无脑插入 * 适用于无脑插入
*/ */
@Override @Override
public boolean saveBatch(Collection<T> entityList) { public boolean saveBatch(Collection<T> entityList) {
return saveBatch(entityList, DEFAULT_BATCH_SIZE); return saveBatch(entityList, DEFAULT_BATCH_SIZE);
} }
@Override @Override
public boolean saveOrUpdateBatch(Collection<T> entityList) { public boolean saveOrUpdateBatch(Collection<T> entityList) {
return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE); return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE);
} }
@Override @Override
public boolean updateBatchById(Collection<T> entityList) { public boolean updateBatchById(Collection<T> entityList) {
return updateBatchById(entityList, DEFAULT_BATCH_SIZE); return updateBatchById(entityList, DEFAULT_BATCH_SIZE);
} }
/** /**
* 单sql批量插入( 全量填充 ) * 单sql批量插入( 全量填充 )
*/ */
@Override @Override
public boolean saveAll(Collection<T> entityList) { public boolean saveAll(Collection<T> entityList) {
if (CollUtil.isEmpty(entityList)) { if (CollUtil.isEmpty(entityList)) {
return false; return false;
} }
return baseMapper.insertAll(entityList) == entityList.size(); return baseMapper.insertAll(entityList) == entityList.size();
} }
/** /**
* 全量保存或更新 ( 按主键区分 ) * 全量保存或更新 ( 按主键区分 )
*/ */
@Override @Override
public boolean saveOrUpdateAll(Collection<T> entityList) { public boolean saveOrUpdateAll(Collection<T> entityList) {
if (CollUtil.isEmpty(entityList)) { if (CollUtil.isEmpty(entityList)) {
return false; return false;
} }
TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass); TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
String keyProperty = tableInfo.getKeyProperty(); String keyProperty = tableInfo.getKeyProperty();
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!"); Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
List<T> addList = new ArrayList<>(); List<T> addList = new ArrayList<>();
List<T> updateList = new ArrayList<>(); List<T> updateList = new ArrayList<>();
int row = 0; int row = 0;
for (T entity : entityList) { for (T entity : entityList) {
Object id = ReflectUtils.invokeGetter(entity, keyProperty); Object id = ReflectUtils.invokeGetter(entity, keyProperty);
if (ObjectUtil.isNull(id)) { if (ObjectUtil.isNull(id)) {
addList.add(entity); addList.add(entity);
} else { } else {
updateList.add(entity); updateList.add(entity);
} }
} }
if (CollUtil.isNotEmpty(updateList) && updateBatchById(updateList)) { if (CollUtil.isNotEmpty(updateList) && updateBatchById(updateList)) {
row += updateList.size(); row += updateList.size();
} }
if (CollUtil.isNotEmpty(addList)) { if (CollUtil.isNotEmpty(addList)) {
row += baseMapper.insertAll(addList); row += baseMapper.insertAll(addList);
} }
return row == entityList.size(); return row == entityList.size();
} }
/** /**
* 根据 ID 查询 * 根据 ID 查询
*/ */
@Override @Override
public V getVoById(Serializable id) { public V getVoById(Serializable id) {
return getBaseMapper().selectVoById(id, voClass); return getBaseMapper().selectVoById(id, voClass);
} }
/** /**
* 查询根据ID 批量查询 * 查询根据ID 批量查询
*/ */
@Override @Override
public List<V> listVoByIds(Collection<? extends Serializable> idList) { public List<V> listVoByIds(Collection<? extends Serializable> idList) {
return getBaseMapper().selectVoBatchIds(idList, voClass); return getBaseMapper().selectVoBatchIds(idList, voClass);
} }
/** /**
* 查询根据 columnMap 条件 * 查询根据 columnMap 条件
*/ */
@Override @Override
public List<V> listVoByMap(Map<String, Object> columnMap) { public List<V> listVoByMap(Map<String, Object> columnMap) {
return getBaseMapper().selectVoByMap(columnMap, voClass); return getBaseMapper().selectVoByMap(columnMap, voClass);
} }
/** /**
* 根据 Wrapper查询一条记录 <br/> * 根据 Wrapper查询一条记录 <br/>
* <p>结果集如果是多个会抛出异常随机取一条加上限制条件 wrapper.last("LIMIT 1")</p> * <p>结果集如果是多个会抛出异常随机取一条加上限制条件 wrapper.last("LIMIT 1")</p>
*/ */
@Override @Override
public V getVoOne(Wrapper<T> queryWrapper) { public V getVoOne(Wrapper<T> queryWrapper) {
return getBaseMapper().selectVoOne(queryWrapper, voClass); return getBaseMapper().selectVoOne(queryWrapper, voClass);
} }
/** /**
* 查询列表 * 查询列表
*/ */
@Override @Override
public List<V> listVo(Wrapper<T> queryWrapper) { public List<V> listVo(Wrapper<T> queryWrapper) {
return getBaseMapper().selectVoList(queryWrapper, voClass); return getBaseMapper().selectVoList(queryWrapper, voClass);
} }
/** /**
* 翻页查询 * 翻页查询

View File

@ -21,81 +21,81 @@ import java.util.List;
*/ */
public class InsertAll extends AbstractMethod { public class InsertAll extends AbstractMethod {
private final static String[] FILL_PROPERTY = {"createTime", "createBy", "updateTime", "updateBy"}; private final static String[] FILL_PROPERTY = {"createTime", "createBy", "updateTime", "updateBy"};
@Override @Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) { public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
final String sql = "<script>insert into %s %s values %s</script>"; final String sql = "<script>insert into %s %s values %s</script>";
final String fieldSql = prepareFieldSql(tableInfo); final String fieldSql = prepareFieldSql(tableInfo);
final String valueSql = prepareValuesSqlForMysqlBatch(tableInfo); final String valueSql = prepareValuesSqlForMysqlBatch(tableInfo);
KeyGenerator keyGenerator = new NoKeyGenerator(); KeyGenerator keyGenerator = new NoKeyGenerator();
String sqlMethod = "insertAll"; String sqlMethod = "insertAll";
String keyProperty = null; String keyProperty = null;
String keyColumn = null; String keyColumn = null;
// 表包含主键处理逻辑,如果不包含主键当普通字段处理 // 表包含主键处理逻辑,如果不包含主键当普通字段处理
if (StringUtils.isNotBlank(tableInfo.getKeyProperty())) { if (StringUtils.isNotBlank(tableInfo.getKeyProperty())) {
if (tableInfo.getIdType() == IdType.AUTO) { if (tableInfo.getIdType() == IdType.AUTO) {
/** 自增主键 */ /** 自增主键 */
keyGenerator = new Jdbc3KeyGenerator(); keyGenerator = new Jdbc3KeyGenerator();
keyProperty = tableInfo.getKeyProperty(); keyProperty = tableInfo.getKeyProperty();
keyColumn = tableInfo.getKeyColumn(); keyColumn = tableInfo.getKeyColumn();
} else { } else {
if (null != tableInfo.getKeySequence()) { if (null != tableInfo.getKeySequence()) {
keyGenerator = TableInfoHelper.genKeyGenerator(sqlMethod, tableInfo, builderAssistant); keyGenerator = TableInfoHelper.genKeyGenerator(sqlMethod, tableInfo, builderAssistant);
keyProperty = tableInfo.getKeyProperty(); keyProperty = tableInfo.getKeyProperty();
keyColumn = tableInfo.getKeyColumn(); keyColumn = tableInfo.getKeyColumn();
} }
} }
} }
final String sqlResult = String.format(sql, tableInfo.getTableName(), fieldSql, valueSql); final String sqlResult = String.format(sql, tableInfo.getTableName(), fieldSql, valueSql);
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass); SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass);
return this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod, sqlSource, keyGenerator, keyProperty, keyColumn); return this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod, sqlSource, keyGenerator, keyProperty, keyColumn);
} }
private String prepareFieldSql(TableInfo tableInfo) { private String prepareFieldSql(TableInfo tableInfo) {
StringBuilder fieldSql = new StringBuilder(); StringBuilder fieldSql = new StringBuilder();
if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) { if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) {
fieldSql.append(tableInfo.getKeyColumn()).append(","); fieldSql.append(tableInfo.getKeyColumn()).append(",");
} }
tableInfo.getFieldList().forEach(x -> fieldSql.append(x.getColumn()).append(",")); tableInfo.getFieldList().forEach(x -> fieldSql.append(x.getColumn()).append(","));
fieldSql.delete(fieldSql.length() - 1, fieldSql.length()); fieldSql.delete(fieldSql.length() - 1, fieldSql.length());
fieldSql.insert(0, "("); fieldSql.insert(0, "(");
fieldSql.append(")"); fieldSql.append(")");
return fieldSql.toString(); return fieldSql.toString();
} }
private String prepareValuesSqlForMysqlBatch(TableInfo tableInfo) { private String prepareValuesSqlForMysqlBatch(TableInfo tableInfo) {
final StringBuilder valueSql = new StringBuilder(); final StringBuilder valueSql = new StringBuilder();
valueSql.append("<foreach collection=\"list\" item=\"item\" index=\"index\" open=\"(\" separator=\"),(\" close=\")\">"); valueSql.append("<foreach collection=\"list\" item=\"item\" index=\"index\" open=\"(\" separator=\"),(\" close=\")\">");
if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) { if (StringUtils.isNotBlank(tableInfo.getKeyColumn())) {
valueSql.append("\n#{item.").append(tableInfo.getKeyProperty()).append("},\n"); valueSql.append("\n#{item.").append(tableInfo.getKeyProperty()).append("},\n");
} }
List<TableFieldInfo> fieldList = tableInfo.getFieldList(); List<TableFieldInfo> fieldList = tableInfo.getFieldList();
int last = fieldList.size() - 1; int last = fieldList.size() - 1;
for (int i = 0; i < fieldList.size(); i++) { for (int i = 0; i < fieldList.size(); i++) {
String property = fieldList.get(i).getProperty(); String property = fieldList.get(i).getProperty();
if (!StringUtils.equalsAny(property, FILL_PROPERTY)) { if (!StringUtils.equalsAny(property, FILL_PROPERTY)) {
valueSql.append("<if test=\"item.").append(property).append(" != null\">"); valueSql.append("<if test=\"item.").append(property).append(" != null\">");
valueSql.append("#{item.").append(property).append("}"); valueSql.append("#{item.").append(property).append("}");
if (i != last) { if (i != last) {
valueSql.append(","); valueSql.append(",");
} }
valueSql.append("</if>"); valueSql.append("</if>");
valueSql.append("<if test=\"item.").append(property).append(" == null\">"); valueSql.append("<if test=\"item.").append(property).append(" == null\">");
valueSql.append("DEFAULT"); valueSql.append("DEFAULT");
if (i != last) { if (i != last) {
valueSql.append(","); valueSql.append(",");
} }
valueSql.append("</if>"); valueSql.append("</if>");
} else { } else {
valueSql.append("#{item.").append(property).append("}"); valueSql.append("#{item.").append(property).append("}");
if (i != last) { if (i != last) {
valueSql.append(","); valueSql.append(",");
} }
} }
} }
valueSql.append("</foreach>"); valueSql.append("</foreach>");
return valueSql.toString(); return valueSql.toString();
} }
} }

View File

@ -22,42 +22,42 @@ import java.util.List;
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel("分页响应对象") @ApiModel("分页响应对象")
public class TableDataInfo<T> implements Serializable { public class TableDataInfo<T> implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 总记录数 * 总记录数
*/ */
@ApiModelProperty("总记录数") @ApiModelProperty("总记录数")
private long total; private long total;
/** /**
* 列表数据 * 列表数据
*/ */
@ApiModelProperty("列表数据") @ApiModelProperty("列表数据")
private List<T> rows; private List<T> rows;
/** /**
* 消息状态码 * 消息状态码
*/ */
@ApiModelProperty("消息状态码") @ApiModelProperty("消息状态码")
private int code; private int code;
/** /**
* 消息内容 * 消息内容
*/ */
@ApiModelProperty("消息内容") @ApiModelProperty("消息内容")
private String msg; private String msg;
/** /**
* 分页 * 分页
* *
* @param list 列表数据 * @param list 列表数据
* @param total 总记录数 * @param total 总记录数
*/ */
public TableDataInfo(List<T> list, long total) { public TableDataInfo(List<T> list, long total) {
this.rows = list; this.rows = list;
this.total = total; this.total = total;
} }
public static <T> TableDataInfo<T> build(IPage<T> page) { public static <T> TableDataInfo<T> build(IPage<T> page) {
TableDataInfo<T> rspData = new TableDataInfo<>(); TableDataInfo<T> rspData = new TableDataInfo<>();

View File

@ -20,339 +20,339 @@ 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 * @param value defaultValue 要判断的value
* @return value 返回值 * @return value 返回值
*/ */
public static <T> T nvl(T value, T defaultValue) { public static <T> T nvl(T value, T defaultValue) {
return ObjectUtil.defaultIfNull(value, defaultValue); return ObjectUtil.defaultIfNull(value, defaultValue);
} }
/** /**
* 获取参数不为空值 * 获取参数不为空值
* *
* @param str defaultValue 要判断的value * @param str defaultValue 要判断的value
* @return value 返回值 * @return value 返回值
*/ */
public static String blankToDefault(String str, String defaultValue) { public static String blankToDefault(String str, String defaultValue) {
return StrUtil.blankToDefault(str, defaultValue); return StrUtil.blankToDefault(str, defaultValue);
} }
/** /**
* * 判断一个Collection是否为空 包含ListSetQueue * * 判断一个Collection是否为空 包含ListSetQueue
* *
* @param coll 要判断的Collection * @param coll 要判断的Collection
* @return true为空 false非空 * @return true为空 false非空
*/ */
public static boolean isEmpty(Collection<?> coll) { public static boolean isEmpty(Collection<?> coll) {
return CollUtil.isEmpty(coll); return CollUtil.isEmpty(coll);
} }
/** /**
* * 判断一个Collection是否非空包含ListSetQueue * * 判断一个Collection是否非空包含ListSetQueue
* *
* @param coll 要判断的Collection * @param coll 要判断的Collection
* @return true非空 false * @return true非空 false
*/ */
public static boolean isNotEmpty(Collection<?> coll) { public static boolean isNotEmpty(Collection<?> coll) {
return !isEmpty(coll); return !isEmpty(coll);
} }
/** /**
* * 判断一个对象数组是否为空 * * 判断一个对象数组是否为空
* *
* @param objects 要判断的对象数组 * @param objects 要判断的对象数组
* * @return true为空 false非空 * * @return true为空 false非空
*/ */
public static boolean isEmpty(Object[] objects) { public static boolean isEmpty(Object[] objects) {
return ArrayUtil.isEmpty(objects); return ArrayUtil.isEmpty(objects);
} }
/** /**
* * 判断一个对象数组是否非空 * * 判断一个对象数组是否非空
* *
* @param objects 要判断的对象数组 * @param objects 要判断的对象数组
* @return true非空 false * @return true非空 false
*/ */
public static boolean isNotEmpty(Object[] objects) { public static boolean isNotEmpty(Object[] objects) {
return !isEmpty(objects); return !isEmpty(objects);
} }
/** /**
* * 判断一个对象是否为空 * * 判断一个对象是否为空
* *
* @param object 要判断的对象数组 * @param object 要判断的对象数组
* * @return true为空 false非空 * * @return true为空 false非空
*/ */
public static boolean isEmpty(Object object) { public static boolean isEmpty(Object object) {
return ObjectUtil.isEmpty(object); return ObjectUtil.isEmpty(object);
} }
/** /**
* * 判断一个对象是否非空 * * 判断一个对象是否非空
* *
* @param object 要判断的对象数组 * @param object 要判断的对象数组
* @return true非空 false * @return true非空 false
*/ */
public static boolean isNotEmpty(Object object) { public static boolean isNotEmpty(Object object) {
return !isEmpty(object); return !isEmpty(object);
} }
/** /**
* * 判断一个Map是否为空 * * 判断一个Map是否为空
* *
* @param map 要判断的Map * @param map 要判断的Map
* @return true为空 false非空 * @return true为空 false非空
*/ */
public static boolean isEmpty(Map<?, ?> map) { public static boolean isEmpty(Map<?, ?> map) {
return MapUtil.isEmpty(map); return MapUtil.isEmpty(map);
} }
/** /**
* * 判断一个Map是否为空 * * 判断一个Map是否为空
* *
* @param map 要判断的Map * @param map 要判断的Map
* @return true非空 false * @return true非空 false
*/ */
public static boolean isNotEmpty(Map<?, ?> map) { public static boolean isNotEmpty(Map<?, ?> map) {
return !isEmpty(map); return !isEmpty(map);
} }
/** /**
* * 判断一个字符串是否为空串 * * 判断一个字符串是否为空串
* *
* @param str String * @param str String
* @return true为空 false非空 * @return true为空 false非空
*/ */
public static boolean isEmpty(String str) { public static boolean isEmpty(String str) {
return StrUtil.isEmpty(str); return StrUtil.isEmpty(str);
} }
/** /**
* * 判断一个字符串是否为非空串 * * 判断一个字符串是否为非空串
* *
* @param str String * @param str String
* @return true非空串 false空串 * @return true非空串 false空串
*/ */
public static boolean isNotEmpty(String str) { public static boolean isNotEmpty(String str) {
return !isEmpty(str); return !isEmpty(str);
} }
/** /**
* * 判断一个对象是否为空 * * 判断一个对象是否为空
* *
* @param object Object * @param object Object
* @return true为空 false非空 * @return true为空 false非空
*/ */
public static boolean isNull(Object object) { public static boolean isNull(Object object) {
return ObjectUtil.isNull(object); return ObjectUtil.isNull(object);
} }
/** /**
* * 判断一个对象是否非空 * * 判断一个对象是否非空
* *
* @param object Object * @param object Object
* @return true非空 false * @return true非空 false
*/ */
public static boolean isNotNull(Object object) { public static boolean isNotNull(Object object) {
return !isNull(object); return !isNull(object);
} }
/** /**
* * 判断一个对象是否是数组类型Java基本型别的数组 * * 判断一个对象是否是数组类型Java基本型别的数组
* *
* @param object 对象 * @param object 对象
* @return true是数组 false不是数组 * @return true是数组 false不是数组
*/ */
public static boolean isArray(Object object) { public static boolean isArray(Object object) {
return ArrayUtil.isArray(object); return ArrayUtil.isArray(object);
} }
/** /**
* 去空格 * 去空格
*/ */
public static String trim(String str) { public static String trim(String str) {
return StrUtil.trim(str); return StrUtil.trim(str);
} }
/** /**
* 截取字符串 * 截取字符串
* *
* @param str 字符串 * @param str 字符串
* @param start 开始 * @param start 开始
* @return 结果 * @return 结果
*/ */
public static String substring(final String str, int start) { public static String substring(final String str, int start) {
return substring(str, start, str.length()); return substring(str, start, str.length());
} }
/** /**
* 截取字符串 * 截取字符串
* *
* @param str 字符串 * @param str 字符串
* @param start 开始 * @param start 开始
* @param end 结束 * @param end 结束
* @return 结果 * @return 结果
*/ */
public static String substring(final String str, int start, int end) { public static String substring(final String str, int start, int end) {
return StrUtil.sub(str, start, end); return StrUtil.sub(str, start, end);
} }
/** /**
* 格式化文本, {} 表示占位符<br> * 格式化文本, {} 表示占位符<br>
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br> * 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
* 如果想输出 {} 使用 \\转义 { 即可如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br> * 如果想输出 {} 使用 \\转义 { 即可如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
* <br> * <br>
* 通常使用format("this is {} for {}", "a", "b") -> this is a for b<br> * 通常使用format("this is {} for {}", "a", "b") -> this is a for b<br>
* 转义{} format("this is \\{} for {}", "a", "b") -> this is \{} for a<br> * 转义{} format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
* 转义\ format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br> * 转义\ format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
* *
* @param template 文本模板被替换的部分用 {} 表示 * @param template 文本模板被替换的部分用 {} 表示
* @param params 参数值 * @param params 参数值
* @return 格式化后的文本 * @return 格式化后的文本
*/ */
public static String format(String template, Object... params) { public static String format(String template, Object... params) {
return StrUtil.format(template, params); return StrUtil.format(template, params);
} }
/** /**
* 是否为http(s)://开头 * 是否为http(s)://开头
* *
* @param link 链接 * @param link 链接
* @return 结果 * @return 结果
*/ */
public static boolean ishttp(String link) { public static boolean ishttp(String link) {
return Validator.isUrl(link); return Validator.isUrl(link);
} }
/** /**
* 字符串转set * 字符串转set
* *
* @param str 字符串 * @param str 字符串
* @param sep 分隔符 * @param sep 分隔符
* @return set集合 * @return set集合
*/ */
public static Set<String> str2Set(String str, String sep) { public static Set<String> str2Set(String str, String sep) {
return new HashSet<>(str2List(str, sep, true, false)); return new HashSet<>(str2List(str, sep, true, false));
} }
/** /**
* 字符串转list * 字符串转list
* *
* @param str 字符串 * @param str 字符串
* @param sep 分隔符 * @param sep 分隔符
* @param filterBlank 过滤纯空白 * @param filterBlank 过滤纯空白
* @param trim 去掉首尾空白 * @param trim 去掉首尾空白
* @return list集合 * @return list集合
*/ */
public static List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) { public static List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
if (isEmpty(str)) { if (isEmpty(str)) {
return list; return list;
} }
// 过滤空白字符串 // 过滤空白字符串
if (filterBlank && isBlank(str)) { if (filterBlank && isBlank(str)) {
return list; return list;
} }
String[] split = str.split(sep); String[] split = str.split(sep);
for (String string : split) { for (String string : split) {
if (filterBlank && isBlank(string)) { if (filterBlank && isBlank(string)) {
continue; continue;
} }
if (trim) { if (trim) {
string = trim(string); string = trim(string);
} }
list.add(string); list.add(string);
} }
return list; return list;
} }
/** /**
* 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写 * 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
* *
* @param cs 指定字符串 * @param cs 指定字符串
* @param searchCharSequences 需要检查的字符串数组 * @param searchCharSequences 需要检查的字符串数组
* @return 是否包含任意一个字符串 * @return 是否包含任意一个字符串
*/ */
public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) { public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) {
return StrUtil.containsAnyIgnoreCase(cs, searchCharSequences); return StrUtil.containsAnyIgnoreCase(cs, searchCharSequences);
} }
/** /**
* 驼峰转下划线命名 * 驼峰转下划线命名
*/ */
public static String toUnderScoreCase(String str) { public static String toUnderScoreCase(String str) {
return StrUtil.toUnderlineCase(str); return StrUtil.toUnderlineCase(str);
} }
/** /**
* 是否包含字符串 * 是否包含字符串
* *
* @param str 验证字符串 * @param str 验证字符串
* @param strs 字符串组 * @param strs 字符串组
* @return 包含返回true * @return 包含返回true
*/ */
public static boolean inStringIgnoreCase(String str, String... strs) { public static boolean inStringIgnoreCase(String str, String... strs) {
return StrUtil.equalsAnyIgnoreCase(str, strs); return StrUtil.equalsAnyIgnoreCase(str, strs);
} }
/** /**
* 将下划线大写方式命名的字符串转换为驼峰式如果转换前的下划线大写方式命名的字符串为空则返回空字符串 例如HELLO_WORLD->HelloWorld * 将下划线大写方式命名的字符串转换为驼峰式如果转换前的下划线大写方式命名的字符串为空则返回空字符串 例如HELLO_WORLD->HelloWorld
* *
* @param name 转换前的下划线大写方式命名的字符串 * @param name 转换前的下划线大写方式命名的字符串
* @return 转换后的驼峰式命名的字符串 * @return 转换后的驼峰式命名的字符串
*/ */
public static String convertToCamelCase(String name) { public static String convertToCamelCase(String name) {
return StrUtil.upperFirst(StrUtil.toCamelCase(name)); return StrUtil.upperFirst(StrUtil.toCamelCase(name));
} }
/** /**
* 驼峰式命名法 例如user_name->userName * 驼峰式命名法 例如user_name->userName
*/ */
public static String toCamelCase(String s) { public static String toCamelCase(String s) {
return StrUtil.toCamelCase(s); return StrUtil.toCamelCase(s);
} }
/** /**
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串 * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
* *
* @param str 指定字符串 * @param str 指定字符串
* @param strs 需要检查的字符串数组 * @param strs 需要检查的字符串数组
* @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) || isEmpty(strs)) {
return false; return false;
} }
for (String pattern : strs) { for (String pattern : strs) {
if (isMatch(pattern, str)) { if (isMatch(pattern, str)) {
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* 判断url是否与规则配置: * 判断url是否与规则配置:
* ? 表示单个字符; * ? 表示单个字符;
* * 表示一层路径内的任意字符串不可跨层级; * * 表示一层路径内的任意字符串不可跨层级;
* ** 表示任意层路径; * ** 表示任意层路径;
* *
* @param pattern 匹配规则 * @param pattern 匹配规则
* @param url 需要匹配的url * @param url 需要匹配的url
* @return * @return
*/ */
public static boolean isMatch(String pattern, String url) { public static boolean isMatch(String pattern, String url) {
AntPathMatcher matcher = new AntPathMatcher(); AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(pattern, url); return matcher.match(pattern, url);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T cast(Object obj) { public static <T> T cast(Object obj) {
return (T) obj; return (T) obj;
} }
} }

View File

@ -17,9 +17,9 @@ import java.util.Set;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ValidatorUtils { public class ValidatorUtils {
private static final Validator VALID = SpringUtils.getBean(Validator.class); private static final Validator VALID = SpringUtils.getBean(Validator.class);
public static <T> void validate(T object, Class<?>... groups) { public static <T> void validate(T object, Class<?>... groups) {
Set<ConstraintViolation<T>> validate = VALID.validate(object, groups); Set<ConstraintViolation<T>> validate = VALID.validate(object, groups);
if (!validate.isEmpty()) { if (!validate.isEmpty()) {
throw new ConstraintViolationException("参数校验异常", validate); throw new ConstraintViolationException("参数校验异常", validate);

View File

@ -27,22 +27,22 @@ import javax.validation.constraints.NotNull;
@RequestMapping("/demo/i18n") @RequestMapping("/demo/i18n")
public class TestI18nController { public class TestI18nController {
/** /**
* 通过code获取国际化内容 * 通过code获取国际化内容
* code为 messages.properties 中的 key * code为 messages.properties 中的 key
* * <p>
* 测试使用 user.register.success * 测试使用 user.register.success
*/ */
@ApiOperation("通过code获取国际化内容") @ApiOperation("通过code获取国际化内容")
@GetMapping() @GetMapping()
public AjaxResult<Void> get(@ApiParam("国际化code") String code) { public AjaxResult<Void> get(@ApiParam("国际化code") String code) {
return AjaxResult.success(MessageUtils.message(code)); return AjaxResult.success(MessageUtils.message(code));
} }
/** /**
* Validator 校验国际化 * Validator 校验国际化
* 不传值 分别查看异常返回 * 不传值 分别查看异常返回
* * <p>
* 测试使用 not.null * 测试使用 not.null
*/ */
@ApiOperation("Validator 校验国际化") @ApiOperation("Validator 校验国际化")
@ -54,7 +54,7 @@ public class TestI18nController {
/** /**
* Bean 校验国际化 * Bean 校验国际化
* 不传值 分别查看异常返回 * 不传值 分别查看异常返回
* * <p>
* 测试使用 not.null * 测试使用 not.null
*/ */
@ApiOperation("Bean 校验国际化") @ApiOperation("Bean 校验国际化")

View File

@ -18,12 +18,12 @@ import lombok.experimental.Accessors;
@TableName("test_demo") @TableName("test_demo")
public class TestDemo extends BaseEntity { public class TestDemo extends BaseEntity {
private static final long serialVersionUID=1L; private static final long serialVersionUID = 1L;
/** /**
* 主键 * 主键
*/ */
@TableId(value = "id") @TableId(value = "id")
private Long id; private Long id;
@ -40,7 +40,7 @@ public class TestDemo extends BaseEntity {
/** /**
* 排序号 * 排序号
*/ */
@OrderBy(asc = false, sort = 1) @OrderBy(asc = false, sort = 1)
private Long orderNum; private Long orderNum;
/** /**

View File

@ -21,7 +21,7 @@ import lombok.experimental.Accessors;
@TableName("test_tree") @TableName("test_tree")
public class TestTree extends TreeEntity { public class TestTree extends TreeEntity {
private static final long serialVersionUID=1L; private static final long serialVersionUID = 1L;
/** /**

View File

@ -26,43 +26,43 @@ public class TestDemoBo extends BaseEntity {
/** /**
* 主键 * 主键
*/ */
@ApiModelProperty("主键") @ApiModelProperty("主键")
@NotNull(message = "主键不能为空", groups = { EditGroup.class }) @NotNull(message = "主键不能为空", groups = {EditGroup.class})
private Long id; private Long id;
/** /**
* 部门id * 部门id
*/ */
@ApiModelProperty("部门id") @ApiModelProperty("部门id")
@NotNull(message = "部门id不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "部门id不能为空", groups = {AddGroup.class, EditGroup.class})
private Long deptId; private Long deptId;
/** /**
* 用户id * 用户id
*/ */
@ApiModelProperty("用户id") @ApiModelProperty("用户id")
@NotNull(message = "用户id不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "用户id不能为空", groups = {AddGroup.class, EditGroup.class})
private Long userId; private Long userId;
/** /**
* 排序号 * 排序号
*/ */
@ApiModelProperty("排序号") @ApiModelProperty("排序号")
@NotNull(message = "排序号不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "排序号不能为空", groups = {AddGroup.class, EditGroup.class})
private Long orderNum; private Long orderNum;
/** /**
* key键 * key键
*/ */
@ApiModelProperty("key键") @ApiModelProperty("key键")
@NotBlank(message = "key键不能为空", groups = { AddGroup.class, EditGroup.class }) @NotBlank(message = "key键不能为空", groups = {AddGroup.class, EditGroup.class})
private String testKey; private String testKey;
/** /**
* *
*/ */
@ApiModelProperty("") @ApiModelProperty("")
@NotBlank(message = "值不能为空", groups = { AddGroup.class, EditGroup.class }) @NotBlank(message = "值不能为空", groups = {AddGroup.class, EditGroup.class})
private String value; private String value;
} }

View File

@ -26,29 +26,29 @@ public class TestTreeBo extends TreeEntity {
/** /**
* 主键 * 主键
*/ */
@ApiModelProperty("主键") @ApiModelProperty("主键")
@NotNull(message = "主键不能为空", groups = { EditGroup.class }) @NotNull(message = "主键不能为空", groups = {EditGroup.class})
private Long id; private Long id;
/** /**
* 部门id * 部门id
*/ */
@ApiModelProperty("部门id") @ApiModelProperty("部门id")
@NotNull(message = "部门id不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "部门id不能为空", groups = {AddGroup.class, EditGroup.class})
private Long deptId; private Long deptId;
/** /**
* 用户id * 用户id
*/ */
@ApiModelProperty("用户id") @ApiModelProperty("用户id")
@NotNull(message = "用户id不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "用户id不能为空", groups = {AddGroup.class, EditGroup.class})
private Long userId; private Long userId;
/** /**
* 树节点名 * 树节点名
*/ */
@ApiModelProperty("树节点名") @ApiModelProperty("树节点名")
@NotBlank(message = "树节点名不能为空", groups = { AddGroup.class, EditGroup.class }) @NotBlank(message = "树节点名不能为空", groups = {AddGroup.class, EditGroup.class})
private String treeName; private String treeName;
} }

View File

@ -9,7 +9,6 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* 测试单表视图对象 test_demo * 测试单表视图对象 test_demo
* *
@ -21,77 +20,77 @@ import java.util.Date;
@ExcelIgnoreUnannotated @ExcelIgnoreUnannotated
public class TestDemoVo { public class TestDemoVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 主键 * 主键
*/ */
@ExcelProperty(value = "主键") @ExcelProperty(value = "主键")
@ApiModelProperty("主键") @ApiModelProperty("主键")
private Long id; private Long id;
/** /**
* 部门id * 部门id
*/ */
@ExcelProperty(value = "部门id") @ExcelProperty(value = "部门id")
@ApiModelProperty("部门id") @ApiModelProperty("部门id")
private Long deptId; private Long deptId;
/** /**
* 用户id * 用户id
*/ */
@ExcelProperty(value = "用户id") @ExcelProperty(value = "用户id")
@ApiModelProperty("用户id") @ApiModelProperty("用户id")
private Long userId; private Long userId;
/** /**
* 排序号 * 排序号
*/ */
@ExcelProperty(value = "排序号") @ExcelProperty(value = "排序号")
@ApiModelProperty("排序号") @ApiModelProperty("排序号")
private Long orderNum; private Long orderNum;
/** /**
* key键 * key键
*/ */
@ExcelProperty(value = "key键") @ExcelProperty(value = "key键")
@ApiModelProperty("key键") @ApiModelProperty("key键")
private String testKey; private String testKey;
/** /**
* *
*/ */
@ExcelProperty(value = "") @ExcelProperty(value = "")
@ApiModelProperty("") @ApiModelProperty("")
private String value; private String value;
/** /**
* 创建时间 * 创建时间
*/ */
@ExcelProperty(value = "创建时间") @ExcelProperty(value = "创建时间")
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
private Date createTime; private Date createTime;
/** /**
* 创建人 * 创建人
*/ */
@ExcelProperty(value = "创建人") @ExcelProperty(value = "创建人")
@ApiModelProperty("创建人") @ApiModelProperty("创建人")
private String createBy; private String createBy;
/** /**
* 更新时间 * 更新时间
*/ */
@ExcelProperty(value = "更新时间") @ExcelProperty(value = "更新时间")
@ApiModelProperty("更新时间") @ApiModelProperty("更新时间")
private Date updateTime; private Date updateTime;
/** /**
* 更新人 * 更新人
*/ */
@ExcelProperty(value = "更新人") @ExcelProperty(value = "更新人")
@ApiModelProperty("更新人") @ApiModelProperty("更新人")
private String updateBy; private String updateBy;
} }

View File

@ -9,7 +9,6 @@ import lombok.Data;
import java.util.Date; import java.util.Date;
/** /**
* 测试树表视图对象 test_tree * 测试树表视图对象 test_tree
* *
@ -21,48 +20,48 @@ import java.util.Date;
@ExcelIgnoreUnannotated @ExcelIgnoreUnannotated
public class TestTreeVo { public class TestTreeVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 主键 * 主键
*/ */
@ApiModelProperty("主键") @ApiModelProperty("主键")
private Long id; private Long id;
/** /**
* 父id * 父id
*/ */
@ExcelProperty(value = "父id") @ExcelProperty(value = "父id")
@ApiModelProperty("父id") @ApiModelProperty("父id")
private Long parentId; private Long parentId;
/** /**
* 部门id * 部门id
*/ */
@ExcelProperty(value = "部门id") @ExcelProperty(value = "部门id")
@ApiModelProperty("部门id") @ApiModelProperty("部门id")
private Long deptId; private Long deptId;
/** /**
* 用户id * 用户id
*/ */
@ExcelProperty(value = "用户id") @ExcelProperty(value = "用户id")
@ApiModelProperty("用户id") @ApiModelProperty("用户id")
private Long userId; private Long userId;
/** /**
* 树节点名 * 树节点名
*/ */
@ExcelProperty(value = "树节点名") @ExcelProperty(value = "树节点名")
@ApiModelProperty("树节点名") @ApiModelProperty("树节点名")
private String treeName; private String treeName;
/** /**
* 创建时间 * 创建时间
*/ */
@ExcelProperty(value = "创建时间") @ExcelProperty(value = "创建时间")
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
private Date createTime; private Date createTime;
} }

View File

@ -1,11 +1,11 @@
package com.ruoyi.demo.service; package com.ruoyi.demo.service;
import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.demo.domain.TestDemo;
import com.ruoyi.demo.domain.vo.TestDemoVo;
import com.ruoyi.demo.domain.bo.TestDemoBo;
import com.ruoyi.common.core.mybatisplus.core.IServicePlus; import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.demo.domain.TestDemo;
import com.ruoyi.demo.domain.bo.TestDemoBo;
import com.ruoyi.demo.domain.vo.TestDemoVo;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -18,46 +18,50 @@ import java.util.List;
*/ */
public interface ITestDemoService extends IServicePlus<TestDemo, TestDemoVo> { public interface ITestDemoService extends IServicePlus<TestDemo, TestDemoVo> {
/** /**
* 查询单个 * 查询单个
* @return *
*/ * @return
TestDemoVo queryById(Long id); */
TestDemoVo queryById(Long id);
/**
* 查询列表
*/
TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery);
/**
* 自定义分页查询
*/
TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo, PageQuery pageQuery);
/** /**
* 查询列表 * 查询列表
*/ */
List<TestDemoVo> queryList(TestDemoBo bo); TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery);
/** /**
* 根据新增业务对象插入测试单表 * 自定义分页查询
* @param bo 测试单表新增业务对象 */
* @return TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo, PageQuery pageQuery);
*/
Boolean insertByBo(TestDemoBo bo);
/** /**
* 根据编辑业务对象修改测试单表 * 查询列表
* @param bo 测试单表编辑业务对象 */
* @return List<TestDemoVo> queryList(TestDemoBo bo);
*/
Boolean updateByBo(TestDemoBo bo);
/** /**
* 校验并删除数据 * 根据新增业务对象插入测试单表
* @param ids 主键集合 *
* @param isValid 是否校验,true-删除前校验,false-不校验 * @param bo 测试单表新增业务对象
* @return * @return
*/ */
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); Boolean insertByBo(TestDemoBo bo);
/**
* 根据编辑业务对象修改测试单表
*
* @param bo 测试单表编辑业务对象
* @return
*/
Boolean updateByBo(TestDemoBo bo);
/**
* 校验并删除数据
*
* @param ids 主键集合
* @param isValid 是否校验,true-删除前校验,false-不校验
* @return
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
} }

View File

@ -1,9 +1,9 @@
package com.ruoyi.demo.service; package com.ruoyi.demo.service;
import com.ruoyi.demo.domain.TestTree;
import com.ruoyi.demo.domain.vo.TestTreeVo;
import com.ruoyi.demo.domain.bo.TestTreeBo;
import com.ruoyi.common.core.mybatisplus.core.IServicePlus; import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
import com.ruoyi.demo.domain.TestTree;
import com.ruoyi.demo.domain.bo.TestTreeBo;
import com.ruoyi.demo.domain.vo.TestTreeVo;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -15,36 +15,40 @@ import java.util.List;
* @date 2021-07-26 * @date 2021-07-26
*/ */
public interface ITestTreeService extends IServicePlus<TestTree, TestTreeVo> { public interface ITestTreeService extends IServicePlus<TestTree, TestTreeVo> {
/** /**
* 查询单个 * 查询单个
* @return *
*/ * @return
TestTreeVo queryById(Long id); */
TestTreeVo queryById(Long id);
/** /**
* 查询列表 * 查询列表
*/ */
List<TestTreeVo> queryList(TestTreeBo bo); List<TestTreeVo> queryList(TestTreeBo bo);
/** /**
* 根据新增业务对象插入测试树表 * 根据新增业务对象插入测试树表
* @param bo 测试树表新增业务对象 *
* @return * @param bo 测试树表新增业务对象
*/ * @return
Boolean insertByBo(TestTreeBo bo); */
Boolean insertByBo(TestTreeBo bo);
/** /**
* 根据编辑业务对象修改测试树表 * 根据编辑业务对象修改测试树表
* @param bo 测试树表编辑业务对象 *
* @return * @param bo 测试树表编辑业务对象
*/ * @return
Boolean updateByBo(TestTreeBo bo); */
Boolean updateByBo(TestTreeBo bo);
/** /**
* 校验并删除数据 * 校验并删除数据
* @param ids 主键集合 *
* @param isValid 是否校验,true-删除前校验,false-不校验 * @param ids 主键集合
* @return * @param isValid 是否校验,true-删除前校验,false-不校验
*/ * @return
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); */
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
} }

View File

@ -28,75 +28,75 @@ import java.util.Map;
@Service @Service
public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDemo, TestDemoVo> implements ITestDemoService { public class TestDemoServiceImpl extends ServicePlusImpl<TestDemoMapper, TestDemo, TestDemoVo> implements ITestDemoService {
@Override @Override
public TestDemoVo queryById(Long id) { public TestDemoVo queryById(Long id) {
return getVoById(id); return getVoById(id);
} }
@Override @Override
public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery) { public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo); LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo);
Page<TestDemoVo> result = pageVo(pageQuery.build(), lqw); Page<TestDemoVo> result = pageVo(pageQuery.build(), lqw);
return TableDataInfo.build(result); return TableDataInfo.build(result);
} }
/** /**
* 自定义分页查询 * 自定义分页查询
*/ */
@Override @Override
public TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo, PageQuery pageQuery) { public TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo); LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo);
Page<TestDemoVo> result = baseMapper.customPageList(pageQuery.build(), lqw); Page<TestDemoVo> result = baseMapper.customPageList(pageQuery.build(), lqw);
return TableDataInfo.build(result); return TableDataInfo.build(result);
} }
@Override @Override
public List<TestDemoVo> queryList(TestDemoBo bo) { public List<TestDemoVo> queryList(TestDemoBo bo) {
return listVo(buildQueryWrapper(bo)); return listVo(buildQueryWrapper(bo));
} }
private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoBo bo) { private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoBo bo) {
Map<String, Object> params = bo.getParams(); Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<TestDemo> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<TestDemo> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getTestKey()), TestDemo::getTestKey, bo.getTestKey()); lqw.like(StringUtils.isNotBlank(bo.getTestKey()), TestDemo::getTestKey, bo.getTestKey());
lqw.eq(StringUtils.isNotBlank(bo.getValue()), TestDemo::getValue, bo.getValue()); lqw.eq(StringUtils.isNotBlank(bo.getValue()), TestDemo::getValue, bo.getValue());
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
TestDemo::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); TestDemo::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
return lqw; return lqw;
} }
@Override @Override
public Boolean insertByBo(TestDemoBo bo) { public Boolean insertByBo(TestDemoBo bo) {
TestDemo add = BeanUtil.toBean(bo, TestDemo.class); TestDemo add = BeanUtil.toBean(bo, TestDemo.class);
validEntityBeforeSave(add); validEntityBeforeSave(add);
boolean flag = save(add); boolean flag = save(add);
if (flag) { if (flag) {
bo.setId(add.getId()); bo.setId(add.getId());
} }
return flag; return flag;
} }
@Override @Override
public Boolean updateByBo(TestDemoBo bo) { public Boolean updateByBo(TestDemoBo bo) {
TestDemo update = BeanUtil.toBean(bo, TestDemo.class); TestDemo update = BeanUtil.toBean(bo, TestDemo.class);
validEntityBeforeSave(update); validEntityBeforeSave(update);
return updateById(update); return updateById(update);
} }
/** /**
* 保存前的数据校验 * 保存前的数据校验
* *
* @param entity 实体类数据 * @param entity 实体类数据
*/ */
private void validEntityBeforeSave(TestDemo entity) { private void validEntityBeforeSave(TestDemo entity) {
//TODO 做一些数据校验,如唯一约束 //TODO 做一些数据校验,如唯一约束
} }
@Override @Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) { if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验 //TODO 做一些业务上的校验,判断是否需要校验
} }
return removeByIds(ids); return removeByIds(ids);
} }
} }

View File

@ -26,59 +26,59 @@ import java.util.Map;
@Service @Service
public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService { public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService {
@Override @Override
public TestTreeVo queryById(Long id) { public TestTreeVo queryById(Long id) {
return getVoById(id); return getVoById(id);
} }
// @DS("slave") // 切换从库查询 // @DS("slave") // 切换从库查询
@Override @Override
public List<TestTreeVo> queryList(TestTreeBo bo) { public List<TestTreeVo> queryList(TestTreeBo bo) {
LambdaQueryWrapper<TestTree> lqw = buildQueryWrapper(bo); LambdaQueryWrapper<TestTree> lqw = buildQueryWrapper(bo);
return listVo(lqw); return listVo(lqw);
} }
private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeBo bo) { private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeBo bo) {
Map<String, Object> params = bo.getParams(); Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<TestTree> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<TestTree> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName()); lqw.like(StringUtils.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName());
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
TestTree::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); TestTree::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
return lqw; return lqw;
} }
@Override @Override
public Boolean insertByBo(TestTreeBo bo) { public Boolean insertByBo(TestTreeBo bo) {
TestTree add = BeanUtil.toBean(bo, TestTree.class); TestTree add = BeanUtil.toBean(bo, TestTree.class);
validEntityBeforeSave(add); validEntityBeforeSave(add);
boolean flag = save(add); boolean flag = save(add);
if (flag) { if (flag) {
bo.setId(add.getId()); bo.setId(add.getId());
} }
return flag; return flag;
} }
@Override @Override
public Boolean updateByBo(TestTreeBo bo) { public Boolean updateByBo(TestTreeBo bo) {
TestTree update = BeanUtil.toBean(bo, TestTree.class); TestTree update = BeanUtil.toBean(bo, TestTree.class);
validEntityBeforeSave(update); validEntityBeforeSave(update);
return updateById(update); return updateById(update);
} }
/** /**
* 保存前的数据校验 * 保存前的数据校验
* *
* @param entity 实体类数据 * @param entity 实体类数据
*/ */
private void validEntityBeforeSave(TestTree entity) { private void validEntityBeforeSave(TestTree entity) {
//TODO 做一些数据校验,如唯一约束 //TODO 做一些数据校验,如唯一约束
} }
@Override @Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) { if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验 //TODO 做一些业务上的校验,判断是否需要校验
} }
return removeByIds(ids); return removeByIds(ids);
} }
} }

View File

@ -11,9 +11,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class MonitorAdminApplication { public class MonitorAdminApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(MonitorAdminApplication.class, args); SpringApplication.run(MonitorAdminApplication.class, args);
System.out.println("Admin 监控启动成功" ); System.out.println("Admin 监控启动成功");
} }
} }

View File

@ -16,33 +16,33 @@ import org.springframework.security.web.authentication.SavedRequestAwareAuthenti
@EnableWebSecurity @EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter { public class SecurityConfig extends WebSecurityConfigurerAdapter {
private final String adminContextPath; private final String adminContextPath;
public SecurityConfig(AdminServerProperties adminServerProperties) { public SecurityConfig(AdminServerProperties adminServerProperties) {
this.adminContextPath = adminServerProperties.getContextPath(); this.adminContextPath = adminServerProperties.getContextPath();
} }
@Override @Override
protected void configure(HttpSecurity httpSecurity) throws Exception { protected void configure(HttpSecurity httpSecurity) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo"); successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl(adminContextPath + "/"); successHandler.setDefaultTargetUrl(adminContextPath + "/");
// admin监控 用户鉴权 // admin监控 用户鉴权
httpSecurity.authorizeRequests() httpSecurity.authorizeRequests()
//授予对所有静态资产和登录页面的公共访问权限 //授予对所有静态资产和登录页面的公共访问权限
.antMatchers(adminContextPath + "/assets/**").permitAll() .antMatchers(adminContextPath + "/assets/**").permitAll()
.antMatchers(adminContextPath + "/login").permitAll() .antMatchers(adminContextPath + "/login").permitAll()
.antMatchers("/actuator").permitAll() .antMatchers("/actuator").permitAll()
.antMatchers("/actuator/**").permitAll() .antMatchers("/actuator/**").permitAll()
//必须对每个其他请求进行身份验证 //必须对每个其他请求进行身份验证
.anyRequest().authenticated().and() .anyRequest().authenticated().and()
//配置登录和注销 //配置登录和注销
.formLogin().loginPage(adminContextPath + "/login") .formLogin().loginPage(adminContextPath + "/login")
.successHandler(successHandler).and() .successHandler(successHandler).and()
.logout().logoutUrl(adminContextPath + "/logout").and() .logout().logoutUrl(adminContextPath + "/logout").and()
//启用HTTP-Basic支持这是Spring Boot Admin Client注册所必需的 //启用HTTP-Basic支持这是Spring Boot Admin Client注册所必需的
.httpBasic().and().csrf().disable() .httpBasic().and().csrf().disable()
.headers().frameOptions().disable(); .headers().frameOptions().disable();
} }
} }

View File

@ -23,9 +23,9 @@ import java.util.concurrent.ScheduledExecutorService;
@Configuration @Configuration
public class AsyncConfig extends AsyncConfigurerSupport { public class AsyncConfig extends AsyncConfigurerSupport {
@Autowired @Autowired
@Qualifier("scheduledExecutorService") @Qualifier("scheduledExecutorService")
private ScheduledExecutorService scheduledExecutorService; private ScheduledExecutorService scheduledExecutorService;
/** /**
* 异步执行需要使用权限框架自带的包装线程池 保证权限信息的传递 * 异步执行需要使用权限框架自带的包装线程池 保证权限信息的传递
@ -44,7 +44,7 @@ public class AsyncConfig extends AsyncConfigurerSupport {
throwable.printStackTrace(); throwable.printStackTrace();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Exception message - ").append(throwable.getMessage()) sb.append("Exception message - ").append(throwable.getMessage())
.append(", Method name - ").append(method.getName()); .append(", Method name - ").append(method.getName());
if (ArrayUtil.isNotEmpty(objects)) { if (ArrayUtil.isNotEmpty(objects)) {
sb.append(", Parameter value - ").append(Arrays.toString(objects)); sb.append(", Parameter value - ").append(Arrays.toString(objects));
} }

View File

@ -21,11 +21,10 @@ public class DruidConfig {
/** /**
* 去除监控页面底部的广告 * 去除监控页面底部的广告
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
@Bean @Bean
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) {
{
// 获取web监控页面的参数 // 获取web监控页面的参数
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
// 提取common.js的配置路径 // 提取common.js的配置路径
@ -33,16 +32,14 @@ public class DruidConfig {
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
final String filePath = "support/http/resources/js/common.js"; final String filePath = "support/http/resources/js/common.js";
// 创建filter进行过滤 // 创建filter进行过滤
Filter filter = new Filter() Filter filter = new Filter() {
{
@Override @Override
public void init(javax.servlet.FilterConfig filterConfig) throws ServletException public void init(javax.servlet.FilterConfig filterConfig) throws ServletException {
{
} }
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException throws IOException, ServletException {
{
chain.doFilter(request, response); chain.doFilter(request, response);
// 重置缓冲区响应头不会被重置 // 重置缓冲区响应头不会被重置
// response.resetBuffer(); // response.resetBuffer();
@ -53,9 +50,9 @@ public class DruidConfig {
text = text.replaceAll("powered.*?shrek.wang</a>", ""); text = text.replaceAll("powered.*?shrek.wang</a>", "");
response.getWriter().write(text); response.getWriter().write(text);
} }
@Override @Override
public void destroy() public void destroy() {
{
} }
}; };
FilterRegistrationBean registrationBean = new FilterRegistrationBean(); FilterRegistrationBean registrationBean = new FilterRegistrationBean();

View File

@ -17,30 +17,30 @@ import java.util.Locale;
@Configuration @Configuration
public class I18nConfig { public class I18nConfig {
@Bean @Bean
public LocaleResolver localeResolver() { public LocaleResolver localeResolver() {
return new I18nLocaleResolver(); return new I18nLocaleResolver();
} }
/** /**
* 获取请求头国际化信息 * 获取请求头国际化信息
*/ */
static class I18nLocaleResolver implements LocaleResolver { static class I18nLocaleResolver implements LocaleResolver {
@Override @Override
public Locale resolveLocale(HttpServletRequest httpServletRequest) { public Locale resolveLocale(HttpServletRequest httpServletRequest) {
String language = httpServletRequest.getHeader("content-language"); String language = httpServletRequest.getHeader("content-language");
Locale locale = Locale.getDefault(); Locale locale = Locale.getDefault();
if (StrUtil.isNotBlank(language)) { if (StrUtil.isNotBlank(language)) {
String[] split = language.split("_"); String[] split = language.split("_");
locale = new Locale(split[0], split[1]); locale = new Locale(split[0], split[1]);
} }
return locale; return locale;
} }
@Override @Override
public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) { public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
} }
} }
} }

View File

@ -28,23 +28,23 @@ import java.util.TimeZone;
@Configuration @Configuration
public class JacksonConfig { public class JacksonConfig {
@Primary @Primary
@Bean @Bean
public ObjectMapper getObjectMapper(Jackson2ObjectMapperBuilder builder, JacksonProperties jacksonProperties) { public ObjectMapper getObjectMapper(Jackson2ObjectMapperBuilder builder, JacksonProperties jacksonProperties) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build(); ObjectMapper objectMapper = builder.createXmlMapper(false).build();
// 全局配置序列化返回 JSON 处理 // 全局配置序列化返回 JSON 处理
SimpleModule simpleModule = new SimpleModule(); SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE); simpleModule.addSerializer(Long.class, BigNumberSerializer.INSTANCE);
simpleModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE); simpleModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE);
simpleModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE); simpleModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE);
simpleModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); simpleModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(jacksonProperties.getDateFormat()); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(jacksonProperties.getDateFormat());
simpleModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter)); simpleModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(formatter));
simpleModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter)); simpleModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter));
objectMapper.registerModule(simpleModule); objectMapper.registerModule(simpleModule);
objectMapper.setTimeZone(TimeZone.getDefault()); objectMapper.setTimeZone(TimeZone.getDefault());
log.info("初始化 jackson 配置"); log.info("初始化 jackson 配置");
return objectMapper; return objectMapper;
} }
} }

View File

@ -31,17 +31,17 @@ import java.util.List;
@MapperScan("${mybatis-plus.mapperPackage}") @MapperScan("${mybatis-plus.mapperPackage}")
public class MybatisPlusConfig { public class MybatisPlusConfig {
@Bean @Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() { public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 数据权限处理 // 数据权限处理
interceptor.addInnerInterceptor(dataPermissionInterceptor()); interceptor.addInnerInterceptor(dataPermissionInterceptor());
// 分页插件 // 分页插件
interceptor.addInnerInterceptor(paginationInnerInterceptor()); interceptor.addInnerInterceptor(paginationInnerInterceptor());
// 乐观锁插件 // 乐观锁插件
interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor()); interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
return interceptor; return interceptor;
} }
/** /**
* 数据权限拦截器 * 数据权限拦截器
@ -50,47 +50,47 @@ public class MybatisPlusConfig {
return new PlusDataPermissionInterceptor(); return new PlusDataPermissionInterceptor();
} }
/** /**
* 分页插件自动识别数据库类型 * 分页插件自动识别数据库类型
*/ */
public PaginationInnerInterceptor paginationInnerInterceptor() { public PaginationInnerInterceptor paginationInnerInterceptor() {
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(); PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
// 设置最大单页限制数量默认 500 -1 不受限制 // 设置最大单页限制数量默认 500 -1 不受限制
paginationInnerInterceptor.setMaxLimit(-1L); paginationInnerInterceptor.setMaxLimit(-1L);
// 分页合理化 // 分页合理化
paginationInnerInterceptor.setOverflow(true); paginationInnerInterceptor.setOverflow(true);
return paginationInnerInterceptor; return paginationInnerInterceptor;
} }
/** /**
* 乐观锁插件 * 乐观锁插件
*/ */
public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() { public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() {
return new OptimisticLockerInnerInterceptor(); return new OptimisticLockerInnerInterceptor();
} }
/** /**
* 元对象字段填充控制器 * 元对象字段填充控制器
*/ */
@Bean @Bean
public MetaObjectHandler metaObjectHandler() { public MetaObjectHandler metaObjectHandler() {
return new CreateAndUpdateMetaObjectHandler(); return new CreateAndUpdateMetaObjectHandler();
} }
/** /**
* sql注入器配置 * sql注入器配置
*/ */
@Bean @Bean
public ISqlInjector sqlInjector() { public ISqlInjector sqlInjector() {
return new DefaultSqlInjector() { return new DefaultSqlInjector() {
@Override @Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) { public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo); List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
methodList.add(new InsertAll()); methodList.add(new InsertAll());
return methodList; return methodList;
} }
}; };
} }
/** /**
* 使用网卡信息绑定雪花生成器 * 使用网卡信息绑定雪花生成器
@ -101,24 +101,24 @@ public class MybatisPlusConfig {
return new DefaultIdentifierGenerator(NetUtil.getLocalhost()); return new DefaultIdentifierGenerator(NetUtil.getLocalhost());
} }
/** /**
* PaginationInnerInterceptor 分页插件自动识别数据库类型 * PaginationInnerInterceptor 分页插件自动识别数据库类型
* https://baomidou.com/pages/97710a/ * https://baomidou.com/pages/97710a/
* OptimisticLockerInnerInterceptor 乐观锁插件 * OptimisticLockerInnerInterceptor 乐观锁插件
* https://baomidou.com/pages/0d93c0/ * https://baomidou.com/pages/0d93c0/
* MetaObjectHandler 元对象字段填充控制器 * MetaObjectHandler 元对象字段填充控制器
* https://baomidou.com/pages/4c6bcf/ * https://baomidou.com/pages/4c6bcf/
* ISqlInjector sql注入器 * ISqlInjector sql注入器
* https://baomidou.com/pages/42ea4a/ * https://baomidou.com/pages/42ea4a/
* BlockAttackInnerInterceptor 如果是对全表的删除或更新操作就会终止该操作 * BlockAttackInnerInterceptor 如果是对全表的删除或更新操作就会终止该操作
* https://baomidou.com/pages/f9a237/ * https://baomidou.com/pages/f9a237/
* IllegalSQLInnerInterceptor sql性能规范插件(垃圾SQL拦截) * IllegalSQLInnerInterceptor sql性能规范插件(垃圾SQL拦截)
* IdentifierGenerator 自定义主键策略 * IdentifierGenerator 自定义主键策略
* https://baomidou.com/pages/568eb2/ * https://baomidou.com/pages/568eb2/
* TenantLineInnerInterceptor 多租户插件 * TenantLineInnerInterceptor 多租户插件
* https://baomidou.com/pages/aef2f2/ * https://baomidou.com/pages/aef2f2/
* DynamicTableNameInnerInterceptor 动态表名插件 * DynamicTableNameInnerInterceptor 动态表名插件
* https://baomidou.com/pages/2a45ff/ * https://baomidou.com/pages/2a45ff/
*/ */
} }

View File

@ -34,7 +34,7 @@ public class SwaggerConfig {
private SwaggerProperties swaggerProperties; private SwaggerProperties swaggerProperties;
@Autowired @Autowired
private TokenProperties tokenProperties; private TokenProperties tokenProperties;
@Autowired @Autowired
private OpenApiExtensionResolver openApiExtensionResolver; private OpenApiExtensionResolver openApiExtensionResolver;
@ -44,30 +44,30 @@ public class SwaggerConfig {
*/ */
@PostConstruct @PostConstruct
public void createRestApi() { public void createRestApi() {
for (SwaggerProperties.Groups group : swaggerProperties.getGroups()) { for (SwaggerProperties.Groups group : swaggerProperties.getGroups()) {
String basePackage = group.getBasePackage(); String basePackage = group.getBasePackage();
Docket docket = new Docket(DocumentationType.OAS_30) Docket docket = new Docket(DocumentationType.OAS_30)
.enable(swaggerProperties.getEnabled()) .enable(swaggerProperties.getEnabled())
// 用来创建该API的基本信息展示在文档的页面中自定义展示的信息 // 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
.apiInfo(apiInfo()) .apiInfo(apiInfo())
// 设置哪些接口暴露给Swagger展示 // 设置哪些接口暴露给Swagger展示
.select() .select()
// 扫描所有有注解的api用这种方式更灵活 // 扫描所有有注解的api用这种方式更灵活
//.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// 扫描指定包中的swagger注解 // 扫描指定包中的swagger注解
.apis(RequestHandlerSelectors.basePackage(basePackage)) .apis(RequestHandlerSelectors.basePackage(basePackage))
// 扫描所有 .apis(RequestHandlerSelectors.any()) // 扫描所有 .apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()) .paths(PathSelectors.any())
.build() .build()
.groupName(group.getName()) .groupName(group.getName())
// 设置安全模式swagger可以设置访问token // 设置安全模式swagger可以设置访问token
.securitySchemes(securitySchemes()) .securitySchemes(securitySchemes())
.securityContexts(securityContexts()) .securityContexts(securityContexts())
.extensions(openApiExtensionResolver.buildExtensions(group.getName())) .extensions(openApiExtensionResolver.buildExtensions(group.getName()))
.pathMapping(swaggerProperties.getPathMapping()); .pathMapping(swaggerProperties.getPathMapping());
String beanName = StringUtils.substringAfterLast(basePackage, ".") + "Docket"; String beanName = StringUtils.substringAfterLast(basePackage, ".") + "Docket";
SpringUtils.registerBean(beanName, docket); SpringUtils.registerBean(beanName, docket);
} }
} }
/** /**
@ -75,8 +75,8 @@ public class SwaggerConfig {
*/ */
private List<SecurityScheme> securitySchemes() { private List<SecurityScheme> securitySchemes() {
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>(); List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
String header = tokenProperties.getHeader(); String header = tokenProperties.getHeader();
apiKeyList.add(new ApiKey(header, header, In.HEADER.toValue())); apiKeyList.add(new ApiKey(header, header, In.HEADER.toValue()));
return apiKeyList; return apiKeyList;
} }
@ -86,10 +86,10 @@ public class SwaggerConfig {
private List<SecurityContext> securityContexts() { private List<SecurityContext> securityContexts() {
List<SecurityContext> securityContexts = new ArrayList<>(); List<SecurityContext> securityContexts = new ArrayList<>();
securityContexts.add( securityContexts.add(
SecurityContext.builder() SecurityContext.builder()
.securityReferences(defaultAuth()) .securityReferences(defaultAuth())
.operationSelector(o -> o.requestMappingPattern().matches("/.*")) .operationSelector(o -> o.requestMappingPattern().matches("/.*"))
.build()); .build());
return securityContexts; return securityContexts;
} }
@ -112,14 +112,14 @@ public class SwaggerConfig {
// 用ApiInfoBuilder进行定制 // 用ApiInfoBuilder进行定制
SwaggerProperties.Contact contact = swaggerProperties.getContact(); SwaggerProperties.Contact contact = swaggerProperties.getContact();
return new ApiInfoBuilder() return new ApiInfoBuilder()
// 设置标题 // 设置标题
.title(swaggerProperties.getTitle()) .title(swaggerProperties.getTitle())
// 描述 // 描述
.description(swaggerProperties.getDescription()) .description(swaggerProperties.getDescription())
// 作者信息 // 作者信息
.contact(new Contact(contact.getName(), contact.getUrl(), contact.getEmail())) .contact(new Contact(contact.getName(), contact.getUrl(), contact.getEmail()))
// 版本 // 版本
.version(swaggerProperties.getVersion()) .version(swaggerProperties.getVersion())
.build(); .build();
} }
} }

View File

@ -16,23 +16,23 @@ import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "captcha") @ConfigurationProperties(prefix = "captcha")
public class CaptchaProperties { public class CaptchaProperties {
/** /**
* 验证码类型 * 验证码类型
*/ */
private CaptchaType type; private CaptchaType type;
/** /**
* 验证码类别 * 验证码类别
*/ */
private CaptchaCategory category; private CaptchaCategory category;
/** /**
* 数字验证码位数 * 数字验证码位数
*/ */
private Integer numberLength; private Integer numberLength;
/** /**
* 字符验证码长度 * 字符验证码长度
*/ */
private Integer charLength; private Integer charLength;
} }

View File

@ -20,217 +20,217 @@ import java.util.List;
@ConfigurationProperties(prefix = "redisson") @ConfigurationProperties(prefix = "redisson")
public class RedissonProperties { public class RedissonProperties {
/** /**
* 线程池数量,默认值 = 当前处理核数量 * 2 * 线程池数量,默认值 = 当前处理核数量 * 2
*/ */
private int threads; private int threads;
/** /**
* Netty线程池数量,默认值 = 当前处理核数量 * 2 * Netty线程池数量,默认值 = 当前处理核数量 * 2
*/ */
private int nettyThreads; private int nettyThreads;
/** /**
* 传输模式 * 传输模式
*/ */
private TransportMode transportMode; private TransportMode transportMode;
/** /**
* 单机服务配置 * 单机服务配置
*/ */
private SingleServerConfig singleServerConfig; private SingleServerConfig singleServerConfig;
/** /**
* 集群服务配置 * 集群服务配置
*/ */
private ClusterServersConfig clusterServersConfig; private ClusterServersConfig clusterServersConfig;
/** /**
* 缓存组 * 缓存组
*/ */
private List<CacheGroup> cacheGroup; private List<CacheGroup> cacheGroup;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public static class SingleServerConfig { public static class SingleServerConfig {
/** /**
* 客户端名称 * 客户端名称
*/ */
private String clientName; private String clientName;
/** /**
* 最小空闲连接数 * 最小空闲连接数
*/ */
private int connectionMinimumIdleSize; private int connectionMinimumIdleSize;
/** /**
* 连接池大小 * 连接池大小
*/ */
private int connectionPoolSize; private int connectionPoolSize;
/** /**
* 连接空闲超时单位毫秒 * 连接空闲超时单位毫秒
*/ */
private int idleConnectionTimeout; private int idleConnectionTimeout;
/** /**
* 命令等待超时单位毫秒 * 命令等待超时单位毫秒
*/ */
private int timeout; private int timeout;
/** /**
* 如果尝试在此限制之内发送成功则开始启用 timeout 计时 * 如果尝试在此限制之内发送成功则开始启用 timeout 计时
*/ */
private int retryAttempts; private int retryAttempts;
/** /**
* 命令重试发送时间间隔单位毫秒 * 命令重试发送时间间隔单位毫秒
*/ */
private int retryInterval; private int retryInterval;
/** /**
* 发布和订阅连接的最小空闲连接数 * 发布和订阅连接的最小空闲连接数
*/ */
private int subscriptionConnectionMinimumIdleSize; private int subscriptionConnectionMinimumIdleSize;
/** /**
* 发布和订阅连接池大小 * 发布和订阅连接池大小
*/ */
private int subscriptionConnectionPoolSize; private int subscriptionConnectionPoolSize;
/** /**
* 单个连接最大订阅数量 * 单个连接最大订阅数量
*/ */
private int subscriptionsPerConnection; private int subscriptionsPerConnection;
/** /**
* DNS监测时间间隔单位毫秒 * DNS监测时间间隔单位毫秒
*/ */
private int dnsMonitoringInterval; private int dnsMonitoringInterval;
} }
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public static class ClusterServersConfig { public static class ClusterServersConfig {
/** /**
* 客户端名称 * 客户端名称
*/ */
private String clientName; private String clientName;
/** /**
* master最小空闲连接数 * master最小空闲连接数
*/ */
private int masterConnectionMinimumIdleSize; private int masterConnectionMinimumIdleSize;
/** /**
* master连接池大小 * master连接池大小
*/ */
private int masterConnectionPoolSize; private int masterConnectionPoolSize;
/** /**
* slave最小空闲连接数 * slave最小空闲连接数
*/ */
private int slaveConnectionMinimumIdleSize; private int slaveConnectionMinimumIdleSize;
/** /**
* slave连接池大小 * slave连接池大小
*/ */
private int slaveConnectionPoolSize; private int slaveConnectionPoolSize;
/** /**
* 连接空闲超时单位毫秒 * 连接空闲超时单位毫秒
*/ */
private int idleConnectionTimeout; private int idleConnectionTimeout;
/** /**
* ping超时 * ping超时
*/ */
private int pingConnectionInterval; private int pingConnectionInterval;
/** /**
* 命令等待超时单位毫秒 * 命令等待超时单位毫秒
*/ */
private int timeout; private int timeout;
/** /**
* 如果尝试在此限制之内发送成功则开始启用 timeout 计时 * 如果尝试在此限制之内发送成功则开始启用 timeout 计时
*/ */
private int retryAttempts; private int retryAttempts;
/** /**
* 命令重试发送时间间隔单位毫秒 * 命令重试发送时间间隔单位毫秒
*/ */
private int retryInterval; private int retryInterval;
/** /**
* 错误重试次数 * 错误重试次数
*/ */
private int failedSlaveReconnectionInterval; private int failedSlaveReconnectionInterval;
/** /**
* 发布和订阅连接池最小空闲连接数 * 发布和订阅连接池最小空闲连接数
*/ */
private int subscriptionConnectionMinimumIdleSize; private int subscriptionConnectionMinimumIdleSize;
/** /**
* 发布和订阅连接池大小 * 发布和订阅连接池大小
*/ */
private int subscriptionConnectionPoolSize; private int subscriptionConnectionPoolSize;
/** /**
* 单个连接最大订阅数量 * 单个连接最大订阅数量
*/ */
private int subscriptionsPerConnection; private int subscriptionsPerConnection;
/** /**
* 扫描间隔 * 扫描间隔
*/ */
private int scanInterval; private int scanInterval;
/** /**
* DNS监测时间间隔单位毫秒 * DNS监测时间间隔单位毫秒
*/ */
private int dnsMonitoringInterval; private int dnsMonitoringInterval;
/** /**
* 读取模式 * 读取模式
*/ */
private ReadMode readMode; private ReadMode readMode;
/** /**
* 订阅模式 * 订阅模式
*/ */
private SubscriptionMode subscriptionMode; private SubscriptionMode subscriptionMode;
} }
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public static class CacheGroup { public static class CacheGroup {
/** /**
* 组id * 组id
*/ */
private String groupId; private String groupId;
/** /**
* 组过期时间 * 组过期时间
*/ */
private long ttl; private long ttl;
/** /**
* 组最大空闲时间 * 组最大空闲时间
*/ */
private long maxIdleTime; private long maxIdleTime;
/** /**
* 组最大长度 * 组最大长度
*/ */
private int maxSize; private int maxSize;
} }
} }

View File

@ -21,10 +21,10 @@ public class SwaggerProperties {
* 验证码类型 * 验证码类型
*/ */
private Boolean enabled; private Boolean enabled;
/** /**
* 设置请求的统一前缀 * 设置请求的统一前缀
*/ */
private String pathMapping; private String pathMapping;
/** /**
* 验证码类别 * 验证码类别
*/ */
@ -38,51 +38,51 @@ public class SwaggerProperties {
*/ */
private String version; private String version;
/** /**
* 联系方式 * 联系方式
*/ */
private Contact contact; private Contact contact;
/** /**
* 组配置 * 组配置
*/ */
private List<Groups> groups; private List<Groups> groups;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public static class Contact { public static class Contact {
/** /**
* 联系人 * 联系人
*/ */
private String name; private String name;
/** /**
* 联系人url * 联系人url
*/ */
private String url; private String url;
/** /**
* 联系人email * 联系人email
*/ */
private String email; private String email;
} }
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public static class Groups { public static class Groups {
/** /**
* 组名 * 组名
*/ */
private String name; private String name;
/** /**
* 基础包路径 * 基础包路径
*/ */
private String basePackage; private String basePackage;
} }
} }

View File

@ -22,43 +22,43 @@ import java.util.Date;
@Slf4j @Slf4j
public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler { public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
@Override @Override
public void insertFill(MetaObject metaObject) { public void insertFill(MetaObject metaObject) {
try { try {
if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) { if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject(); BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
Date current = new Date(); Date current = new Date();
// 创建时间为空 则填充 // 创建时间为空 则填充
if (ObjectUtil.isNull(baseEntity.getCreateTime())) { if (ObjectUtil.isNull(baseEntity.getCreateTime())) {
baseEntity.setCreateTime(current); baseEntity.setCreateTime(current);
} }
// 更新时间为空 则填充 // 更新时间为空 则填充
if (ObjectUtil.isNull(baseEntity.getUpdateTime())) { if (ObjectUtil.isNull(baseEntity.getUpdateTime())) {
baseEntity.setUpdateTime(current); baseEntity.setUpdateTime(current);
} }
String username = getLoginUsername(); String username = getLoginUsername();
// 当前已登录 创建人为空 则填充 // 当前已登录 创建人为空 则填充
if (StringUtils.isNotBlank(username) if (StringUtils.isNotBlank(username)
&& StringUtils.isBlank(baseEntity.getCreateBy())) { && StringUtils.isBlank(baseEntity.getCreateBy())) {
baseEntity.setCreateBy(username); baseEntity.setCreateBy(username);
} }
// 当前已登录 更新人为空 则填充 // 当前已登录 更新人为空 则填充
if (StringUtils.isNotBlank(username) if (StringUtils.isNotBlank(username)
&& StringUtils.isBlank(baseEntity.getUpdateBy())) { && StringUtils.isBlank(baseEntity.getUpdateBy())) {
baseEntity.setUpdateBy(username); baseEntity.setUpdateBy(username);
} }
} }
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED); throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
} }
} }
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
try { try {
if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) { if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject(); BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
Date current = new Date(); Date current = new Date();
// 更新时间填充(不管为不为空) // 更新时间填充(不管为不为空)
baseEntity.setUpdateTime(current); baseEntity.setUpdateTime(current);
String username = getLoginUsername(); String username = getLoginUsername();
@ -66,24 +66,24 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
if (StringUtils.isNotBlank(username)) { if (StringUtils.isNotBlank(username)) {
baseEntity.setUpdateBy(username); baseEntity.setUpdateBy(username);
} }
} }
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED); throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
} }
} }
/** /**
* 获取登录用户名 * 获取登录用户名
*/ */
private String getLoginUsername() { private String getLoginUsername() {
LoginUser loginUser; LoginUser loginUser;
try { try {
loginUser = SecurityUtils.getLoginUser(); loginUser = SecurityUtils.getLoginUser();
} catch (Exception e) { } catch (Exception e) {
log.warn("自动注入警告 => 用户未登录"); log.warn("自动注入警告 => 用户未登录");
return null; return null;
} }
return loginUser.getUsername(); return loginUser.getUsername();
} }
} }

View File

@ -15,28 +15,28 @@ import java.io.IOException;
@JacksonStdImpl @JacksonStdImpl
public class BigNumberSerializer extends NumberSerializer { public class BigNumberSerializer extends NumberSerializer {
/** /**
* 根据 JS Number.MAX_SAFE_INTEGER Number.MIN_SAFE_INTEGER 得来 * 根据 JS Number.MAX_SAFE_INTEGER Number.MIN_SAFE_INTEGER 得来
*/ */
private static final long MAX_SAFE_INTEGER = 9007199254740991L; private static final long MAX_SAFE_INTEGER = 9007199254740991L;
private static final long MIN_SAFE_INTEGER = -9007199254740991L; private static final long MIN_SAFE_INTEGER = -9007199254740991L;
/** /**
* 提供实例 * 提供实例
*/ */
public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class); public static final BigNumberSerializer INSTANCE = new BigNumberSerializer(Number.class);
public BigNumberSerializer(Class<? extends Number> rawType) { public BigNumberSerializer(Class<? extends Number> rawType) {
super(rawType); super(rawType);
} }
@Override @Override
public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException { public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException {
// 超出范围 序列化位字符串 // 超出范围 序列化位字符串
if (value.longValue() > MIN_SAFE_INTEGER && value.longValue() < MAX_SAFE_INTEGER) { if (value.longValue() > MIN_SAFE_INTEGER && value.longValue() < MAX_SAFE_INTEGER) {
super.serialize(value, gen, provider); super.serialize(value, gen, provider);
} else { } else {
gen.writeString(value.toString()); gen.writeString(value.toString());
} }
} }
} }

View File

@ -18,24 +18,24 @@ import java.util.concurrent.ScheduledExecutorService;
@Component @Component
public class ShutdownManager { public class ShutdownManager {
@Autowired @Autowired
@Qualifier("scheduledExecutorService") @Qualifier("scheduledExecutorService")
private ScheduledExecutorService scheduledExecutorService; private ScheduledExecutorService scheduledExecutorService;
@PreDestroy @PreDestroy
public void destroy() { public void destroy() {
shutdownAsyncManager(); shutdownAsyncManager();
} }
/** /**
* 停止异步执行任务 * 停止异步执行任务
*/ */
private void shutdownAsyncManager() { private void shutdownAsyncManager() {
try { try {
log.info("====关闭后台任务任务线程池===="); log.info("====关闭后台任务任务线程池====");
Threads.shutdownAndAwaitTermination(scheduledExecutorService); Threads.shutdownAndAwaitTermination(scheduledExecutorService);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
} }
} }

View File

@ -28,28 +28,28 @@ import java.io.IOException;
@Configuration @Configuration
public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler { public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Autowired @Autowired
private LogininforService asyncService; private LogininforService asyncService;
/** /**
* 退出处理 * 退出处理
*/ */
@Override @Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws IOException, ServletException { throws IOException, ServletException {
LoginUser loginUser = tokenService.getLoginUser(request); LoginUser loginUser = tokenService.getLoginUser(request);
String message = MessageUtils.message("user.logout.success"); String message = MessageUtils.message("user.logout.success");
if (StringUtils.isNotNull(loginUser)) { if (StringUtils.isNotNull(loginUser)) {
String userName = loginUser.getUsername(); String userName = loginUser.getUsername();
// 删除用户缓存记录 // 删除用户缓存记录
tokenService.delLoginUser(loginUser.getToken()); tokenService.delLoginUser(loginUser.getToken());
// 记录用户退出日志 // 记录用户退出日志
asyncService.recordLogininfor(userName, Constants.LOGOUT, message, request); asyncService.recordLogininfor(userName, Constants.LOGOUT, message, request);
} }
ServletUtils.renderString(response, JsonUtils.toJsonString(AjaxResult.error(HttpStatus.HTTP_OK, message))); ServletUtils.renderString(response, JsonUtils.toJsonString(AjaxResult.error(HttpStatus.HTTP_OK, message)));
} }
} }

View File

@ -70,7 +70,7 @@ public class SysConfig extends BaseEntity {
*/ */
@ApiModelProperty(value = "系统内置Y是 N否") @ApiModelProperty(value = "系统内置Y是 N否")
@ExcelProperty(value = "系统内置", converter = ExcelDictConvert.class) @ExcelProperty(value = "系统内置", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_yes_no") @ExcelDictFormat(dictType = "sys_yes_no")
private String configType; private String configType;
/** /**

View File

@ -52,7 +52,7 @@ public class SysOperLog implements Serializable {
*/ */
@ApiModelProperty(value = "业务类型0其它 1新增 2修改 3删除") @ApiModelProperty(value = "业务类型0其它 1新增 2修改 3删除")
@ExcelProperty(value = "业务类型", converter = ExcelDictConvert.class) @ExcelProperty(value = "业务类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_oper_type") @ExcelDictFormat(dictType = "sys_oper_type")
private Integer businessType; private Integer businessType;
/** /**
@ -81,7 +81,7 @@ public class SysOperLog implements Serializable {
*/ */
@ApiModelProperty(value = "操作类别0其它 1后台用户 2手机端用户") @ApiModelProperty(value = "操作类别0其它 1后台用户 2手机端用户")
@ExcelProperty(value = "操作类别", converter = ExcelDictConvert.class) @ExcelProperty(value = "操作类别", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "0=其它,1=后台用户,2=手机端用户") @ExcelDictFormat(readConverterExp = "0=其它,1=后台用户,2=手机端用户")
private Integer operatorType; private Integer operatorType;
/** /**
@ -138,7 +138,7 @@ public class SysOperLog implements Serializable {
*/ */
@ApiModelProperty(value = "操作状态0正常 1异常") @ApiModelProperty(value = "操作状态0正常 1异常")
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class) @ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_common_status") @ExcelDictFormat(dictType = "sys_common_status")
private Integer status; private Integer status;
/** /**

View File

@ -19,35 +19,35 @@ import lombok.experimental.Accessors;
@TableName("sys_oss") @TableName("sys_oss")
public class SysOss extends BaseEntity { public class SysOss extends BaseEntity {
/** /**
* 对象存储主键 * 对象存储主键
*/ */
@TableId(value = "oss_id", type = IdType.AUTO) @TableId(value = "oss_id", type = IdType.AUTO)
private Long ossId; private Long ossId;
/** /**
* 文件名 * 文件名
*/ */
private String fileName; private String fileName;
/** /**
* 原名 * 原名
*/ */
private String originalName; private String originalName;
/** /**
* 文件后缀名 * 文件后缀名
*/ */
private String fileSuffix; private String fileSuffix;
/** /**
* URL地址 * URL地址
*/ */
private String url; private String url;
/** /**
* 服务商 * 服务商
*/ */
private String service; private String service;
} }

View File

@ -69,8 +69,8 @@ public class SysPost extends BaseEntity {
* 状态0正常 1停用 * 状态0正常 1停用
*/ */
@ApiModelProperty(value = "状态0正常 1停用") @ApiModelProperty(value = "状态0正常 1停用")
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class) @ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "sys_common_status") @ExcelDictFormat(dictType = "sys_common_status")
private String status; private String status;
/** /**

View File

@ -426,9 +426,8 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
* *
* @return * @return
*/ */
public String innerLinkReplaceEach(String path) public String innerLinkReplaceEach(String path) {
{ return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS},
return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS }, new String[]{"", ""});
new String[] { "", "" });
} }
} }