refactor: 代码生成器优化重构 - 可提用户筛选适合的Java类型

v1.4.1
Carina 4 years ago
parent 608341ae2e
commit 36d29de268

@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -42,24 +42,24 @@ public class TestCarModel extends ApiWrapper {
@ApiModelProperty(value = "汽车名称") @ApiModelProperty(value = "汽车名称")
@ExcelProperty(value = "汽车名称", order = 1) @ExcelProperty(value = "汽车名称", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(20) @ValidatorLenMax(20)
private String carName; private String carName;
/** 汽车类型 */ /** 汽车类型 */
@ApiModelProperty(value = "汽车类型") @ApiModelProperty(value = "汽车类型")
@ExcelProperty(value = "汽车类型", order = 2) @ExcelProperty(value = "汽车类型", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(20) @ValidatorLenMax(20)
private String carType; private String carType;
/** 汽车品牌 */ /** 汽车品牌 */
@ApiModelProperty(value = "汽车品牌") @ApiModelProperty(value = "汽车品牌")
@ExcelProperty(value = "汽车品牌", order = 3) @ExcelProperty(value = "汽车品牌", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String carBrand; private String carBrand;
/** 生产日期 */ /** 生产日期 */
@ -74,7 +74,7 @@ public class TestCarModel extends ApiWrapper {
@ApiModelProperty(value = "是否启用") @ApiModelProperty(value = "是否启用")
@ExcelProperty(value = "是否启用", order = 5) @ExcelProperty(value = "是否启用", order = 5)
@ExcelInfo( dictType = "no_yes" ) @ExcelInfo( dictType = "no_yes" )
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izUsable; private String izUsable;

@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
@ -43,31 +43,31 @@ public class TestUserModel extends ApiWrapper {
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
@ExcelProperty(value = "名称", order = 1) @ExcelProperty(value = "名称", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String name; private String name;
/** 金钱 */ /** 金钱 */
@ApiModelProperty(value = "金钱") @ApiModelProperty(value = "金钱")
@ExcelProperty(value = "金钱", order = 2) @ExcelProperty(value = "金钱", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_MONEY}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_MONEY})
@ValidationArgsLenMax(8) @ValidatorLenMax(8)
private Double money; private Double money;
/** 年龄 */ /** 年龄 */
@ApiModelProperty(value = "年龄") @ApiModelProperty(value = "年龄")
@ExcelProperty(value = "年龄", order = 3) @ExcelProperty(value = "年龄", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_INTEGER}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_INTEGER})
@ValidationArgsLenMax(5) @ValidatorLenMax(5)
private Integer age; private Integer age;
/** 生日 */ /** 生日 */
@ApiModelProperty(value = "生日") @ApiModelProperty(value = "生日")
@ExcelProperty(value = "生日", order = 4) @ExcelProperty(value = "生日", order = 4)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, }) @Validator({ValidatorType.IS_NOT_NULL, })
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birth; private Date birth;
@ -76,8 +76,8 @@ public class TestUserModel extends ApiWrapper {
@ApiModelProperty(value = "是否启用") @ApiModelProperty(value = "是否启用")
@ExcelProperty(value = "是否启用", order = 5) @ExcelProperty(value = "是否启用", order = 5)
@ExcelInfo( dictType = "no_yes" ) @ExcelInfo( dictType = "no_yes" )
@ValidationArgs({ValiArgsType.IS_NOT_NULL, }) @Validator({ValidatorType.IS_NOT_NULL, })
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izUsable; private String izUsable;

@ -15,15 +15,14 @@
*/ */
package org.opsli.api.wrapper.system.area; package org.opsli.api.wrapper.system.area;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -40,23 +39,23 @@ public class SysAreaModel extends ApiWrapper {
@ApiModelProperty(value = "父级主键") @ApiModelProperty(value = "父级主键")
@ExcelProperty(value = "父级主键", order = 1) @ExcelProperty(value = "父级主键", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(19) @ValidatorLenMax(19)
private String parentId; private String parentId;
/** 地域编号 */ /** 地域编号 */
@ApiModelProperty(value = "地域编号") @ApiModelProperty(value = "地域编号")
@ExcelProperty(value = "地域编号", order = 2) @ExcelProperty(value = "地域编号", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_INTEGER}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_INTEGER})
@ValidationArgsLenMax(40) @ValidatorLenMax(40)
private String areaCode; private String areaCode;
/** 地域名称 */ /** 地域名称 */
@ApiModelProperty(value = "地域名称") @ApiModelProperty(value = "地域名称")
@ExcelProperty(value = "地域名称", order = 3) @ExcelProperty(value = "地域名称", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(40) @ValidatorLenMax(40)
private String areaName; private String areaName;
} }

@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -40,53 +40,53 @@ public class DictDetailModel extends ApiWrapper {
/** 字典ID */ /** 字典ID */
@ApiModelProperty(value = "字典类型ID") @ApiModelProperty(value = "字典类型ID")
@ExcelIgnore @ExcelIgnore
@ValidationArgs(ValiArgsType.IS_NOT_NULL) @Validator(ValidatorType.IS_NOT_NULL)
private String typeId; private String typeId;
/** 类型编号 - 冗余 */ /** 类型编号 - 冗余 */
@ApiModelProperty(value = "字典类型Code") @ApiModelProperty(value = "字典类型Code")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(120) @ValidatorLenMax(120)
private String typeCode; private String typeCode;
/** 字典名称 */ /** 字典名称 */
@ApiModelProperty(value = "字典名称") @ApiModelProperty(value = "字典名称")
@ExcelProperty(value = "字典名称", order = 1) @ExcelProperty(value = "字典名称", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(120) @ValidatorLenMax(120)
private String dictName; private String dictName;
/** 字典值 */ /** 字典值 */
@ApiModelProperty(value = "字典值") @ApiModelProperty(value = "字典值")
@ExcelProperty(value = "字典值", order = 2) @ExcelProperty(value = "字典值", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(120) @ValidatorLenMax(120)
private String dictValue; private String dictValue;
/** 是否内置数据 0否 1是*/ /** 是否内置数据 0否 1是*/
@ApiModelProperty(value = "是否内置数据 0否 1是") @ApiModelProperty(value = "是否内置数据 0否 1是")
@ExcelProperty(value = "是否内置数据", order = 2) @ExcelProperty(value = "是否内置数据", order = 2)
@ExcelInfo(dictType = "no_yes") @ExcelInfo(dictType = "no_yes")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izLock; private String izLock;
/** 排序 */ /** 排序 */
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
@ExcelProperty(value = "排序", order = 2) @ExcelProperty(value = "排序", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_INTEGER}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_INTEGER})
@ValidationArgsLenMax(10) @ValidatorLenMax(10)
private Integer sortNo; private Integer sortNo;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelProperty(value = "备注", order = 2) @ExcelProperty(value = "备注", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;

@ -20,9 +20,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -41,31 +41,31 @@ public class DictModel extends ApiWrapper {
@ApiModelProperty(value = "字典类型编号") @ApiModelProperty(value = "字典类型编号")
@ExcelProperty(value = "字典类型编号", order = 1) @ExcelProperty(value = "字典类型编号", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(120) @ValidatorLenMax(120)
private String typeCode; private String typeCode;
/** 字典类型名称 */ /** 字典类型名称 */
@ApiModelProperty(value = "字典类型名称") @ApiModelProperty(value = "字典类型名称")
@ExcelProperty(value = "字典类型名称", order = 2) @ExcelProperty(value = "字典类型名称", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(120) @ValidatorLenMax(120)
private String typeName; private String typeName;
/** 是否内置数据 0否 1是*/ /** 是否内置数据 0否 1是*/
@ApiModelProperty(value = "是否内置数据 0否 1是") @ApiModelProperty(value = "是否内置数据 0否 1是")
@ExcelProperty(value = "是否内置数据", order = 3) @ExcelProperty(value = "是否内置数据", order = 3)
@ExcelInfo(dictType = "no_yes") @ExcelInfo(dictType = "no_yes")
@ValidationArgs(ValiArgsType.IS_NOT_NULL) @Validator(ValidatorType.IS_NOT_NULL)
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izLock; private String izLock;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelProperty(value = "备注", order = 4) @ExcelProperty(value = "备注", order = 4)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;

@ -19,10 +19,9 @@ import com.alibaba.excel.annotation.ExcelIgnore;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.enums.ValidatorType;
import org.opsli.common.enums.ValiArgsType;
import java.io.Serializable; import java.io.Serializable;
@ -41,28 +40,28 @@ public class MenuFullModel implements Serializable {
/** 上级菜单ID */ /** 上级菜单ID */
@ApiModelProperty(value = "上级菜单ID") @ApiModelProperty(value = "上级菜单ID")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(19) @ValidatorLenMax(19)
private String parentId; private String parentId;
/** 菜单名称 */ /** 菜单名称 */
@ApiModelProperty(value = "菜单名称") @ApiModelProperty(value = "菜单名称")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String title; private String title;
/** 模块名 */ /** 模块名 */
@ApiModelProperty(value = "模块名") @ApiModelProperty(value = "模块名")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(40) @ValidatorLenMax(40)
private String moduleName; private String moduleName;
/** 子模块名 */ /** 子模块名 */
@ApiModelProperty(value = "子模块名") @ApiModelProperty(value = "子模块名")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(40) @ValidatorLenMax(40)
private String subModuleName; private String subModuleName;
} }

@ -16,16 +16,13 @@
package org.opsli.api.wrapper.system.menu; package org.opsli.api.wrapper.system.menu;
import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
* *
@ -40,70 +37,70 @@ public class MenuModel extends ApiWrapper {
/** 父级主键 */ /** 父级主键 */
@ApiModelProperty(value = "父级主键") @ApiModelProperty(value = "父级主键")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(20) @ValidatorLenMax(20)
private String parentId; private String parentId;
/** 权限编号 */ /** 权限编号 */
@ApiModelProperty(value = "权限编号") @ApiModelProperty(value = "权限编号")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String permissions; private String permissions;
/** 菜单名称 */ /** 菜单名称 */
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String menuName; private String menuName;
/** 图标 */ /** 图标 */
@ApiModelProperty(value = "图标") @ApiModelProperty(value = "图标")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String icon; private String icon;
/** 项目类型: 1-菜单 2-按钮 3-链接 */ /** 项目类型: 1-菜单 2-按钮 3-链接 */
@ApiModelProperty(value = "项目类型") @ApiModelProperty(value = "项目类型")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(20) @ValidatorLenMax(20)
private String type; private String type;
/** url地址 */ /** url地址 */
@ApiModelProperty(value = "url地址") @ApiModelProperty(value = "url地址")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String url; private String url;
/** 组件 - vue 对应组件 */ /** 组件 - vue 对应组件 */
@ApiModelProperty(value = "组件") @ApiModelProperty(value = "组件")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String component; private String component;
/** 重定向 */ /** 重定向 */
@ApiModelProperty(value = "重定向") @ApiModelProperty(value = "重定向")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String redirect; private String redirect;
/** 排序 */ /** 排序 */
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
private Integer sortNo; private Integer sortNo;
/** 是否隐藏 0为否 1为是 */ /** 是否隐藏 0为否 1为是 */
@ApiModelProperty(value = "是否隐藏") @ApiModelProperty(value = "是否隐藏")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
private String hidden; private String hidden;
/** 是否总是显示 0为否 1为是 */ /** 是否总是显示 0为否 1为是 */
@ApiModelProperty(value = "是否隐藏") @ApiModelProperty(value = "是否隐藏")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
private String alwaysShow; private String alwaysShow;
} }

@ -22,9 +22,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -44,36 +44,36 @@ public class OptionsModel extends ApiWrapper {
@ApiModelProperty(value = "参数编号") @ApiModelProperty(value = "参数编号")
@ExcelProperty(value = "参数编号", order = 1) @ExcelProperty(value = "参数编号", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String optionCode; private String optionCode;
/** 参数名称 */ /** 参数名称 */
@ApiModelProperty(value = "参数名称") @ApiModelProperty(value = "参数名称")
@ExcelProperty(value = "参数名称", order = 2) @ExcelProperty(value = "参数名称", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String optionName; private String optionName;
/** 参数值 */ /** 参数值 */
@ApiModelProperty(value = "参数值") @ApiModelProperty(value = "参数值")
@ExcelProperty(value = "参数值", order = 3) @ExcelProperty(value = "参数值", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(10000) @ValidatorLenMax(10000)
private String optionValue; private String optionValue;
/** 是否内置数据 0否 1是*/ /** 是否内置数据 0否 1是*/
@ApiModelProperty(value = "是否内置数据 0否 1是") @ApiModelProperty(value = "是否内置数据 0否 1是")
@ExcelProperty(value = "是否内置数据", order = 4) @ExcelProperty(value = "是否内置数据", order = 4)
@ExcelInfo(dictType = "no_yes") @ExcelInfo(dictType = "no_yes")
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izLock; private String izLock;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelProperty(value = "备注", order = 5) @ExcelProperty(value = "备注", order = 5)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;
} }

@ -22,9 +22,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -41,44 +41,44 @@ public class SysOrgModel extends ApiWrapper {
@ApiModelProperty(value = "父级主键") @ApiModelProperty(value = "父级主键")
@ExcelProperty(value = "父级主键", order = 1) @ExcelProperty(value = "父级主键", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(19) @ValidatorLenMax(19)
private String parentId; private String parentId;
/** 组织机构编号 */ /** 组织机构编号 */
@ApiModelProperty(value = "组织机构编号") @ApiModelProperty(value = "组织机构编号")
@ExcelProperty(value = "组织机构编号", order = 2) @ExcelProperty(value = "组织机构编号", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(120) @ValidatorLenMax(120)
private String orgCode; private String orgCode;
/** 组织机构名称 */ /** 组织机构名称 */
@ApiModelProperty(value = "组织机构名称") @ApiModelProperty(value = "组织机构名称")
@ExcelProperty(value = "组织机构名称", order = 3) @ExcelProperty(value = "组织机构名称", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(120) @ValidatorLenMax(120)
private String orgName; private String orgName;
/** 组织机构类型 1-公司 2-部门 3-岗位*/ /** 组织机构类型 1-公司 2-部门 3-岗位*/
@ApiModelProperty(value = "组织机构类型") @ApiModelProperty(value = "组织机构类型")
@ExcelProperty(value = "组织机构类型", order = 4) @ExcelProperty(value = "组织机构类型", order = 4)
@ExcelInfo( dictType = "org_type") @ExcelInfo( dictType = "org_type")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(3) @ValidatorLenMax(3)
private String orgType; private String orgType;
/** 排序 */ /** 排序 */
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
@ExcelProperty(value = "排序", order = 5) @ExcelProperty(value = "排序", order = 5)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(10) @ValidatorLenMax(10)
private Integer sortNo; private Integer sortNo;
/** 多租户字段 */ /** 多租户字段 */
@ApiModelProperty(value = "多租户ID") @ApiModelProperty(value = "多租户ID")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(20) @ValidatorLenMax(20)
private String tenantId; private String tenantId;
} }

@ -19,9 +19,9 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import java.io.Serializable; import java.io.Serializable;
@ -38,8 +38,8 @@ public class RoleMenuRefModel implements Serializable {
/** 角色ID */ /** 角色ID */
@ApiModelProperty(value = "角色ID") @ApiModelProperty(value = "角色ID")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String roleId; private String roleId;
/** 权限数组 */ /** 权限数组 */

@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -40,38 +40,38 @@ public class RoleModel extends ApiWrapper {
@ApiModelProperty(value = "角色编码") @ApiModelProperty(value = "角色编码")
@ExcelProperty(value = "角色编码", order = 1) @ExcelProperty(value = "角色编码", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String roleCode; private String roleCode;
/** 角色名称 */ /** 角色名称 */
@ApiModelProperty(value = "角色编码") @ApiModelProperty(value = "角色编码")
@ExcelProperty(value = "角色编码", order = 2) @ExcelProperty(value = "角色编码", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String roleName; private String roleName;
/** 是否内置数据 0否 1是*/ /** 是否内置数据 0否 1是*/
@ApiModelProperty(value = "是否内置数据 0否 1是") @ApiModelProperty(value = "是否内置数据 0否 1是")
@ExcelProperty(value = "是否内置数据", order = 3) @ExcelProperty(value = "是否内置数据", order = 3)
@ExcelInfo(dictType = "no_yes") @ExcelInfo(dictType = "no_yes")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izLock; private String izLock;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelProperty(value = "备注", order = 4) @ExcelProperty(value = "备注", order = 4)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;
/** 多租户字段 */ /** 多租户字段 */
@ApiModelProperty(value = "多租户ID") @ApiModelProperty(value = "多租户ID")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(20) @ValidatorLenMax(20)
private String tenantId; private String tenantId;
} }

@ -20,9 +20,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -40,23 +40,23 @@ public class TenantModel extends ApiWrapper {
@ApiModelProperty(value = "租户名称") @ApiModelProperty(value = "租户名称")
@ExcelProperty(value = "租户名称", order = 1) @ExcelProperty(value = "租户名称", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String tenantName; private String tenantName;
/** 是否启用 0否 1是*/ /** 是否启用 0否 1是*/
@ApiModelProperty(value = "是否启用") @ApiModelProperty(value = "是否启用")
@ExcelProperty(value = "是否启用", order = 2) @ExcelProperty(value = "是否启用", order = 2)
@ExcelInfo(dictType = "no_yes") @ExcelInfo(dictType = "no_yes")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String enable; private String enable;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelProperty(value = "备注", order = 3) @ExcelProperty(value = "备注", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;

@ -21,10 +21,10 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin; import org.opsli.common.annotation.validator.ValidatorLenMin;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -41,100 +41,100 @@ public class UserAndOrgModel extends ApiWrapper {
/** 登录账户 */ /** 登录账户 */
@ApiModelProperty(value = "登录账户") @ApiModelProperty(value = "登录账户")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(32) @ValidatorLenMax(32)
@ValidationArgsLenMin(5) @ValidatorLenMin(5)
private String username; private String username;
/** 登录密码 */ /** 登录密码 */
@ApiModelProperty(value = "登录密码") @ApiModelProperty(value = "登录密码")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMin(6) @ValidatorLenMin(6)
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String password; private String password;
/** 登录密码强度 */ /** 登录密码强度 */
@ApiModelProperty(value = "登录密码强度") @ApiModelProperty(value = "登录密码强度")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMin(1) @ValidatorLenMin(1)
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String passwordLevel; private String passwordLevel;
/** 盐值,密码秘钥 */ /** 盐值,密码秘钥 */
@ApiModelProperty(value = "盐值,密码秘钥") @ApiModelProperty(value = "盐值,密码秘钥")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String secretKey; private String secretKey;
/** 启用状态 */ /** 启用状态 */
@ApiModelProperty(value = "启用状态") @ApiModelProperty(value = "启用状态")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String enable; private String enable;
/** 真实姓名 */ /** 真实姓名 */
@ApiModelProperty(value = "真实姓名") @ApiModelProperty(value = "真实姓名")
@ExcelProperty(value = "真实姓名", order = 1) @ExcelProperty(value = "真实姓名", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String realName; private String realName;
/** 手机 */ /** 手机 */
@ApiModelProperty(value = "手机") @ApiModelProperty(value = "手机")
@ExcelProperty(value = "手机", order = 2) @ExcelProperty(value = "手机", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_MOBILE}) @Validator({ValidatorType.IS_MOBILE})
private String mobile; private String mobile;
/** 邮箱 */ /** 邮箱 */
@ApiModelProperty(value = "邮箱") @ApiModelProperty(value = "邮箱")
@ExcelProperty(value = "邮箱", order = 3) @ExcelProperty(value = "邮箱", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_EMAIL}) @Validator({ValidatorType.IS_EMAIL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String email; private String email;
/** 工号 */ /** 工号 */
@ApiModelProperty(value = "工号") @ApiModelProperty(value = "工号")
@ExcelProperty(value = "工号", order = 4) @ExcelProperty(value = "工号", order = 4)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(32) @ValidatorLenMax(32)
private String no; private String no;
/** 头像 */ /** 头像 */
@ApiModelProperty(value = "头像") @ApiModelProperty(value = "头像")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String avatar; private String avatar;
/** 最后登陆IP */ /** 最后登陆IP */
@ApiModelProperty(value = "最后登陆IP") @ApiModelProperty(value = "最后登陆IP")
@ExcelIgnore @ExcelIgnore
@ValidationArgs(ValiArgsType.IS_IPV4) @Validator(ValidatorType.IS_IPV4)
private String loginIp; private String loginIp;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelProperty(value = "备注", order = 5) @ExcelProperty(value = "备注", order = 5)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;
/** 签名 */ /** 签名 */
@ApiModelProperty(value = "签名") @ApiModelProperty(value = "签名")
@ExcelProperty(value = "签名", order = 5) @ExcelProperty(value = "签名", order = 5)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String sign; private String sign;
/** 多租户字段 */ /** 多租户字段 */
@ApiModelProperty(value = "多租户ID") @ApiModelProperty(value = "多租户ID")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(20) @ValidatorLenMax(20)
private String tenantId; private String tenantId;
/** 组织机构 */ /** 组织机构 */

@ -16,15 +16,14 @@
package org.opsli.api.wrapper.system.user; package org.opsli.api.wrapper.system.user;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin; import org.opsli.common.annotation.validator.ValidatorLenMin;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import java.util.List; import java.util.List;
@ -42,46 +41,46 @@ public class UserInfo extends ApiWrapper {
/** 登录账户 */ /** 登录账户 */
@ApiModelProperty(value = "登录账户") @ApiModelProperty(value = "登录账户")
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(32) @ValidatorLenMax(32)
@ValidationArgsLenMin(5) @ValidatorLenMin(5)
private String username; private String username;
/** 真实姓名 */ /** 真实姓名 */
@ApiModelProperty(value = "真实姓名") @ApiModelProperty(value = "真实姓名")
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String realName; private String realName;
/** 手机 */ /** 手机 */
@ApiModelProperty(value = "手机") @ApiModelProperty(value = "手机")
@ValidationArgs({ValiArgsType.IS_MOBILE}) @Validator({ValidatorType.IS_MOBILE})
private String mobile; private String mobile;
/** 邮箱 */ /** 邮箱 */
@ApiModelProperty(value = "邮箱") @ApiModelProperty(value = "邮箱")
@ValidationArgs({ValiArgsType.IS_EMAIL}) @Validator({ValidatorType.IS_EMAIL})
private String email; private String email;
/** 工号 */ /** 工号 */
@ApiModelProperty(value = "工号") @ApiModelProperty(value = "工号")
@ValidationArgs({ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(32) @ValidatorLenMax(32)
private String no; private String no;
/** 头像 */ /** 头像 */
@ApiModelProperty(value = "头像") @ApiModelProperty(value = "头像")
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String avatar; private String avatar;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;
/** 签名 */ /** 签名 */
@ApiModelProperty(value = "签名") @ApiModelProperty(value = "签名")
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String sign; private String sign;
/** 角色列表 */ /** 角色列表 */

@ -21,10 +21,10 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin; import org.opsli.common.annotation.validator.ValidatorLenMin;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -40,99 +40,99 @@ public class UserModel extends ApiWrapper {
/** 登录账户 */ /** 登录账户 */
@ApiModelProperty(value = "登录账户") @ApiModelProperty(value = "登录账户")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(32) @ValidatorLenMax(32)
@ValidationArgsLenMin(5) @ValidatorLenMin(5)
private String username; private String username;
/** 登录密码 */ /** 登录密码 */
@ApiModelProperty(value = "登录密码") @ApiModelProperty(value = "登录密码")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMin(6) @ValidatorLenMin(6)
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String password; private String password;
/** 登录密码强度 */ /** 登录密码强度 */
@ApiModelProperty(value = "登录密码强度") @ApiModelProperty(value = "登录密码强度")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMin(1) @ValidatorLenMin(1)
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String passwordLevel; private String passwordLevel;
/** 盐值,密码秘钥 */ /** 盐值,密码秘钥 */
@ApiModelProperty(value = "盐值,密码秘钥") @ApiModelProperty(value = "盐值,密码秘钥")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String secretKey; private String secretKey;
/** 是否启用 */ /** 是否启用 */
@ApiModelProperty(value = "是否启用") @ApiModelProperty(value = "是否启用")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String enable; private String enable;
/** 真实姓名 */ /** 真实姓名 */
@ApiModelProperty(value = "真实姓名") @ApiModelProperty(value = "真实姓名")
@ExcelProperty(value = "真实姓名", order = 1) @ExcelProperty(value = "真实姓名", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String realName; private String realName;
/** 手机 */ /** 手机 */
@ApiModelProperty(value = "手机") @ApiModelProperty(value = "手机")
@ExcelProperty(value = "手机", order = 2) @ExcelProperty(value = "手机", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_MOBILE}) @Validator({ValidatorType.IS_MOBILE})
private String mobile; private String mobile;
/** 邮箱 */ /** 邮箱 */
@ApiModelProperty(value = "邮箱") @ApiModelProperty(value = "邮箱")
@ExcelProperty(value = "邮箱", order = 3) @ExcelProperty(value = "邮箱", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_EMAIL}) @Validator({ValidatorType.IS_EMAIL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String email; private String email;
/** 工号 */ /** 工号 */
@ApiModelProperty(value = "工号") @ApiModelProperty(value = "工号")
@ExcelProperty(value = "工号", order = 4) @ExcelProperty(value = "工号", order = 4)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(32) @ValidatorLenMax(32)
private String no; private String no;
/** 头像 */ /** 头像 */
@ApiModelProperty(value = "头像") @ApiModelProperty(value = "头像")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String avatar; private String avatar;
/** 最后登陆IP */ /** 最后登陆IP */
@ApiModelProperty(value = "最后登陆IP") @ApiModelProperty(value = "最后登陆IP")
@ExcelIgnore @ExcelIgnore
@ValidationArgs(ValiArgsType.IS_IPV4) @Validator(ValidatorType.IS_IPV4)
private String loginIp; private String loginIp;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelProperty(value = "备注", order = 5) @ExcelProperty(value = "备注", order = 5)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;
/** 签名 */ /** 签名 */
@ApiModelProperty(value = "签名") @ApiModelProperty(value = "签名")
@ExcelProperty(value = "签名", order = 5) @ExcelProperty(value = "签名", order = 5)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String sign; private String sign;
/** 多租户字段 */ /** 多租户字段 */
@ApiModelProperty(value = "多租户ID") @ApiModelProperty(value = "多租户ID")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(20) @ValidatorLenMax(20)
private String tenantId; private String tenantId;

@ -19,9 +19,9 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import java.io.Serializable; import java.io.Serializable;
@ -38,27 +38,27 @@ public class UserOrgRefModel implements Serializable {
/** 用户ID */ /** 用户ID */
@ApiModelProperty(value = "用户ID") @ApiModelProperty(value = "用户ID")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String userId; private String userId;
@ApiModelProperty(value = "公司") @ApiModelProperty(value = "公司")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(19) @ValidatorLenMax(19)
private String companyId; private String companyId;
@ApiModelProperty(value = "公司名称") @ApiModelProperty(value = "公司名称")
private String companyName; private String companyName;
@ApiModelProperty(value = "部门ID") @ApiModelProperty(value = "部门ID")
@ValidationArgsLenMax(19) @ValidatorLenMax(19)
private String departmentId; private String departmentId;
@ApiModelProperty(value = "部门名称") @ApiModelProperty(value = "部门名称")
private String departmentName; private String departmentName;
@ApiModelProperty(value = "岗位ID") @ApiModelProperty(value = "岗位ID")
@ValidationArgsLenMax(19) @ValidatorLenMax(19)
private String postId; private String postId;
@ApiModelProperty(value = "岗位名称") @ApiModelProperty(value = "岗位名称")

@ -20,10 +20,10 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin; import org.opsli.common.annotation.validator.ValidatorLenMin;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import java.io.Serializable; import java.io.Serializable;
@ -46,29 +46,29 @@ public class UserPassword implements Serializable {
/** 旧密码 */ /** 旧密码 */
@ApiModelProperty(value = "旧密码") @ApiModelProperty(value = "旧密码")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMin(6) @ValidatorLenMin(6)
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String oldPassword; private String oldPassword;
/** 新密码 */ /** 新密码 */
@ApiModelProperty(value = "新密码") @ApiModelProperty(value = "新密码")
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_SECURITY_PASSWORD}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_SECURITY_PASSWORD})
@ValidationArgsLenMin(6) @ValidatorLenMin(6)
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String newPassword; private String newPassword;
/** 盐值,密码秘钥 前端不可改*/ /** 盐值,密码秘钥 前端不可改*/
@ApiModelProperty(value = "盐值,密码秘钥 前端不可改") @ApiModelProperty(value = "盐值,密码秘钥 前端不可改")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String salt; private String salt;
/** 登录密码强度 前端不可改 */ /** 登录密码强度 前端不可改 */
@ApiModelProperty(value = "登录密码强度 前端不可改") @ApiModelProperty(value = "登录密码强度 前端不可改")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMin(1) @ValidatorLenMin(1)
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String passwordLevel; private String passwordLevel;
} }

@ -19,9 +19,9 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import java.io.Serializable; import java.io.Serializable;
@ -38,8 +38,8 @@ public class UserRoleRefModel implements Serializable {
/** 用户ID */ /** 用户ID */
@ApiModelProperty(value = "用户ID") @ApiModelProperty(value = "用户ID")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String userId; private String userId;
/** 角色数组 */ /** 角色数组 */

@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -42,24 +42,24 @@ public class Test3Model extends ApiWrapper {
@ApiModelProperty(value = "金钱") @ApiModelProperty(value = "金钱")
@ExcelProperty(value = "金钱", order = 1) @ExcelProperty(value = "金钱", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_MONEY}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_MONEY})
@ValidationArgsLenMax(10) @ValidatorLenMax(10)
private Double money; private Double money;
/** 年龄 */ /** 年龄 */
@ApiModelProperty(value = "年龄") @ApiModelProperty(value = "年龄")
@ExcelProperty(value = "年龄", order = 2) @ExcelProperty(value = "年龄", order = 2)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_INTEGER}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_INTEGER})
@ValidationArgsLenMax(3) @ValidatorLenMax(3)
private Integer age; private Integer age;
/** 名称 */ /** 名称 */
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
@ExcelProperty(value = "名称", order = 3) @ExcelProperty(value = "名称", order = 3)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_CHINESE}) @Validator({ValidatorType.IS_CHINESE})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String name; private String name;
/** 生日 */ /** 生日 */
@ -74,7 +74,7 @@ public class Test3Model extends ApiWrapper {
@ApiModelProperty(value = "是否启用") @ApiModelProperty(value = "是否启用")
@ExcelProperty(value = "是否启用", order = 5) @ExcelProperty(value = "是否启用", order = 5)
@ExcelInfo( dictType = "no_yes" ) @ExcelInfo( dictType = "no_yes" )
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izUsable; private String izUsable;

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.common.annotation.validation; package org.opsli.common.annotation.validator;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import java.lang.annotation.*; import java.lang.annotation.*;
@ -28,8 +28,8 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Documented @Documented
public @interface ValidationArgs { public @interface Validator {
ValiArgsType[] value(); ValidatorType[] value();
} }

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.common.annotation.validation; package org.opsli.common.annotation.validator;
import java.lang.annotation.*; import java.lang.annotation.*;
@ -28,7 +28,7 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Documented @Documented
public @interface ValidationArgsLenMax { public @interface ValidatorLenMax {
int value(); int value();

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.common.annotation.validation; package org.opsli.common.annotation.validator;
import java.lang.annotation.*; import java.lang.annotation.*;
@ -28,7 +28,7 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Documented @Documented
public @interface ValidationArgsLenMin { public @interface ValidatorLenMin {
int value(); int value();

@ -39,7 +39,7 @@ public interface OrderConstants {
int HOT_DATA_ORDER = 180; int HOT_DATA_ORDER = 180;
/** 参数非法验证顺序 */ /** 参数非法验证顺序 */
int PARAM_VALIDATE_AOP_SORT = 185; int VERIFY_ARGS_AOP_SORT = 185;
/** 搜索历史 */ /** 搜索历史 */
int SEARCH_HIS_AOP_SORT = 186; int SEARCH_HIS_AOP_SORT = 186;

@ -22,7 +22,7 @@ package org.opsli.common.enums;
* @author Parker * @author Parker
* @date 2020-09-17 23:40 * @date 2020-09-17 23:40
*/ */
public enum ValiArgsType { public enum ValidatorType {
/** 不能为空 */ /** 不能为空 */
IS_NOT_NULL, IS_NOT_NULL,

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.msg; package org.opsli.common.msg;
import org.opsli.common.base.msg.BaseMsg; import org.opsli.common.base.msg.BaseMsg;
@ -23,7 +23,7 @@ import org.opsli.common.base.msg.BaseMsg;
* @author Parker * @author Parker
* @date 2020-09-13 19:36 * @date 2020-09-13 19:36
*/ */
public enum ValidationMsg implements BaseMsg { public enum ValidatorMsg implements BaseMsg {
/** 不能为空 */ /** 不能为空 */
EXCEPTION_IS_NOT_NULL(9800,"不能为空! "), EXCEPTION_IS_NOT_NULL(9800,"不能为空! "),
@ -84,7 +84,7 @@ public enum ValidationMsg implements BaseMsg {
private final String message; private final String message;
private String fieldName; private String fieldName;
ValidationMsg(int code, String message){ ValidatorMsg(int code, String message){
this.code = code; this.code = code;
this.message = message; this.message = message;
} }

@ -15,18 +15,17 @@
*/ */
package org.opsli.common.utils; package org.opsli.common.utils;
import org.springframework.util.StringUtils;
/** /**
* *
* *
* @author Parker * @author Parker
* @date 2020-09-19 23:21 * @date 2020-09-19 23:21
*/ */
public final class HumpUtil { public final class FieldUtil {
private final static String UNDERLINE = "_";
public final static String UNDERLINE = "_";
private HumpUtil(){}
/*** /***
@ -75,21 +74,35 @@ public final class HumpUtil {
} }
/** /**
* *
*
* @param str * @param str
* @return String * @return
*/ */
public static String captureName(String str) { public static String upperFirstLetter(String str) {
char[] cs = str.toCharArray(); if (StringUtils.hasText(str)) {
cs[0] -= 32; String firstUpper = str.substring(0, 1).toUpperCase();
return String.valueOf(cs); str = firstUpper + str.substring(1);
}
return str;
} }
public static void main(String[] args) { /**
String aa = HumpUtil.humpToUnderline("tenantId"); *
String bb = HumpUtil.underlineToHump(aa); *
System.out.println(aa); * @param str
System.out.println(bb); * @return
*/
public static String lowerFirstLetter(String str) {
if (StringUtils.hasText(str)) {
String firstLower = str.substring(0, 1).toLowerCase();
str = firstLower + str.substring(1);
} }
return str;
}
// ====================
private FieldUtil(){}
} }

@ -129,8 +129,9 @@ public class ShiroConfig {
List<Realm> realms = Lists.newArrayList(); List<Realm> realms = Lists.newArrayList();
// 拿到state包下 实现了 FlagRealm 接口的,所有子类 // 拿到state包下 实现了 FlagRealm 接口的,所有子类
Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(FlagRealm.class.getPackage().getName() Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(
, FlagRealm.class FlagRealm.class.getPackage().getName(),
FlagRealm.class
); );
for (Class<?> aClass : clazzSet) { for (Class<?> aClass : clazzSet) {
// 位运算 去除抽象类 // 位运算 去除抽象类

@ -71,8 +71,9 @@ public class RedisPushSubReceiver extends BaseReceiver {
public void initRedisPushSubHandler(){ public void initRedisPushSubHandler(){
// 拿到state包下 实现了 SystemEventState 接口的,所有子类 // 拿到state包下 实现了 SystemEventState 接口的,所有子类
Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(RedisPushSubHandler.class.getPackage().getName() Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(
, RedisPushSubHandler.class RedisPushSubHandler.class.getPackage().getName(),
RedisPushSubHandler.class
); );
for (Class<?> aClass : clazzSet) { for (Class<?> aClass : clazzSet) {

@ -21,7 +21,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.core.utils.ValidationUtil; import org.opsli.core.utils.ValidatorUtil;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -31,7 +31,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import static org.opsli.common.constants.OrderConstants.PARAM_VALIDATE_AOP_SORT; import static org.opsli.common.constants.OrderConstants.VERIFY_ARGS_AOP_SORT;
/** /**
* *
@ -40,10 +40,10 @@ import static org.opsli.common.constants.OrderConstants.PARAM_VALIDATE_AOP_SORT;
* @date 2020-09-16 * @date 2020-09-16
*/ */
@Slf4j @Slf4j
@Order(PARAM_VALIDATE_AOP_SORT) @Order(VERIFY_ARGS_AOP_SORT)
@Aspect @Aspect
@Component @Component
public class ValitaionArgsAop { public class ValidatorAop {
/** post请求 */ /** post请求 */
private static final String POST_TYPE = "POST"; private static final String POST_TYPE = "POST";
@ -76,7 +76,7 @@ public class ValitaionArgsAop {
ApiWrapper apiWrapper = (ApiWrapper) arg; ApiWrapper apiWrapper = (ApiWrapper) arg;
// 如果是内部调用 则不判断参数非法情况 // 如果是内部调用 则不判断参数非法情况
if(apiWrapper.getIzApi() != null && !apiWrapper.getIzApi()){ if(apiWrapper.getIzApi() != null && !apiWrapper.getIzApi()){
ValidationUtil.verify(arg); ValidatorUtil.verify(arg);
} }
} }
} }

@ -19,7 +19,7 @@ import cn.hutool.core.util.ReflectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.core.base.entity.BaseEntity; import org.opsli.core.base.entity.BaseEntity;
import org.opsli.core.persistence.querybuilder.conf.WebQueryConf; import org.opsli.core.persistence.querybuilder.conf.WebQueryConf;
@ -173,7 +173,7 @@ public class WebQueryBuilder<T extends BaseEntity> implements QueryBuilder<T>{
key = keyStr; key = keyStr;
}else{ }else{
// 转换驼峰 为 数据库下划线字段 // 转换驼峰 为 数据库下划线字段
key = HumpUtil.humpToUnderline(key); key = FieldUtil.humpToUnderline(key);
} }
queryWrapper.orderByDesc(key); queryWrapper.orderByDesc(key);
@ -205,7 +205,7 @@ public class WebQueryBuilder<T extends BaseEntity> implements QueryBuilder<T>{
key = keyStr; key = keyStr;
}else{ }else{
// 转换驼峰 为 数据库下划线字段 // 转换驼峰 为 数据库下划线字段
key = HumpUtil.humpToUnderline(key); key = FieldUtil.humpToUnderline(key);
} }
switch (handle) { switch (handle) {

@ -20,7 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.api.wrapper.system.user.UserModel; import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.core.base.entity.BaseEntity; import org.opsli.core.base.entity.BaseEntity;
import org.opsli.core.utils.UserUtil; import org.opsli.core.utils.UserUtil;
@ -59,7 +59,7 @@ public class TenantHandler implements QueryBuilderChain{
if(!UserUtil.SUPER_ADMIN.equals(user.getUsername()) && if(!UserUtil.SUPER_ADMIN.equals(user.getUsername()) &&
StringUtils.isNotEmpty(tenantId) StringUtils.isNotEmpty(tenantId)
){ ){
wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT), tenantId); wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT), tenantId);
} }
} }

@ -16,19 +16,17 @@
package org.opsli.core.utils; package org.opsli.core.utils;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.common.utils.DefPatternPool; import org.opsli.common.utils.DefPatternPool;
import org.opsli.core.msg.ValidationMsg; import org.opsli.common.msg.ValidatorMsg;
import org.opsli.api.wrapper.system.dict.DictModel; import org.opsli.api.wrapper.system.dict.DictModel;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin; import org.opsli.common.annotation.validator.ValidatorLenMin;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -41,7 +39,7 @@ import java.nio.charset.StandardCharsets;
* @date 2020-09-19 20:03 * @date 2020-09-19 20:03
*/ */
@Slf4j @Slf4j
public final class ValidationUtil { public final class ValidatorUtil {
/** /**
* *
@ -55,27 +53,27 @@ public final class ValidationUtil {
Field[] fields = ReflectUtil.getFields(obj.getClass()); Field[] fields = ReflectUtil.getFields(obj.getClass());
for (Field field : fields) { for (Field field : fields) {
// 获得 统一验证 注解 // 获得 统一验证 注解
ValidationArgs validationArgs = field.getAnnotation(ValidationArgs.class); Validator validator = field.getAnnotation(Validator.class);
if (validationArgs != null) { if (validator != null) {
ValiArgsType[] types = validationArgs.value(); org.opsli.common.enums.ValidatorType[] types = validator.value();
Object fieldValue = ReflectUtil.getFieldValue(obj, field); Object fieldValue = ReflectUtil.getFieldValue(obj, field);
ValidationUtil.check(field, types, fieldValue); ValidatorUtil.check(field, types, fieldValue);
} }
// 获得 最大长度 注解 // 获得 最大长度 注解
ValidationArgsLenMax validationArgsMax = field.getAnnotation(ValidationArgsLenMax.class); ValidatorLenMax validationArgsMax = field.getAnnotation(ValidatorLenMax.class);
if (validationArgsMax != null) { if (validationArgsMax != null) {
int maxLength = validationArgsMax.value(); int maxLength = validationArgsMax.value();
Object fieldValue = ReflectUtil.getFieldValue(obj, field); Object fieldValue = ReflectUtil.getFieldValue(obj, field);
ValidationUtil.checkMax(field, maxLength, fieldValue); ValidatorUtil.checkMax(field, maxLength, fieldValue);
} }
// 获得 最小长度 注解 // 获得 最小长度 注解
ValidationArgsLenMin validationArgsMin = field.getAnnotation(ValidationArgsLenMin.class); ValidatorLenMin validationArgsMin = field.getAnnotation(ValidatorLenMin.class);
if (validationArgsMin != null) { if (validationArgsMin != null) {
int minLength = validationArgsMin.value(); int minLength = validationArgsMin.value();
Object fieldValue = ReflectUtil.getFieldValue(obj, field); Object fieldValue = ReflectUtil.getFieldValue(obj, field);
ValidationUtil.checkMin(field, minLength, fieldValue); ValidatorUtil.checkMin(field, minLength, fieldValue);
} }
} }
} }
@ -86,7 +84,7 @@ public final class ValidationUtil {
* @param types * @param types
* @param fieldValue * @param fieldValue
*/ */
private static void check(Field field, ValiArgsType[] types, Object fieldValue){ private static void check(Field field, org.opsli.common.enums.ValidatorType[] types, Object fieldValue){
// 获得字段名 // 获得字段名
String fieldName = field.getName(); String fieldName = field.getName();
ApiModelProperty annotation = field.getAnnotation(ApiModelProperty.class); ApiModelProperty annotation = field.getAnnotation(ApiModelProperty.class);
@ -97,15 +95,15 @@ public final class ValidationUtil {
String value = Convert.toStr(fieldValue); String value = Convert.toStr(fieldValue);
// 循环验证 // 循环验证
for (ValiArgsType type : types) { for (org.opsli.common.enums.ValidatorType type : types) {
try { try {
boolean validateRet; boolean verifyRet;
switch (type) { switch (type) {
// 不能为空 // 不能为空
case IS_NOT_NULL: { case IS_NOT_NULL: {
validateRet = Validator.isNotEmpty(fieldValue); verifyRet = cn.hutool.core.lang.Validator.isNotEmpty(fieldValue);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_NOT_NULL; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_NOT_NULL;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -116,9 +114,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isGeneral(value); verifyRet = cn.hutool.core.lang.Validator.isGeneral(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_GENERAL; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_GENERAL;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -129,9 +127,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = NumberUtil.isInteger(value); verifyRet = NumberUtil.isInteger(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_INTEGER; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_INTEGER;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -142,9 +140,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = NumberUtil.isDouble(value); verifyRet = NumberUtil.isDouble(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_DECIMAL; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_DECIMAL;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -156,10 +154,10 @@ public final class ValidationUtil {
break; break;
} }
// 先验证 是否是 整数, 再验证是否是 质数 // 先验证 是否是 整数, 再验证是否是 质数
validateRet = NumberUtil.isInteger(value) && verifyRet = NumberUtil.isInteger(value) &&
NumberUtil.isPrimes(Convert.toInt(value)); NumberUtil.isPrimes(Convert.toInt(value));
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_PRIMES; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_PRIMES;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -170,9 +168,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isLetter(value); verifyRet = cn.hutool.core.lang.Validator.isLetter(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_LETTER; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_LETTER;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -183,9 +181,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isUpperCase(value); verifyRet = cn.hutool.core.lang.Validator.isUpperCase(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_UPPER_CASE; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_UPPER_CASE;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -196,9 +194,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isLowerCase(value); verifyRet = cn.hutool.core.lang.Validator.isLowerCase(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_LOWER_CASE; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_LOWER_CASE;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -209,9 +207,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isIpv4(value) || Validator.isIpv6(value) ; verifyRet = cn.hutool.core.lang.Validator.isIpv4(value) || cn.hutool.core.lang.Validator.isIpv6(value) ;
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_IP; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_IP;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -222,9 +220,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isIpv4(value); verifyRet = cn.hutool.core.lang.Validator.isIpv4(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_IPV4; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_IPV4;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -235,9 +233,9 @@ public final class ValidationUtil {
if(StringUtils.isEmpty(value)){ if(StringUtils.isEmpty(value)){
break; break;
} }
validateRet = Validator.isIpv6(value); verifyRet = cn.hutool.core.lang.Validator.isIpv6(value);
if(!validateRet){ if(!verifyRet){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_IPV6; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_IPV6;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -248,9 +246,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isMoney(value); verifyRet = cn.hutool.core.lang.Validator.isMoney(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MONEY; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MONEY;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -261,9 +259,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isEmail(value); verifyRet = cn.hutool.core.lang.Validator.isEmail(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_EMAIL; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_EMAIL;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -274,9 +272,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isMobile(value); verifyRet = cn.hutool.core.lang.Validator.isMobile(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MOBILE; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MOBILE;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -287,9 +285,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isCitizenId(value); verifyRet = cn.hutool.core.lang.Validator.isCitizenId(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_CITIZENID; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_CITIZENID;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -300,9 +298,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isZipCode(value); verifyRet = cn.hutool.core.lang.Validator.isZipCode(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_ZIPCODE; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_ZIPCODE;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -313,9 +311,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isUrl(value); verifyRet = cn.hutool.core.lang.Validator.isUrl(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_URL; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_URL;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -326,9 +324,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isChinese(value); verifyRet = cn.hutool.core.lang.Validator.isChinese(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_CHINESE; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_CHINESE;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -339,9 +337,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isGeneralWithChinese(value); verifyRet = cn.hutool.core.lang.Validator.isGeneralWithChinese(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_GENERAL_WITH_CHINESE; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_GENERAL_WITH_CHINESE;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -352,9 +350,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isMac(value); verifyRet = cn.hutool.core.lang.Validator.isMac(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MAC; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MAC;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -365,9 +363,9 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isPlateNumber(value); verifyRet = cn.hutool.core.lang.Validator.isPlateNumber(value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_PLATE_NUMBER; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_PLATE_NUMBER;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -378,10 +376,10 @@ public final class ValidationUtil {
if (StringUtils.isEmpty(value)) { if (StringUtils.isEmpty(value)) {
break; break;
} }
validateRet = Validator.isMatchRegex( verifyRet = cn.hutool.core.lang.Validator.isMatchRegex(
DefPatternPool.SECURITY_PASSWORD, value); DefPatternPool.SECURITY_PASSWORD, value);
if (!validateRet) { if (!verifyRet) {
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_SECURITY_PASSWORD; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_SECURITY_PASSWORD;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -420,7 +418,7 @@ public final class ValidationUtil {
// 转换为 数据库真实 长度 // 转换为 数据库真实 长度
int strLength = value.getBytes(StandardCharsets.UTF_8).length; int strLength = value.getBytes(StandardCharsets.UTF_8).length;
if(strLength > maxLength){ if(strLength > maxLength){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MAX; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MAX;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -453,7 +451,7 @@ public final class ValidationUtil {
// 转换为 数据库真实 长度 // 转换为 数据库真实 长度
int strLength = value.getBytes(StandardCharsets.UTF_8).length; int strLength = value.getBytes(StandardCharsets.UTF_8).length;
if(strLength < minLength){ if(strLength < minLength){
ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MIN; ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MIN;
msg.setFieldName(fieldName); msg.setFieldName(fieldName);
throw new ServiceException(msg); throw new ServiceException(msg);
} }
@ -472,12 +470,12 @@ public final class ValidationUtil {
dictModel.setRemark("测试11232131231231223123"); dictModel.setRemark("测试11232131231231223123");
dictModel.setIzLock("1"); dictModel.setIzLock("1");
ValidationUtil.verify(dictModel); ValidatorUtil.verify(dictModel);
} }
// ================ // ================
private ValidationUtil(){} private ValidatorUtil(){}
} }

@ -6,7 +6,7 @@ import cn.hutool.extra.mail.MailUtil;
import org.opsli.api.wrapper.system.options.OptionsModel; import org.opsli.api.wrapper.system.options.OptionsModel;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.core.utils.OptionsUtil; import org.opsli.core.utils.OptionsUtil;
import org.opsli.core.utils.ValidationUtil; import org.opsli.core.utils.ValidatorUtil;
import org.opsli.plugins.email.enums.EmailType; import org.opsli.plugins.email.enums.EmailType;
import org.opsli.plugins.email.service.IEmailService; import org.opsli.plugins.email.service.IEmailService;
import org.opsli.plugins.email.wrapper.EmailModel; import org.opsli.plugins.email.wrapper.EmailModel;
@ -52,7 +52,7 @@ public class EmailServiceImpl implements IEmailService {
emailModel.setTo(to); emailModel.setTo(to);
emailModel.setSubject(subject); emailModel.setSubject(subject);
emailModel.setContent(content); emailModel.setContent(content);
ValidationUtil.verify(emailModel); ValidatorUtil.verify(emailModel);
} }
// 获得配置信息 // 获得配置信息

@ -3,9 +3,9 @@ package org.opsli.plugins.email.wrapper;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
/** /**
* *
@ -20,19 +20,19 @@ public class EmailModel {
/** 收件人 */ /** 收件人 */
@ApiModelProperty(value = "收件人") @ApiModelProperty(value = "收件人")
@ValidationArgs({ValiArgsType.IS_EMAIL, ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_EMAIL, ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String to; private String to;
/** 主题 */ /** 主题 */
@ApiModelProperty(value = "主题") @ApiModelProperty(value = "主题")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String subject; private String subject;
/** 内容 */ /** 内容 */
@ApiModelProperty(value = "内容") @ApiModelProperty(value = "内容")
@ValidationArgsLenMax(20000) @ValidatorLenMax(20000)
private String content; private String content;

@ -83,7 +83,7 @@ public enum OssStorageFactory {
// 拿到实现了 OssStorageService 接口的,所有子类 // 拿到实现了 OssStorageService 接口的,所有子类
Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper( Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(
OssStorageService.class.getPackage().getName()+".impl", OssStorageService.class.getPackage().getName(),
OssStorageService.class OssStorageService.class
); );

@ -18,9 +18,9 @@ package org.opsli.plugins.oss.factory;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.opsli.common.annotation.OptionDict; import org.opsli.common.annotation.OptionDict;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.core.utils.OptionsUtil; import org.opsli.core.utils.OptionsUtil;
import java.io.Serializable; import java.io.Serializable;
@ -64,14 +64,14 @@ public enum LocalConfigFactory implements ConfigFactory<LocalConfigFactory.Local
/** 域名 */ /** 域名 */
@ApiModelProperty(value = "域名") @ApiModelProperty(value = "域名")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
@OptionDict("storage_local_domain") @OptionDict("storage_local_domain")
private String domain; private String domain;
/** 前缀 */ /** 前缀 */
@ApiModelProperty(value = "前缀") @ApiModelProperty(value = "前缀")
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
@OptionDict("storage_local_path_prefix") @OptionDict("storage_local_path_prefix")
private String pathPrefix; private String pathPrefix;

@ -22,7 +22,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.core.autoconfigure.properties.GlobalProperties; import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.utils.GlobalPropertiesUtil; import org.opsli.core.utils.GlobalPropertiesUtil;
import org.opsli.core.utils.ValidationUtil; import org.opsli.core.utils.ValidatorUtil;
import org.opsli.plugins.oss.enums.OssStorageType; import org.opsli.plugins.oss.enums.OssStorageType;
import org.opsli.plugins.oss.factory.LocalConfigFactory; import org.opsli.plugins.oss.factory.LocalConfigFactory;
import org.opsli.plugins.oss.service.BaseOssStorageService; import org.opsli.plugins.oss.service.BaseOssStorageService;
@ -70,7 +70,7 @@ public class LocalStorageServiceImpl extends BaseOssStorageService {
LocalConfigFactory.LocalConfig config = LocalConfigFactory.INSTANCE.getConfig(); LocalConfigFactory.LocalConfig config = LocalConfigFactory.INSTANCE.getConfig();
// 验证对象 // 验证对象
ValidationUtil.verify(config); ValidatorUtil.verify(config);
// 当前时间戳 // 当前时间戳
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
@ -128,7 +128,7 @@ public class LocalStorageServiceImpl extends BaseOssStorageService {
// 获得配置信息 // 获得配置信息
LocalConfigFactory.LocalConfig config = LocalConfigFactory.INSTANCE.getConfig(); LocalConfigFactory.LocalConfig config = LocalConfigFactory.INSTANCE.getConfig();
// 验证对象 // 验证对象
ValidationUtil.verify(config); ValidatorUtil.verify(config);
// 当前时间戳 // 当前时间戳
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();

@ -12,6 +12,18 @@
<artifactId>opsli-modulars-generator</artifactId> <artifactId>opsli-modulars-generator</artifactId>
<dependencies> <dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.3</version>
</dependency>
<dependency> <dependency>
<groupId>com.jfinal</groupId> <groupId>com.jfinal</groupId>
<artifactId>enjoy</artifactId> <artifactId>enjoy</artifactId>

@ -1,69 +0,0 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.core.generator.strategy.sync.mysql.enums;
import org.opsli.core.generator.strategy.sync.mysql.entity.FieldTypeAttribute;
import java.util.HashMap;
import java.util.Map;
/**
* MySQL
*
* @author parker
* @date 2020-11-18 13:21
*/
public enum MySQLSyncColumnType {
/** 实例对象 */
INSTANCE;
private static final Map<String, FieldTypeAttribute> FIELD_TYPE_MAP = new HashMap<>();
static {
FIELD_TYPE_MAP.put("tinyint", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("smallint", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("mediumint", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("int", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("integer", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("bigint", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("real", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("float", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("double", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("decimal", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("numeric", new FieldTypeAttribute(true, true));
FIELD_TYPE_MAP.put("char", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("varchar", new FieldTypeAttribute(true, false));
FIELD_TYPE_MAP.put("date", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("time", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("timestamp", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("datetime", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("blob", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("mediumblob", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("longblob", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("tinytext", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("text", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("mediumtext", new FieldTypeAttribute(false, false));
FIELD_TYPE_MAP.put("longtext", new FieldTypeAttribute(false, false));
}
public FieldTypeAttribute getAttr(String fieldType){
return FIELD_TYPE_MAP.get(fieldType);
}
}

@ -19,11 +19,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.generator.exception.GeneratorException; import org.opsli.plugins.generator.exception.GeneratorException;
import org.opsli.core.generator.msg.GeneratorMsg; import org.opsli.plugins.generator.msg.GeneratorMsg;
import org.opsli.core.persistence.querybuilder.GenQueryBuilder; import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
import org.opsli.core.persistence.querybuilder.QueryBuilder; import org.opsli.core.persistence.querybuilder.QueryBuilder;
import org.opsli.core.utils.ValidationUtil; import org.opsli.core.utils.ValidatorUtil;
import org.opsli.modulars.generator.column.entity.GenTableColumn; import org.opsli.modulars.generator.column.entity.GenTableColumn;
import org.opsli.modulars.generator.column.mapper.GenTableColumnMapper; import org.opsli.modulars.generator.column.mapper.GenTableColumnMapper;
import org.opsli.modulars.generator.column.service.IGenTableColumnService; import org.opsli.modulars.generator.column.service.IGenTableColumnService;
@ -52,7 +52,7 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl<GenTableColumnMap
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public GenTableColumnModel insert(GenTableColumnModel model) { public GenTableColumnModel insert(GenTableColumnModel model) {
// 验证对象 // 验证对象
ValidationUtil.verify(model); ValidatorUtil.verify(model);
if(model == null){ if(model == null){
return null; return null;
@ -84,7 +84,7 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl<GenTableColumnMap
for (GenTableColumnModel model : models) { for (GenTableColumnModel model : models) {
// 验证对象合法性 // 验证对象合法性
ValidationUtil.verify(model); ValidatorUtil.verify(model);
// 唯一验证 // 唯一验证
Integer count = this.uniqueVerificationByFieldName(model); Integer count = this.uniqueVerificationByFieldName(model);
@ -113,7 +113,7 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl<GenTableColumnMap
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public GenTableColumnModel update(GenTableColumnModel model) { public GenTableColumnModel update(GenTableColumnModel model) {
// 验证对象 // 验证对象
ValidationUtil.verify(model); ValidatorUtil.verify(model);
if(model == null){ if(model == null){
return null; return null;

@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import java.util.List; import java.util.List;
@ -45,15 +45,15 @@ public class GenTableColumnModel extends ApiWrapper {
/** 字段名称 */ /** 字段名称 */
@ApiModelProperty(value = "字段名称") @ApiModelProperty(value = "字段名称")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String fieldName; private String fieldName;
/** 字段类型 */ /** 字段类型 */
@ApiModelProperty(value = "字段类型") @ApiModelProperty(value = "字段类型")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String fieldType; private String fieldType;
/** 字段长度 */ /** 字段长度 */
@ -69,72 +69,72 @@ public class GenTableColumnModel extends ApiWrapper {
/** 字段描述 */ /** 字段描述 */
@ApiModelProperty(value = "字段描述") @ApiModelProperty(value = "字段描述")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String fieldComments; private String fieldComments;
/** 是否主键 */ /** 是否主键 */
@ApiModelProperty(value = "是否主键") @ApiModelProperty(value = "是否主键")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izPk; private String izPk;
/** 是否可为空 */ /** 是否可为空 */
@ApiModelProperty(value = "是否可为空") @ApiModelProperty(value = "是否可为空")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izNotNull; private String izNotNull;
/** 是否列表显示 */ /** 是否列表显示 */
@ApiModelProperty(value = "是否列表显示") @ApiModelProperty(value = "是否列表显示")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izShowList; private String izShowList;
/** 是否表单显示 */ /** 是否表单显示 */
@ApiModelProperty(value = "是否表单显示") @ApiModelProperty(value = "是否表单显示")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izShowForm; private String izShowForm;
/** Java字段类型 */ /** Java字段类型 */
@ApiModelProperty(value = "Java字段类型") @ApiModelProperty(value = "Java字段类型")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String javaType; private String javaType;
/** 字段生成方案(文本框、文本域、字典选择) */ /** 字段生成方案(文本框、文本域、字典选择) */
@ApiModelProperty(value = "字段生成方案") @ApiModelProperty(value = "字段生成方案")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String showType; private String showType;
/** 字典类型编号 */ /** 字典类型编号 */
@ApiModelProperty(value = "字典类型编号") @ApiModelProperty(value = "字典类型编号")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String dictTypeCode; private String dictTypeCode;
/** 排序(升序) */ /** 排序(升序) */
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(6) @ValidatorLenMax(6)
private Integer sort; private Integer sort;
/** 验证类别 */ /** 验证类别 */
@ApiModelProperty(value = "验证类别") @ApiModelProperty(value = "验证类别")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(500) @ValidatorLenMax(500)
private String validateType; private String validateType;
/** 检索类别 */ /** 检索类别 */
@ApiModelProperty(value = "检索类别") @ApiModelProperty(value = "检索类别")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String queryType; private String queryType;
// ======================= // =======================
@ -144,24 +144,14 @@ public class GenTableColumnModel extends ApiWrapper {
@ExcelIgnore @ExcelIgnore
private String fieldHumpName; private String fieldHumpName;
/** 后端验证 */ /** 验证集合 */
@JsonIgnore @JsonIgnore
@ExcelIgnore @ExcelIgnore
private String backendValidateType; private List<String> validateTypeList;
/** 后端验证集合 */ /** 验证集合(含逗号) */
@JsonIgnore @JsonIgnore
@ExcelIgnore @ExcelIgnore
private List<String> backendValidateTypeList; private List<String> validateTypeAndCommaList;
/** 前端验证集合 */
@JsonIgnore
@ExcelIgnore
private String frontendValidateType;
/** 前端验证集合 */
@JsonIgnore
@ExcelIgnore
private List<String> frontendValidateTypeList;
} }

@ -16,13 +16,15 @@
package org.opsli.modulars.generator.importable; package org.opsli.modulars.generator.importable;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ClassUtil; import cn.hutool.core.util.ClassUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.core.autoconfigure.properties.DbSourceProperties; import org.opsli.core.autoconfigure.properties.DbSourceProperties;
import org.opsli.core.generator.enums.DataBaseType; import org.opsli.plugins.generator.database.mysql.MySqlSyncColumnType;
import org.opsli.plugins.generator.enums.DataBaseType;
import org.opsli.core.utils.SpringContextHolder; import org.opsli.core.utils.SpringContextHolder;
import org.opsli.modulars.generator.importable.entity.DatabaseColumn; import org.opsli.modulars.generator.importable.entity.DatabaseColumn;
import org.opsli.modulars.generator.importable.entity.DatabaseTable; import org.opsli.modulars.generator.importable.entity.DatabaseTable;
@ -174,6 +176,64 @@ public class ImportTableUtil{
return databaseTableService.findColumns(dataSource.getDbName(), tableName); return databaseTableService.findColumns(dataSource.getDbName(), tableName);
} }
/**
*
* @return List
*/
public static List<String> getFieldTypes() {
DatabaseTableService databaseTableService = getDatabaseTableService();
if(databaseTableService == null){
return ListUtil.empty();
}
return databaseTableService.getFieldTypes();
}
/**
* Java
* @return List
*/
public static Map<String, String> getJavaFieldTypes() {
DatabaseTableService databaseTableService = getDatabaseTableService();
if(databaseTableService == null){
return Maps.newHashMap();
}
return databaseTableService.getJavaFieldTypes();
}
/**
* JavaString
* @return List
*/
public static Map<String, List<String>> getJavaFieldTypesBySafety() {
DatabaseTableService databaseTableService = getDatabaseTableService();
if(databaseTableService == null){
return Maps.newHashMap();
}
return databaseTableService.getJavaFieldTypesBySafety();
}
/**
* Service
* @return DatabaseTableService
*/
private static DatabaseTableService getDatabaseTableService(){
Map<String, DbSourceProperties.DataSourceInfo> dataSourceInfoMap =
dbSourceProperties.getDataSourceInfoMap();
// 非法判断
if(CollUtil.isEmpty(dataSourceInfoMap)){
return null;
}
DbSourceProperties.DataSourceInfo dataSource = dataSourceInfoMap.get(ASSIGN_DB);
if(dataSource == null){
return null;
}
// 根据类型获得查询器
DataBaseType dataBaseType = DB_TYPE_MAP.get(dataSource.getDriverClassName());
return HANDLER_MAP.get(dataBaseType);
}
// ==================================== // ====================================
@ -182,8 +242,9 @@ public class ImportTableUtil{
public void initImportTable(){ public void initImportTable(){
// 拿到state包下 实现了 SystemEventState 接口的,所有子类 // 拿到state包下 实现了 SystemEventState 接口的,所有子类
Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(DatabaseTableService.class.getPackage().getName() Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(
, DatabaseTableService.class DatabaseTableService.class.getPackage().getName(),
DatabaseTableService.class
); );
for (Class<?> aClass : clazzSet) { for (Class<?> aClass : clazzSet) {
@ -199,7 +260,7 @@ public class ImportTableUtil{
} }
@Autowired @Autowired
public void setDbSourceProperties(DbSourceProperties dbSourceProperties) { public void init(DbSourceProperties dbSourceProperties) {
ImportTableUtil.dbSourceProperties = dbSourceProperties; ImportTableUtil.dbSourceProperties = dbSourceProperties;
} }
} }

@ -15,11 +15,12 @@
*/ */
package org.opsli.modulars.generator.importable.service; package org.opsli.modulars.generator.importable.service;
import org.opsli.core.generator.enums.DataBaseType; import org.opsli.plugins.generator.enums.DataBaseType;
import org.opsli.modulars.generator.importable.entity.DatabaseColumn; import org.opsli.modulars.generator.importable.entity.DatabaseColumn;
import org.opsli.modulars.generator.importable.entity.DatabaseTable; import org.opsli.modulars.generator.importable.entity.DatabaseTable;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
@ -36,6 +37,25 @@ public interface DatabaseTableService {
*/ */
DataBaseType getType(); DataBaseType getType();
/**
*
* @return List
*/
List<String> getFieldTypes();
/**
* Java
* @return List
*/
Map<String, String> getJavaFieldTypes();
/**
* JavaString
* @return List
*/
Map<String, List<String>> getJavaFieldTypesBySafety();
/** /**
* *
* @param dbName * @param dbName

@ -17,7 +17,8 @@ package org.opsli.modulars.generator.importable.service;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.common.utils.Props; import org.opsli.common.utils.Props;
import org.opsli.core.generator.enums.DataBaseType; import org.opsli.plugins.generator.database.mysql.MySqlSyncColumnType;
import org.opsli.plugins.generator.enums.DataBaseType;
import org.opsli.modulars.generator.importable.entity.DatabaseColumn; import org.opsli.modulars.generator.importable.entity.DatabaseColumn;
import org.opsli.modulars.generator.importable.entity.DatabaseTable; import org.opsli.modulars.generator.importable.entity.DatabaseTable;
import org.opsli.modulars.generator.importable.mapper.MySQLDatabaseTableMapper; import org.opsli.modulars.generator.importable.mapper.MySQLDatabaseTableMapper;
@ -26,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
@ -56,6 +58,21 @@ public class MySQLDatabaseTableServiceImpl implements DatabaseTableService {
return DataBaseType.MYSQL; return DataBaseType.MYSQL;
} }
@Override
public List<String> getFieldTypes() {
return MySqlSyncColumnType.INSTANCE.getFieldTypes();
}
@Override
public Map<String, String> getJavaFieldTypes() {
return MySqlSyncColumnType.INSTANCE.getJavaFieldTypes();
}
@Override
public Map<String, List<String>> getJavaFieldTypesBySafety() {
return MySqlSyncColumnType.INSTANCE.getJavaFieldTypesBySafety();
}
@Override @Override
public List<DatabaseTable> findTables(String dbName) { public List<DatabaseTable> findTables(String dbName) {
return this.findTables(dbName, null); return this.findTables(dbName, null);

@ -23,9 +23,9 @@ import org.opsli.api.web.system.menu.MenuApi;
import org.opsli.api.wrapper.system.menu.MenuFullModel; import org.opsli.api.wrapper.system.menu.MenuFullModel;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.generator.exception.GeneratorException; import org.opsli.plugins.generator.exception.GeneratorException;
import org.opsli.core.generator.msg.GeneratorMsg; import org.opsli.plugins.generator.msg.GeneratorMsg;
import org.opsli.core.generator.strategy.create.CodeBuilder; import org.opsli.plugins.generator.strategy.create.CodeBuilder;
import org.opsli.core.persistence.Page; import org.opsli.core.persistence.Page;
import org.opsli.core.persistence.querybuilder.GenQueryBuilder; import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
import org.opsli.core.persistence.querybuilder.QueryBuilder; import org.opsli.core.persistence.querybuilder.QueryBuilder;

@ -20,9 +20,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
/** /**
* - * -
@ -38,51 +38,51 @@ public class GenLogsModel extends ApiWrapper {
/** 归属表ID */ /** 归属表ID */
@ApiModelProperty(value = "归属表ID") @ApiModelProperty(value = "归属表ID")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(19) @ValidatorLenMax(19)
private String tableId; private String tableId;
/** 包名 */ /** 包名 */
@ApiModelProperty(value = "包名") @ApiModelProperty(value = "包名")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String packageName; private String packageName;
/** 模块名 */ /** 模块名 */
@ApiModelProperty(value = "模块名") @ApiModelProperty(value = "模块名")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(40) @ValidatorLenMax(40)
private String moduleName; private String moduleName;
/** 子模块名 */ /** 子模块名 */
@ApiModelProperty(value = "子模块名") @ApiModelProperty(value = "子模块名")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(40) @ValidatorLenMax(40)
private String subModuleName; private String subModuleName;
/** 代码标题 */ /** 代码标题 */
@ApiModelProperty(value = "代码标题") @ApiModelProperty(value = "代码标题")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String codeTitle; private String codeTitle;
/** 代码标题简介 */ /** 代码标题简介 */
@ApiModelProperty(value = "代码标题简介") @ApiModelProperty(value = "代码标题简介")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String codeTitleBrief; private String codeTitleBrief;
/** 作者名 */ /** 作者名 */
@ApiModelProperty(value = "作者名") @ApiModelProperty(value = "作者名")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(64) @ValidatorLenMax(64)
private String authorName; private String authorName;
} }

@ -24,6 +24,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/** /**
* - API * - API
@ -121,4 +123,26 @@ public interface TableApi {
@PostMapping("/importTables") @PostMapping("/importTables")
ResultVo<?> importTables(String tableNames); ResultVo<?> importTables(String tableNames);
/**
*
* @return List
*/
@GetMapping("/getFieldTypes")
ResultVo<List<String>> getFieldTypes();
/**
* Java
* @return List
*/
@GetMapping("/getJavaFieldTypes")
ResultVo<Map<String, String> > getJavaFieldTypes();
/**
* JavaString
* @return List
*/
@GetMapping("/getJavaFieldTypesBySafety")
ResultVo<Map<String, List<String>>> getJavaFieldTypesBySafety();
} }

@ -23,8 +23,8 @@ import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.generator.exception.GeneratorException; import org.opsli.plugins.generator.exception.GeneratorException;
import org.opsli.core.generator.msg.GeneratorMsg; import org.opsli.plugins.generator.msg.GeneratorMsg;
import org.opsli.modulars.generator.column.service.IGenTableColumnService; import org.opsli.modulars.generator.column.service.IGenTableColumnService;
import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel;
import org.opsli.modulars.generator.logs.service.IGenLogsService; import org.opsli.modulars.generator.logs.service.IGenLogsService;

@ -26,9 +26,9 @@ import org.opsli.common.annotation.EnableLog;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.controller.BaseRestController; import org.opsli.core.base.controller.BaseRestController;
import org.opsli.core.generator.exception.GeneratorException; import org.opsli.plugins.generator.exception.GeneratorException;
import org.opsli.core.generator.msg.GeneratorMsg; import org.opsli.plugins.generator.msg.GeneratorMsg;
import org.opsli.core.generator.strategy.sync.util.SqlSyncUtil; import org.opsli.plugins.generator.SqlSyncUtil;
import org.opsli.core.msg.CoreMsg; import org.opsli.core.msg.CoreMsg;
import org.opsli.core.persistence.Page; import org.opsli.core.persistence.Page;
import org.opsli.core.persistence.querybuilder.QueryBuilder; import org.opsli.core.persistence.querybuilder.QueryBuilder;
@ -45,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
@ -254,4 +255,25 @@ public class GenTableRestController extends BaseRestController<GenTable, GenTabl
IService.importTables(tableNameArray); IService.importTables(tableNameArray);
return ResultVo.success("导入成功"); return ResultVo.success("导入成功");
} }
@ApiOperation(value = "获得数据库类型下 字段类型",
notes = "获得数据库类型下 字段类型")
@Override
public ResultVo<List<String>> getFieldTypes() {
return ResultVo.success(ImportTableUtil.getFieldTypes());
}
@ApiOperation(value = "获得数据库类型下 全部类型对应Java类型",
notes = "获得数据库类型下 全部类型对应Java类型")
@Override
public ResultVo<Map<String, String>> getJavaFieldTypes() {
return ResultVo.success(ImportTableUtil.getJavaFieldTypes());
}
@ApiOperation(value = "获得全部类型对应Java类型集合兜底String 类型)",
notes = "获得全部类型对应Java类型集合兜底String 类型)")
@Override
public ResultVo<Map<String, List<String>>> getJavaFieldTypesBySafety() {
return ResultVo.success(ImportTableUtil.getJavaFieldTypesBySafety());
}
} }

@ -21,12 +21,11 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -43,8 +42,8 @@ public class GenTableAndColumnModel extends ApiWrapper {
/** 表名称 */ /** 表名称 */
@ApiModelProperty(value = "表名称") @ApiModelProperty(value = "表名称")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String tableName; private String tableName;
/** 旧表名称 */ /** 旧表名称 */
@ -55,39 +54,39 @@ public class GenTableAndColumnModel extends ApiWrapper {
/** 表类型 */ /** 表类型 */
@ApiModelProperty(value = "表类型") @ApiModelProperty(value = "表类型")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String tableType; private String tableType;
/** 数据库类型 */ /** 数据库类型 */
@ApiModelProperty(value = "数据库类型") @ApiModelProperty(value = "数据库类型")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(30) @ValidatorLenMax(30)
private String jdbcType; private String jdbcType;
/** 描述 */ /** 描述 */
@ApiModelProperty(value = "描述") @ApiModelProperty(value = "描述")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String comments; private String comments;
/** 同步 */ /** 同步 */
@ApiModelProperty(value = "同步") @ApiModelProperty(value = "同步")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izSync; private String izSync;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelIgnore @ExcelIgnore
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;
/** 表结构 */ /** 表结构 */
@ApiModelProperty(value = "表结构") @ApiModelProperty(value = "表结构")
@ExcelIgnore @ExcelIgnore
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
private List<GenTableColumnModel> columnList; private List<GenTableColumnModel> columnList;
// ======================= // =======================
@ -97,6 +96,11 @@ public class GenTableAndColumnModel extends ApiWrapper {
@ExcelIgnore @ExcelIgnore
private String tableHumpName; private String tableHumpName;
/** Entity 包地址 */
@JsonIgnore
@ExcelIgnore
private List<String> entityPkgList;
/** 前端Form集合 */ /** 前端Form集合 */
@JsonIgnore @JsonIgnore
@ExcelIgnore @ExcelIgnore
@ -112,9 +116,4 @@ public class GenTableAndColumnModel extends ApiWrapper {
@ExcelIgnore @ExcelIgnore
private List<GenTableColumnModel> moreQueryList; private List<GenTableColumnModel> moreQueryList;
/** 前端验证集合 */
@JsonIgnore
@ExcelIgnore
private String frontendValidateType;
} }

@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.warpper.ApiWrapper; import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
/** /**
@ -41,8 +41,8 @@ public class GenTableModel extends ApiWrapper {
@ApiModelProperty(value = "表名称") @ApiModelProperty(value = "表名称")
@ExcelProperty(value = "表名称", order = 1) @ExcelProperty(value = "表名称", order = 1)
@ExcelInfo @ExcelInfo
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(100) @ValidatorLenMax(100)
private String tableName; private String tableName;
/** 旧表名称 */ /** 旧表名称 */
@ -54,37 +54,37 @@ public class GenTableModel extends ApiWrapper {
@ApiModelProperty(value = "表类型") @ApiModelProperty(value = "表类型")
@ExcelProperty(value = "表类型", order = 2) @ExcelProperty(value = "表类型", order = 2)
@ExcelInfo(dictType = "table_type") @ExcelInfo(dictType = "table_type")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String tableType; private String tableType;
/** 数据库类型 */ /** 数据库类型 */
@ApiModelProperty(value = "数据库类型") @ApiModelProperty(value = "数据库类型")
@ExcelProperty(value = "数据库类型", order = 3) @ExcelProperty(value = "数据库类型", order = 3)
@ExcelInfo(dictType = "jdbc_type") @ExcelInfo(dictType = "jdbc_type")
@ValidationArgs({ValiArgsType.IS_NOT_NULL}) @Validator({ValidatorType.IS_NOT_NULL})
@ValidationArgsLenMax(30) @ValidatorLenMax(30)
private String jdbcType; private String jdbcType;
/** 描述 */ /** 描述 */
@ApiModelProperty(value = "描述") @ApiModelProperty(value = "描述")
@ExcelProperty(value = "描述", order = 4) @ExcelProperty(value = "描述", order = 4)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(200) @ValidatorLenMax(200)
private String comments; private String comments;
/** 同步 */ /** 同步 */
@ApiModelProperty(value = "同步") @ApiModelProperty(value = "同步")
@ExcelProperty(value = "是否同步", order = 5) @ExcelProperty(value = "是否同步", order = 5)
@ExcelInfo(dictType = "no_yes") @ExcelInfo(dictType = "no_yes")
@ValidationArgsLenMax(1) @ValidatorLenMax(1)
private String izSync; private String izSync;
/** 备注 */ /** 备注 */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
@ExcelProperty(value = "备注", order = 6) @ExcelProperty(value = "备注", order = 6)
@ExcelInfo @ExcelInfo
@ValidationArgsLenMax(255) @ValidatorLenMax(255)
private String remark; private String remark;

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.strategy.sync.mysql.entity; package org.opsli.plugins.generator;
import lombok.Data; import lombok.Data;

@ -13,12 +13,12 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.strategy.sync.util; package org.opsli.plugins.generator;
import cn.hutool.core.util.ClassUtil; import cn.hutool.core.util.ClassUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.opsli.core.generator.enums.DataBaseType; import org.opsli.plugins.generator.enums.DataBaseType;
import org.opsli.core.generator.strategy.sync.SyncStrategy; import org.opsli.plugins.generator.SyncStrategy;
import org.opsli.core.utils.SpringContextHolder; import org.opsli.core.utils.SpringContextHolder;
import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel; import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -48,8 +48,9 @@ public class SqlSyncUtil {
public void initSyncStrategy(){ public void initSyncStrategy(){
// 拿到state包下 实现了 SystemEventState 接口的,所有子类 // 拿到state包下 实现了 SystemEventState 接口的,所有子类
Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(SyncStrategy.class.getPackage().getName() Set<Class<?>> clazzSet = ClassUtil.scanPackageBySuper(
, SyncStrategy.class SyncStrategy.class.getPackage().getName(),
SyncStrategy.class
); );
for (Class<?> aClass : clazzSet) { for (Class<?> aClass : clazzSet) {

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.strategy.sync; package org.opsli.plugins.generator;
import org.opsli.core.generator.enums.DataBaseType; import org.opsli.plugins.generator.enums.DataBaseType;
import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel; import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel;
/** /**

@ -0,0 +1,177 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator;
import cn.hutool.core.collection.CollUtil;
import org.apache.commons.lang3.StringUtils;
import org.opsli.plugins.generator.enums.TypeEnum;
import java.util.List;
/**
*
*
* @author Parker
* @date 202152614:45:15
*/
public interface TypeFormatter {
/**
*
* @param columnType
* @return String
*/
default TypeEnum format(String columnType) {
if (isBit(columnType)) {
return TypeEnum.BIT;
}
if (isBoolean(columnType)) {
return TypeEnum.BOOLEAN;
}
if (isTinyint(columnType)) {
return TypeEnum.TINYINT;
}
if (isSmallint(columnType)) {
return TypeEnum.SMALLINT;
}
if (isInt(columnType)) {
return TypeEnum.INT;
}
if (isLong(columnType)) {
return TypeEnum.BIGINT;
}
if (isFloat(columnType)) {
return TypeEnum.FLOAT;
}
if (isDouble(columnType)) {
return TypeEnum.DOUBLE;
}
if (isDecimal(columnType)) {
return TypeEnum.DECIMAL;
}
if(isJsonb(columnType)){
return TypeEnum.JSONB;
}
if (isVarchar(columnType)) {
return TypeEnum.VARCHAR;
}
if (isDatetime(columnType)) {
return TypeEnum.DATETIME;
}
if (isBlob(columnType)) {
return TypeEnum.BLOB;
}
return TypeEnum.VARCHAR;
}
/**
*
* @param columnTypes
* @param type
* @return boolean
*/
default boolean isContains(List<String> columnTypes, String type) {
if(CollUtil.isEmpty(columnTypes)){
return false;
}
for (String columnType : columnTypes) {
if(StringUtils.equalsIgnoreCase(columnType, type)){
return true;
}
}
return false;
}
/**
*
* @param columnType
* @return boolean
*/
boolean isBit(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isBoolean(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isTinyint(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isSmallint(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isInt(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isLong(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isFloat(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isDouble(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isDecimal(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isVarchar(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isDatetime(String columnType);
/**
*
* @param columnType
* @return boolean
*/
boolean isBlob(String columnType);
/**
* JSON
* @param columnType
* @return boolean
*/
boolean isJsonb(String columnType);
}

@ -0,0 +1,44 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.converter;
import org.opsli.plugins.generator.enums.TypeEnum;
import java.util.List;
/**
*
*
* @author Parker
* @date 202152614:22:31
*/
public interface ColumnTypeConverter {
/**
*
* @param type
* @return
*/
String convertType(TypeEnum type);
/**
* ( String )
* @param type
* @return List
*/
List<String> convertTypeBySafety(TypeEnum type);
}

@ -0,0 +1,67 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.converter;
import com.google.common.collect.Lists;
import org.opsli.common.utils.ListDistinctUtil;
import org.opsli.plugins.generator.enums.JavaType;
import org.opsli.plugins.generator.enums.TypeEnum;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Java
*
* @author Parker
* @date 202152614:25:47
*/
public class JavaColumnTypeConverter implements ColumnTypeConverter {
private static final Map<TypeEnum, JavaType> TYPE_MAP = new HashMap<>(64);
static {
TYPE_MAP.put(TypeEnum.BIT, JavaType.BOOLEAN);
TYPE_MAP.put(TypeEnum.BOOLEAN, JavaType.BOOLEAN);
TYPE_MAP.put(TypeEnum.TINYINT, JavaType.BYTE);
TYPE_MAP.put(TypeEnum.SMALLINT, JavaType.SHORT);
TYPE_MAP.put(TypeEnum.INT, JavaType.INTEGER);
TYPE_MAP.put(TypeEnum.BIGINT, JavaType.LONG);
TYPE_MAP.put(TypeEnum.FLOAT, JavaType.FLOAT);
TYPE_MAP.put(TypeEnum.DOUBLE, JavaType.DOUBLE);
TYPE_MAP.put(TypeEnum.DECIMAL, JavaType.BIG_DECIMAL);
TYPE_MAP.put(TypeEnum.VARCHAR, JavaType.STRING);
TYPE_MAP.put(TypeEnum.DATETIME, JavaType.DATE);
TYPE_MAP.put(TypeEnum.BLOB, JavaType.BYTE_ARRAY);
TYPE_MAP.put(TypeEnum.JSONB, JavaType.MAP_OBJECT) ;
}
@Override
public String convertType(TypeEnum type) {
return TYPE_MAP.getOrDefault(type, TYPE_MAP.get(TypeEnum.VARCHAR)).getType();
}
@Override
public List<String> convertTypeBySafety(TypeEnum type) {
String currType = TYPE_MAP.getOrDefault(type, TYPE_MAP.get(TypeEnum.VARCHAR)).getType();
String defType = TYPE_MAP.get(TypeEnum.VARCHAR).getType();
List<String> typeList = Lists.newArrayListWithCapacity(2);
typeList.add(currType);
typeList.add(defType);
return ListDistinctUtil.distinct(typeList);
}
}

@ -13,16 +13,16 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.strategy.sync; package org.opsli.plugins.generator.database.mysql;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.utils.Props; import org.opsli.common.utils.Props;
import org.opsli.core.generator.enums.DataBaseType; import org.opsli.plugins.generator.enums.DataBaseType;
import org.opsli.core.generator.exception.GeneratorException; import org.opsli.plugins.generator.exception.GeneratorException;
import org.opsli.core.generator.msg.GeneratorMsg; import org.opsli.plugins.generator.msg.GeneratorMsg;
import org.opsli.core.generator.strategy.sync.mysql.entity.FieldTypeAttribute; import org.opsli.plugins.generator.SyncStrategy;
import org.opsli.core.generator.strategy.sync.mysql.enums.MySQLSyncColumnType; import org.opsli.plugins.generator.FieldTypeAttribute;
import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel;
import org.opsli.modulars.generator.general.actuator.SQLActuator; import org.opsli.modulars.generator.general.actuator.SQLActuator;
import org.opsli.modulars.generator.table.service.IGenTableService; import org.opsli.modulars.generator.table.service.IGenTableService;
@ -43,7 +43,7 @@ import java.util.List;
*/ */
@Service @Service
@Transactional(readOnly = true) @Transactional(readOnly = true)
public class MySQLSyncBuilder implements SyncStrategy { public class MySqlSyncBuilder implements SyncStrategy {
/** 数据库引擎 */ /** 数据库引擎 */
private static final String ENGINE = "InnoDB"; private static final String ENGINE = "InnoDB";
@ -94,11 +94,11 @@ public class MySQLSyncBuilder implements SyncStrategy {
} }
// 删除表 // 删除表
sqlActuator.execute(this.genDropTableSQL(model.getOldTableName())); sqlActuator.execute(this.genDropTableSql(model.getOldTableName()));
sqlActuator.execute(this.genDropTableSQL(model.getTableName())); sqlActuator.execute(this.genDropTableSql(model.getTableName()));
// 新建表 // 新建表
sqlActuator.execute(this.genCreateTableSQL(model)); sqlActuator.execute(this.genCreateTableSql(model));
// 更新同步状态 // 更新同步状态
iGenTableService.renewSyncState(model.getId()); iGenTableService.renewSyncState(model.getId());
@ -109,7 +109,7 @@ public class MySQLSyncBuilder implements SyncStrategy {
* @param tableName * @param tableName
* @return sql * @return sql
*/ */
private String genDropTableSQL(String tableName) { private String genDropTableSql(String tableName) {
return "DROP TABLE IF EXISTS " + SQLFilterKit.replaceSQL(tableName) + ";"; return "DROP TABLE IF EXISTS " + SQLFilterKit.replaceSQL(tableName) + ";";
} }
@ -118,7 +118,7 @@ public class MySQLSyncBuilder implements SyncStrategy {
* @param model * @param model
* @return sql * @return sql
*/ */
private String genCreateTableSQL(GenTableAndColumnModel model){ private String genCreateTableSql(GenTableAndColumnModel model){
// 表名 // 表名
String tableName = model.getTableName(); String tableName = model.getTableName();
// 表字段 // 表字段
@ -138,7 +138,7 @@ public class MySQLSyncBuilder implements SyncStrategy {
// 字段类型 // 字段类型
String fieldType = SQLFilterKit.replaceSQL(tmp.getFieldType()); String fieldType = SQLFilterKit.replaceSQL(tmp.getFieldType());
FieldTypeAttribute fieldAttr = MySQLSyncColumnType.INSTANCE.getAttr(fieldType); FieldTypeAttribute fieldAttr = MySqlSyncColumnType.INSTANCE.getAttr(fieldType);
str.append(" ").append(fieldType); str.append(" ").append(fieldType);
if(fieldAttr != null){ if(fieldAttr != null){
// 字段有长度 // 字段有长度

@ -0,0 +1,108 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.database.mysql;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.opsli.common.utils.ListDistinctUtil;
import org.opsli.plugins.generator.converter.ColumnTypeConverter;
import org.opsli.plugins.generator.converter.JavaColumnTypeConverter;
import org.opsli.plugins.generator.enums.TypeEnum;
import org.opsli.plugins.generator.FieldTypeAttribute;
import java.util.List;
import java.util.Map;
/**
* MySQL
*
* @author parker
* @date 2020-11-18 13:21
*/
public enum MySqlSyncColumnType {
/** 实例对象 */
INSTANCE;
/** 字段类型 */
private final Map<String, FieldTypeAttribute> fieldTypeMap = Maps.newHashMap();
/** 类型转换器 */
private final ColumnTypeConverter columnTypeConverter = new JavaColumnTypeConverter();
MySqlSyncColumnType(){
fieldTypeMap.put("bit", new FieldTypeAttribute(true, false));
fieldTypeMap.put("tinyint", new FieldTypeAttribute(true, false));
fieldTypeMap.put("smallint", new FieldTypeAttribute(true, false));
fieldTypeMap.put("int", new FieldTypeAttribute(true, false));
fieldTypeMap.put("integer", new FieldTypeAttribute(true, false));
fieldTypeMap.put("bigint", new FieldTypeAttribute(true, false));
fieldTypeMap.put("float", new FieldTypeAttribute(true, true));
fieldTypeMap.put("double", new FieldTypeAttribute(true, true));
fieldTypeMap.put("decimal", new FieldTypeAttribute(true, true));
fieldTypeMap.put("char", new FieldTypeAttribute(true, false));
fieldTypeMap.put("varchar", new FieldTypeAttribute(true, false));
fieldTypeMap.put("text", new FieldTypeAttribute(false, false));
fieldTypeMap.put("date", new FieldTypeAttribute(false, false));
fieldTypeMap.put("time", new FieldTypeAttribute(false, false));
fieldTypeMap.put("datetime", new FieldTypeAttribute(false, false));
fieldTypeMap.put("timestamp", new FieldTypeAttribute(false, false));
fieldTypeMap.put("blob", new FieldTypeAttribute(false, false));
}
/**
*
* @return List
*/
public List<String> getFieldTypes(){
List<String> fieldTypes = Lists.newArrayListWithCapacity(fieldTypeMap.size());
fieldTypes.addAll(fieldTypeMap.keySet());
return ListDistinctUtil.distinct(fieldTypes);
}
/**
* Java
* @return List
*/
public Map<String, String> getJavaFieldTypes(){
List<String> fieldTypes = this.getFieldTypes();
Map<String, String> fieldJavaTypeMap = Maps.newHashMapWithExpectedSize(fieldTypes.size());
for (String fieldType : fieldTypes) {
fieldJavaTypeMap.put(fieldType, columnTypeConverter.convertType(
TypeEnum.getType(fieldType)));
}
return fieldJavaTypeMap;
}
/**
* JavaString
* @return List
*/
public Map<String, List<String>> getJavaFieldTypesBySafety(){
List<String> fieldTypes = this.getFieldTypes();
Map<String, List<String>> fieldJavaTypeMap = Maps.newHashMapWithExpectedSize(fieldTypes.size());
for (String fieldType : fieldTypes) {
fieldJavaTypeMap.put(fieldType, columnTypeConverter.convertTypeBySafety(
TypeEnum.getType(fieldType)));
}
return fieldJavaTypeMap;
}
public FieldTypeAttribute getAttr(String fieldType){
return fieldTypeMap.get(fieldType);
}
}

@ -0,0 +1,96 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.database.mysql;
import org.opsli.plugins.generator.TypeFormatter;
import java.util.Arrays;
import java.util.Collections;
/**
* MySQL
*
* @author Parker
* @date 202152614:51:50
*/
public class MySqlTypeFormatter implements TypeFormatter {
@Override
public boolean isBit(String columnType) {
return isContains(Collections.singletonList("bit"), columnType);
}
@Override
public boolean isBoolean(String columnType) {
return false;
}
@Override
public boolean isTinyint(String columnType) {
return isContains(Collections.singletonList("tinyint"), columnType);
}
@Override
public boolean isSmallint(String columnType) {
return isContains(Collections.singletonList("smallint"), columnType);
}
@Override
public boolean isInt(String columnType) {
return !isLong(columnType) && isContains(Arrays.asList("int", "integer"), columnType);
}
@Override
public boolean isLong(String columnType) {
return !isVarchar(columnType) && isContains(Collections.singletonList("bigint"), columnType);
}
@Override
public boolean isFloat(String columnType) {
return isContains(Collections.singletonList("float"), columnType);
}
@Override
public boolean isDouble(String columnType) {
return isContains(Collections.singletonList("double"), columnType);
}
@Override
public boolean isDecimal(String columnType) {
return isContains(Collections.singletonList("decimal"), columnType);
}
@Override
public boolean isVarchar(String columnType) {
return isContains(Arrays.asList("CHAR", "VARCHAR", "TEXT"), columnType);
}
@Override
public boolean isDatetime(String columnType) {
return isContains(Arrays.asList("DATE", "TIME", "DATETIME", "TIMESTAMP"), columnType);
}
@Override
public boolean isBlob(String columnType) {
return isContains(Collections.singletonList("blob"), columnType);
}
@Override
public boolean isJsonb(String columnType) {
return false;
}
}

@ -0,0 +1,96 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.database.oracle;
import org.opsli.plugins.generator.TypeFormatter;
import java.util.Arrays;
import java.util.Collections;
/**
* Oracle
*
* @author Parker
* @date 202152614:51:50
*/
public class OracleTypeFormatter implements TypeFormatter {
@Override
public boolean isBit(String columnType) {
return isContains(Collections.singletonList("bit"), columnType);
}
@Override
public boolean isBoolean(String columnType) {
return isContains(Collections.singletonList("boolean"), columnType);
}
@Override
public boolean isTinyint(String columnType) {
return isContains(Collections.singletonList("tinyint"), columnType);
}
@Override
public boolean isSmallint(String columnType) {
return false;
}
@Override
public boolean isInt(String columnType) {
return isContains(Arrays.asList("int", "integer"), columnType);
}
@Override
public boolean isLong(String columnType) {
return !isVarchar(columnType) && isContains(Collections.singletonList("long"), columnType);
}
@Override
public boolean isFloat(String columnType) {
return isContains(Collections.singletonList("float"), columnType);
}
@Override
public boolean isDouble(String columnType) {
return isContains(Collections.singletonList("double"), columnType);
}
@Override
public boolean isDecimal(String columnType) {
return isContains(Collections.singletonList("decimal"), columnType);
}
@Override
public boolean isVarchar(String columnType) {
return isContains(Arrays.asList("CHAR", "VARCHAR", "VARCHAR2", "NVARCHAR2", "TEXT", "NCHAR"), columnType);
}
@Override
public boolean isDatetime(String columnType) {
return isContains(Arrays.asList("DATE", "TIME", "DATETIME", "TIMESTAMP"), columnType);
}
@Override
public boolean isBlob(String columnType) {
return isContains(Collections.singletonList("blob"), columnType);
}
@Override
public boolean isJsonb(String columnType) {
return false;
}
}

@ -0,0 +1,96 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.database.postgresql;
import org.opsli.plugins.generator.TypeFormatter;
import java.util.Arrays;
import java.util.Collections;
/**
* PostgreSql
*
* @author Parker
* @date 202152614:51:50
*/
public class PostgreSqlTypeFormatter implements TypeFormatter {
@Override
public boolean isBit(String columnType) {
return isContains(Collections.singletonList("bit"), columnType);
}
@Override
public boolean isBoolean(String columnType) {
return isContains(Collections.singletonList("boolean"), columnType);
}
@Override
public boolean isTinyint(String columnType) {
return false;
}
@Override
public boolean isSmallint(String columnType) {
return isContains(Arrays.asList("int2", "serial2", "smallint"), columnType);
}
@Override
public boolean isInt(String columnType) {
return isContains(Arrays.asList("int4", "serial4", "integer"), columnType);
}
@Override
public boolean isLong(String columnType) {
return !isVarchar(columnType) && isContains(Arrays.asList("int8", "serial8", "bigint"), columnType);
}
@Override
public boolean isFloat(String columnType) {
return isContains(Arrays.asList("float", "real"), columnType);
}
@Override
public boolean isDouble(String columnType) {
return isContains(Collections.singletonList("double"), columnType);
}
@Override
public boolean isDecimal(String columnType) {
return isContains(Arrays.asList("decimal","numeric"), columnType);
}
@Override
public boolean isVarchar(String columnType) {
return isContains(Arrays.asList("CHAR", "VARCHAR", "TEXT", "character", "json"), columnType);
}
@Override
public boolean isDatetime(String columnType) {
return isContains(Arrays.asList("DATE", "TIME", "DATETIME", "TIMESTAMP"), columnType);
}
@Override
public boolean isBlob(String columnType) {
return isContains(Collections.singletonList("blob"), columnType);
}
@Override
public boolean isJsonb(String columnType) {
return isContains(Collections.singletonList("jsonb"), columnType);
}
}

@ -0,0 +1,96 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.database.sqlserver;
import org.opsli.plugins.generator.TypeFormatter;
import java.util.Arrays;
import java.util.Collections;
/**
* SqlServer
*
* @author Parker
* @date 202152614:51:50
*/
public class SqlServerTypeFormatter implements TypeFormatter {
@Override
public boolean isBit(String columnType) {
return isContains(Collections.singletonList("bit"), columnType);
}
@Override
public boolean isBoolean(String columnType) {
return isContains(Collections.singletonList("boolean"), columnType);
}
@Override
public boolean isTinyint(String columnType) {
return isContains(Collections.singletonList("tinyint"), columnType);
}
@Override
public boolean isSmallint(String columnType) {
return isContains(Collections.singletonList("smallint"), columnType);
}
@Override
public boolean isInt(String columnType) {
return !isLong(columnType) && isContains(Arrays.asList("int", "integer"), columnType);
}
@Override
public boolean isLong(String columnType) {
return !isVarchar(columnType) && isContains(Collections.singletonList("bigint"), columnType);
}
@Override
public boolean isFloat(String columnType) {
return isContains(Arrays.asList("float", "real"), columnType);
}
@Override
public boolean isDouble(String columnType) {
return isContains(Collections.singletonList("double"), columnType);
}
@Override
public boolean isDecimal(String columnType) {
return isContains(Arrays.asList("decimal", "numeric", "money", "smallmoney"), columnType);
}
@Override
public boolean isVarchar(String columnType) {
return isContains(Arrays.asList("CHAR", "VARCHAR", "TEXT", "nchar", "nvarchar", "ntext"), columnType);
}
@Override
public boolean isDatetime(String columnType) {
return isContains(Arrays.asList("DATE", "TIME", "DATETIME", "TIMESTAMP", "datetime2", "smalldatetime", "datetimeoffset"), columnType);
}
@Override
public boolean isBlob(String columnType) {
return isContains(Arrays.asList("blob", "binary", "varbinary"), columnType);
}
@Override
public boolean isJsonb(String columnType) {
return false;
}
}

@ -1,4 +1,19 @@
package org.opsli.core.generator.enums; /**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.enums;
/** /**
* *

@ -0,0 +1,103 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.enums;
import org.apache.commons.lang3.StringUtils;
import org.opsli.common.utils.ListDistinctUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Java
*
* @author Parker
* @date 202152616:31:08
*/
public enum JavaType {
/** 包装类型 */
BYTE("Byte", null),
SHORT("Short", null),
CHARACTER("Character", null),
INTEGER("Integer", null),
LONG("Long", null),
FLOAT("Float", null),
DOUBLE("Double", null),
BOOLEAN("Boolean", null),
STRING("String", null),
/** Big类 */
BIG_INTEGER("BigInteger", "java.math.BigInteger"),
BIG_DECIMAL("BigDecimal", "java.math.BigDecimal"),
/** 时间类 */
DATE("Date", "java.util.Date"),
LOCAL_DATE("LocalDate", "java.time.LocalDate"),
LOCAL_TIME("LocalTime", "java.time.LocalTime"),
YEAR("Year", "java.time.Year"),
YEAR_MONTH("YearMonth", "java.time.YearMonth"),
LOCAL_DATE_TIME("LocalDateTime", "java.time.LocalDateTime"),
INSTANT("Instant", "java.time.Instant"),
/** 其他 */
BYTE_ARRAY("Byte[]",null),
MAP_OBJECT("Map<String, Object>", "java.util.Map"),
;
/** 类型 */
private final String type;
/** 包路径 */
private final String pkg;
JavaType(final String type, final String pkg) {
this.type = type;
this.pkg = pkg;
}
public String getType() {
return type;
}
public String getPkg() {
return pkg;
}
/**
*
* @param typeList
* @return
*/
public static List<String> getPkgList(List<String> typeList) {
if(typeList == null || typeList.size() == 0){
return Collections.emptyList();
}
List<String> pkgList = new ArrayList<>();
JavaType[] types = values();
for (JavaType javaType : types) {
if(typeList.contains(javaType.type)){
pkgList.add(javaType.pkg);
}
}
pkgList.removeIf(StringUtils::isBlank);
// 去重复
return ListDistinctUtil.distinct(pkgList);
}
}

@ -0,0 +1,73 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.plugins.generator.enums;
/**
*
*
* @author tanghc
*/
public enum TypeEnum {
/** 统一类型 */
BIT("bit"),
BOOLEAN("boolean"),
TINYINT("tinyint"),
SMALLINT("smallint"),
INT("int"),
BIGINT("bigint"),
FLOAT("float"),
DOUBLE("double"),
DECIMAL("decimal"),
VARCHAR("varchar"),
DATETIME("datetime"),
BLOB("blob"),
JSONB("jsonb")
;
private final String type;
TypeEnum(String type) {
this.type = type;
}
public static TypeEnum getType(String type) {
TypeEnum[] types = values();
for (TypeEnum typeEnum : types) {
if (typeEnum.type.equalsIgnoreCase(type)) {
return typeEnum;
}
}
return null;
}
public String getType() {
return type;
}
}

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.exception; package org.opsli.plugins.generator.exception;
import org.opsli.common.base.msg.BaseMsg; import org.opsli.common.base.msg.BaseMsg;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.msg; package org.opsli.plugins.generator.msg;
import org.opsli.common.base.msg.BaseMsg; import org.opsli.common.base.msg.BaseMsg;

@ -13,26 +13,22 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.strategy.create; package org.opsli.plugins.generator.strategy.create;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.api.ApiFlag; import org.opsli.api.ApiFlag;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.ValidatorType;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.common.utils.HumpUtil;
import org.opsli.common.utils.Props; import org.opsli.common.utils.Props;
import org.opsli.common.utils.ZipUtils; import org.opsli.common.utils.ZipUtils;
import org.opsli.core.generator.strategy.create.backend.JavaCodeBuilder; import org.opsli.plugins.generator.strategy.create.backend.JavaCodeBuilder;
import org.opsli.core.generator.strategy.create.foreend.VueCodeBuilder; import org.opsli.plugins.generator.strategy.create.foreend.VueCodeBuilder;
import org.opsli.core.generator.strategy.create.readme.ReadMeBuilder; import org.opsli.plugins.generator.strategy.create.readme.ReadMeBuilder;
import org.opsli.core.generator.utils.GeneratorHandleUtil; import org.opsli.plugins.generator.utils.GeneratorHandleUtil;
import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel;
import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel;
import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -146,7 +142,12 @@ public enum CodeBuilder {
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(ValiArgsType.IS_NOT_NULL.toString()); // 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
} }
} }

@ -13,23 +13,18 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.strategy.create.backend; package org.opsli.plugins.generator.strategy.create.backend;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.jfinal.kit.Kv; import com.jfinal.kit.Kv;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.common.enums.DictType;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.common.utils.HumpUtil;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.common.utils.ZipUtils; import org.opsli.common.utils.ZipUtils;
import org.opsli.core.generator.strategy.create.CodeBuilder; import org.opsli.plugins.generator.strategy.create.CodeBuilder;
import org.opsli.core.generator.utils.EnjoyUtil; import org.opsli.plugins.generator.utils.EnjoyUtil;
import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel;
import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**

@ -13,20 +13,16 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.strategy.create.foreend; package org.opsli.plugins.generator.strategy.create.foreend;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.jfinal.kit.Kv; import com.jfinal.kit.Kv;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.common.enums.DictType;
import org.opsli.common.enums.ValiArgsType;
import org.opsli.common.utils.HumpUtil;
import org.opsli.common.utils.Props; import org.opsli.common.utils.Props;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.common.utils.ZipUtils; import org.opsli.common.utils.ZipUtils;
import org.opsli.core.generator.strategy.create.CodeBuilder; import org.opsli.plugins.generator.strategy.create.CodeBuilder;
import org.opsli.core.generator.utils.EnjoyUtil; import org.opsli.plugins.generator.utils.EnjoyUtil;
import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel;
import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel;
import java.util.*; import java.util.*;

@ -13,14 +13,14 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.strategy.create.readme; package org.opsli.plugins.generator.strategy.create.readme;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.jfinal.kit.Kv; import com.jfinal.kit.Kv;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.common.utils.ZipUtils; import org.opsli.common.utils.ZipUtils;
import org.opsli.core.generator.strategy.create.CodeBuilder; import org.opsli.plugins.generator.strategy.create.CodeBuilder;
import org.opsli.core.generator.utils.EnjoyUtil; import org.opsli.plugins.generator.utils.EnjoyUtil;
import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel;
import java.util.HashMap; import java.util.HashMap;

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.utils; package org.opsli.plugins.generator.utils;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;

@ -13,24 +13,25 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package org.opsli.core.generator.utils; package org.opsli.plugins.generator.utils;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.common.utils.ListDistinctUtil;
import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel;
import org.opsli.modulars.generator.importable.ImportTableUtil;
import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel;
import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel; import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel;
import org.opsli.plugins.generator.enums.JavaType;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Map;
/*** /***
* *
@ -41,9 +42,9 @@ import java.util.Set;
public final class GeneratorHandleUtil { public final class GeneratorHandleUtil {
/** 后端 验证前缀 */ /** 后端 验证前缀 */
private static final String BACKEND_VALIDATE_TYPE_PREFIX = "ValiArgsType."; private static final String BACKEND_VALIDATE_TYPE_PREFIX = "ValidatorType.";
/** 验证方法前缀 */ /** 验证方法前缀 */
private static final String VALIDATE_PREFIX = "validate_"; private static final String VALIDATE_PREFIX = "validator_";
/** /**
* *
@ -65,8 +66,8 @@ public final class GeneratorHandleUtil {
GenTableAndColumnModel model = builderModel.getModel(); GenTableAndColumnModel model = builderModel.getModel();
// 数据库表名转驼峰 // 数据库表名转驼峰
model.setTableHumpName( model.setTableHumpName(
HumpUtil.captureName( FieldUtil.upperFirstLetter(
HumpUtil.underlineToHump( FieldUtil.underlineToHump(
model.getTableName() model.getTableName()
) )
) )
@ -84,55 +85,40 @@ public final class GeneratorHandleUtil {
for (GenTableColumnModel columnModel : columnList) { for (GenTableColumnModel columnModel : columnList) {
// 1. 数据库字段名转驼峰 // 1. 数据库字段名转驼峰
columnModel.setFieldHumpName( columnModel.setFieldHumpName(
HumpUtil.underlineToHump( FieldUtil.underlineToHump(
columnModel.getFieldName() columnModel.getFieldName()
) )
); );
// 验证集合 // 验证集合
Set<String> validateTypeSet = Sets.newHashSet(columnModel.getValidateType()); List<String> validateTypeList = Convert.toList(String.class, columnModel.getValidateType());
// 如果非空 则开启非空验证 // 如果非空 则开启非空验证
if(DictType.NO_YES_YES.getValue().equals(columnModel.getIzNotNull())){ if(DictType.NO_YES_YES.getValue().equals(columnModel.getIzNotNull())){
validateTypeSet.add(ValiArgsType.IS_NOT_NULL.toString()); validateTypeList.add(ValidatorType.IS_NOT_NULL.toString());
} }
List<String> validateTypeList = Convert.toList(String.class, validateTypeSet); // 去空项
validateTypeList.removeIf(StringUtils::isBlank); validateTypeList.removeIf(StringUtils::isBlank);
// 去重复
validateTypeList = ListDistinctUtil.distinct(validateTypeList);
// 2. 后端字段验证 // 2. 处理字段验证器
// 处理验证器
if(!CollUtil.isEmpty(validateTypeList)){ if(!CollUtil.isEmpty(validateTypeList)){
StringBuilder backendStb = new StringBuilder(); List<String> typeList = Lists.newArrayListWithCapacity(validateTypeList.size());
StringBuilder frontendStb = new StringBuilder(); List<String> typeAndCommaList = Lists.newArrayListWithCapacity(validateTypeList.size());
columnModel.setFrontendValidateTypeList(Lists.newArrayList());
List<String> backendList = Lists.newArrayListWithCapacity(validateTypeList.size());
List<String> frontendList = Lists.newArrayListWithCapacity(validateTypeList.size());
for (int i = 0; i < validateTypeList.size(); i++) { for (int i = 0; i < validateTypeList.size(); i++) {
String validate = validateTypeList.get(i); String validate = validateTypeList.get(i);
String validateAndComma = validate;
backendStb.append(BACKEND_VALIDATE_TYPE_PREFIX).append(validate);
frontendStb.append(
HumpUtil.underlineToHump(
VALIDATE_PREFIX + validate.toLowerCase()));
backendList.add(validate);
frontendList.add(
HumpUtil.underlineToHump(
VALIDATE_PREFIX + validate.toLowerCase()));
if(i < validateTypeList.size() - 1 ){ if(i < validateTypeList.size() - 1 ){
backendStb.append(", "); validateAndComma+=", ";
frontendStb.append(", ");
}
} }
typeList.add(validate);
typeAndCommaList.add(validateAndComma);
}
columnModel.setBackendValidateType(backendStb.toString()); columnModel.setValidateTypeList(typeList);
columnModel.setFrontendValidateType(frontendStb.toString()); columnModel.setValidateTypeAndCommaList(typeAndCommaList);
model.setFrontendValidateType(frontendStb.toString());
columnModel.setBackendValidateTypeList(backendList);
columnModel.setFrontendValidateTypeList(frontendList);
} }
// 3. 处理 Form 表单字段 // 3. 处理 Form 表单字段
@ -172,6 +158,15 @@ public final class GeneratorHandleUtil {
} }
} }
// 6. Entity 引入 import
Map<String, String> javaFieldTypes = ImportTableUtil.getJavaFieldTypes();
List<String> javaTypeList = Lists.newArrayListWithCapacity(javaFieldTypes.size());
for (Map.Entry<String, String> entry : javaFieldTypes.entrySet()) {
javaTypeList.add(entry.getValue());
}
List<String> pkgList = JavaType.getPkgList(javaTypeList);
model.setEntityPkgList(pkgList);
} }
return builderModel; return builderModel;

@ -19,7 +19,9 @@ package #(data.packageName+"."+data.moduleName+"."+data.subModuleName).entity;
package #(data.packageName+"."+data.moduleName).entity; package #(data.packageName+"."+data.moduleName).entity;
#end #end
import java.util.Date; #for(pkg : data.model.entityPkgList)
import #(pkg);
#end
import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;

@ -19,15 +19,18 @@ package #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName);
package #(apiPath).wrapper.#(data.moduleName); package #(apiPath).wrapper.#(data.moduleName);
#end #end
import java.util.Date; #for(pkg : data.model.entityPkgList)
import #(pkg);
#end
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import #(apiPath).base.warpper.ApiWrapper; import #(apiPath).base.warpper.ApiWrapper;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.annotation.validator.ValidatorLenMin;
import org.opsli.common.enums.ValidatorType;
import org.opsli.plugins.excel.annotation.ExcelInfo; import org.opsli.plugins.excel.annotation.ExcelInfo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -53,14 +56,18 @@ public class #(data.model.tableHumpName)Model extends ApiWrapper {
#else #else
@ExcelInfo @ExcelInfo
#end #end
#if(column.backendValidateType != null && column.backendValidateType != "") #if(column.validateTypeAndCommaList != null && column.validateTypeAndCommaList.size() > 0)
@ValidationArgs({#(column.backendValidateType)}) @Validator({
#for(typeAndComma : column.validateTypeAndCommaList)
ValidatorType.#(typeAndComma)
#end
})
#end #end
#if(column.fieldLength != null && column.fieldLength > 0) #if(column.fieldLength != null && column.fieldLength > 0)
#if(column.fieldPrecision != null && column.fieldPrecision > 0) #if(column.fieldPrecision != null && column.fieldPrecision > 0)
@ValidationArgsLenMax(#(column.fieldLength+column.fieldPrecision)) @ValidatorLenMax(#(column.fieldLength+column.fieldPrecision))
#else #else
@ValidationArgsLenMax(#(column.fieldLength)) @ValidatorLenMax(#(column.fieldLength))
#end #end
#end #end
### ###

@ -81,9 +81,8 @@
#else #else
import { doInsert, doUpdate } from "@/api/#(data.moduleName)/#(data.model.tableHumpName)Management"; import { doInsert, doUpdate } from "@/api/#(data.moduleName)/#(data.model.tableHumpName)Management";
#end #end
import { formateDate } from "@/utils/format";
import { isNull } from "@/utils/validate"; import { isNull } from "@/utils/validate";
import { #(data.model.frontendValidateType) } from "@/utils/validateRlue"; import { validatorRule } from "@/utils/validateRlue";
export default { export default {
name: "#(data.model.tableHumpName)ManagementEdit", name: "#(data.model.tableHumpName)ManagementEdit",
@ -98,16 +97,16 @@
rules: { rules: {
#for(columnList : data.model.formList) #for(columnList : data.model.formList)
#for(column : columnList) #for(column : columnList)
#if(column.frontendValidateTypeList.size() > 0) #if(column.validateTypeList != null && column.validateTypeList.size() > 0)
#(column.fieldHumpName): [ #(column.fieldHumpName): [
#for(validate : column.frontendValidateTypeList) #for(typeNotComma : column.validateTypeList)
#if(validate == "isNotNull") #if(typeNotComma == "IS_NOT_NULL")
{ required: true, trigger: "blur", message: "#(column.fieldComments)非空" }, { required: true, trigger: "blur", message: "#(column.fieldComments)非空" },
#end #end
#end #end
#for(validate : column.frontendValidateTypeList) #for(typeNotComma : column.validateTypeList)
#if(validate != "isNotNull") #if(typeNotComma != "IS_NOT_NULL")
{ required: false, trigger: "blur", validator: #(validate) }, { required: false, trigger: "blur", validator: validatorRule.#(typeNotComma) },
#end #end
#end #end
], ],

@ -23,7 +23,7 @@ import org.opsli.api.wrapper.system.area.SysAreaModel;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.core.base.entity.HasChildren; import org.opsli.core.base.entity.HasChildren;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.persistence.querybuilder.GenQueryBuilder; import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
@ -132,7 +132,7 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
boolean ret = false; boolean ret = false;
QueryBuilder<SysArea> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysArea> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysArea> queryWrapper = queryBuilder.build(); QueryWrapper<SysArea> queryWrapper = queryBuilder.build();
queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
List<SysArea> childList = super.findList(queryWrapper); List<SysArea> childList = super.findList(queryWrapper);
for (SysArea child : childList) { for (SysArea child : childList) {
super.delete(child.getId()); super.delete(child.getId());
@ -181,9 +181,9 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
} }
QueryWrapper<SysArea> wrapper = new QueryWrapper<>(); QueryWrapper<SysArea> wrapper = new QueryWrapper<>();
wrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds) wrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds)
.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) .eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); .groupBy(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID));
return mapper.hasChildren(wrapper); return mapper.hasChildren(wrapper);
} }

@ -22,7 +22,6 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig; import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@ -43,10 +42,9 @@ import org.opsli.common.annotation.ApiRestController;
import org.opsli.common.annotation.EnableLog; import org.opsli.common.annotation.EnableLog;
import org.opsli.common.annotation.RequiresPermissionsCus; import org.opsli.common.annotation.RequiresPermissionsCus;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.core.base.controller.BaseRestController; import org.opsli.core.base.controller.BaseRestController;
import org.opsli.core.base.entity.HasChildren; import org.opsli.core.base.entity.HasChildren;
import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
import org.opsli.core.persistence.querybuilder.QueryBuilder; import org.opsli.core.persistence.querybuilder.QueryBuilder;
import org.opsli.core.persistence.querybuilder.WebQueryBuilder; import org.opsli.core.persistence.querybuilder.WebQueryBuilder;
import org.opsli.core.utils.TreeBuildUtil; import org.opsli.core.utils.TreeBuildUtil;
@ -107,7 +105,7 @@ public class SysAreaRestController extends BaseRestController<SysArea, SysAreaMo
public ResultVo<?> findTree(String parentId) { public ResultVo<?> findTree(String parentId) {
QueryWrapper<SysArea> wrapper = new QueryWrapper<>(); QueryWrapper<SysArea> wrapper = new QueryWrapper<>();
wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
List<SysArea> dataList = IService.findList(wrapper); List<SysArea> dataList = IService.findList(wrapper);
// 获得BeanMapList // 获得BeanMapList

@ -25,7 +25,7 @@ import org.opsli.api.wrapper.system.dict.DictModel;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.msg.CoreMsg; import org.opsli.core.msg.CoreMsg;
import org.opsli.core.persistence.querybuilder.GenQueryBuilder; import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
@ -170,7 +170,7 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys
QueryBuilder<SysDictDetail> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysDictDetail> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysDictDetail> queryWrapper = queryBuilder.build(); QueryWrapper<SysDictDetail> queryWrapper = queryBuilder.build();
List<?> idList = Convert.toList(ids); List<?> idList = Convert.toList(ids);
queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList);
List<SysDictDetail> list = this.findList(queryWrapper); List<SysDictDetail> list = this.findList(queryWrapper);
boolean ret = super.deleteAll(ids); boolean ret = super.deleteAll(ids);
@ -208,7 +208,7 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys
for (DictDetailModel model : models) { for (DictDetailModel model : models) {
idList.add(model.getId()); idList.add(model.getId());
} }
queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList);
List<SysDictDetail> list = this.findList(queryWrapper); List<SysDictDetail> list = this.findList(queryWrapper);
@ -244,7 +244,7 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys
return false; return false;
} }
String key = HumpUtil.humpToUnderline("typeId"); String key = FieldUtil.humpToUnderline("typeId");
QueryBuilder<SysDictDetail> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysDictDetail> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysDictDetail> queryWrapper = queryBuilder.build(); QueryWrapper<SysDictDetail> queryWrapper = queryBuilder.build();
queryWrapper.eq(key, parentId); queryWrapper.eq(key, parentId);
@ -273,8 +273,8 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys
return null; return null;
} }
String key = HumpUtil.humpToUnderline("typeCode"); String key = FieldUtil.humpToUnderline("typeCode");
String deleted = HumpUtil.humpToUnderline("deleted"); String deleted = FieldUtil.humpToUnderline("deleted");
QueryBuilder<SysDictDetail> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysDictDetail> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysDictDetail> queryWrapper = queryBuilder.build(); QueryWrapper<SysDictDetail> queryWrapper = queryBuilder.build();

@ -19,10 +19,10 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.opsli.api.base.encrypt.BaseEncrypt; import org.opsli.api.base.encrypt.BaseEncrypt;
import org.opsli.common.annotation.validation.ValidationArgs; import org.opsli.common.annotation.validator.Validator;
import org.opsli.common.annotation.validation.ValidationArgsLenMax; import org.opsli.common.annotation.validator.ValidatorLenMax;
import org.opsli.common.annotation.validation.ValidationArgsLenMin; import org.opsli.common.annotation.validator.ValidatorLenMin;
import org.opsli.common.enums.ValiArgsType; import org.opsli.common.enums.ValidatorType;
/** /**
* *
@ -36,19 +36,19 @@ public class LoginForm extends BaseEncrypt {
/** 用户名 */ /** 用户名 */
@ApiModelProperty(value = "用户名") @ApiModelProperty(value = "用户名")
@ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL})
@ValidationArgsLenMax(50) @ValidatorLenMax(50)
private String username; private String username;
/** 密码 */ /** 密码 */
@ApiModelProperty(value = "密码") @ApiModelProperty(value = "密码")
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_SECURITY_PASSWORD}) @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_SECURITY_PASSWORD})
@ValidationArgsLenMin(6) @ValidatorLenMin(6)
private String password; private String password;
/** 验证码 */ /** 验证码 */
@ApiModelProperty(value = "验证码") @ApiModelProperty(value = "验证码")
@ValidationArgsLenMax(30) @ValidatorLenMax(30)
private String captcha; private String captcha;
/** UUID */ /** UUID */

@ -29,7 +29,7 @@ import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.common.annotation.ApiCryptoAsymmetric; import org.opsli.common.annotation.ApiCryptoAsymmetric;
import org.opsli.common.annotation.Limiter; import org.opsli.common.annotation.Limiter;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.core.utils.ValidationUtil; import org.opsli.core.utils.ValidatorUtil;
import org.opsli.core.api.TokenThreadLocal; import org.opsli.core.api.TokenThreadLocal;
import org.opsli.common.enums.AlertType; import org.opsli.common.enums.AlertType;
import org.opsli.common.enums.OptionsType; import org.opsli.common.enums.OptionsType;
@ -83,7 +83,7 @@ public class LoginRestController {
} }
// 验证登录对象 // 验证登录对象
ValidationUtil.verify(form); ValidatorUtil.verify(form);
// 判断账号是否临时锁定 // 判断账号是否临时锁定
UserTokenUtil.verifyLockAccount(form.getUsername()); UserTokenUtil.verifyLockAccount(form.getUsername());

@ -26,7 +26,7 @@ import org.opsli.common.constants.MenuConstants;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.core.base.entity.HasChildren; import org.opsli.core.base.entity.HasChildren;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.msg.CoreMsg; import org.opsli.core.msg.CoreMsg;
@ -274,7 +274,7 @@ public class MenuServiceImpl extends CrudServiceImpl<MenuMapper, SysMenu, MenuMo
boolean ret = false; boolean ret = false;
QueryBuilder<SysMenu> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysMenu> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysMenu> queryWrapper = queryBuilder.build(); QueryWrapper<SysMenu> queryWrapper = queryBuilder.build();
queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
List<SysMenu> menuList = super.findList(queryWrapper); List<SysMenu> menuList = super.findList(queryWrapper);
for (SysMenu child : menuList) { for (SysMenu child : menuList) {
// 删除菜单数据 // 删除菜单数据
@ -299,9 +299,9 @@ public class MenuServiceImpl extends CrudServiceImpl<MenuMapper, SysMenu, MenuMo
return null; return null;
} }
QueryWrapper<SysMenu> wrapper = new QueryWrapper<>(); QueryWrapper<SysMenu> wrapper = new QueryWrapper<>();
wrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds) wrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds)
.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) .eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); .groupBy(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID));
return mapper.hasChildren(wrapper); return mapper.hasChildren(wrapper);
} }
@ -318,10 +318,10 @@ public class MenuServiceImpl extends CrudServiceImpl<MenuMapper, SysMenu, MenuMo
return null; return null;
} }
QueryWrapper<SysMenu> wrapper = new QueryWrapper<>(); QueryWrapper<SysMenu> wrapper = new QueryWrapper<>();
wrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds) wrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds)
.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) .eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("type", "1") .eq("type", "1")
.groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); .groupBy(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID));
return mapper.hasChildren(wrapper); return mapper.hasChildren(wrapper);
} }

@ -21,7 +21,6 @@ import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig; import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -42,8 +41,7 @@ import org.opsli.common.annotation.EnableLog;
import org.opsli.common.annotation.RequiresPermissionsCus; import org.opsli.common.annotation.RequiresPermissionsCus;
import org.opsli.common.constants.MenuConstants; import org.opsli.common.constants.MenuConstants;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.exception.ServiceException; import org.opsli.common.utils.FieldUtil;
import org.opsli.common.utils.HumpUtil;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.controller.BaseRestController; import org.opsli.core.base.controller.BaseRestController;
import org.opsli.core.base.entity.HasChildren; import org.opsli.core.base.entity.HasChildren;
@ -54,7 +52,6 @@ import org.opsli.core.persistence.querybuilder.QueryBuilder;
import org.opsli.core.persistence.querybuilder.WebQueryBuilder; import org.opsli.core.persistence.querybuilder.WebQueryBuilder;
import org.opsli.core.utils.TreeBuildUtil; import org.opsli.core.utils.TreeBuildUtil;
import org.opsli.core.utils.UserUtil; import org.opsli.core.utils.UserUtil;
import org.opsli.modulars.system.SystemMsg;
import org.opsli.modulars.system.menu.entity.SysMenu; import org.opsli.modulars.system.menu.entity.SysMenu;
import org.opsli.modulars.system.menu.service.IMenuService; import org.opsli.modulars.system.menu.service.IMenuService;
import org.opsli.modulars.system.user.service.IUserService; import org.opsli.modulars.system.user.service.IUserService;
@ -184,13 +181,13 @@ public class MenuRestController extends BaseRestController<SysMenu, MenuModel, I
QueryBuilder<SysMenu> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysMenu> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysMenu> queryWrapper = queryBuilder.build(); QueryWrapper<SysMenu> queryWrapper = queryBuilder.build();
queryWrapper.eq( queryWrapper.eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
queryWrapper.eq("type", "1"); queryWrapper.eq("type", "1");
// 如果传入ID 则不包含自身 // 如果传入ID 则不包含自身
if(StringUtils.isNotEmpty(id)){ if(StringUtils.isNotEmpty(id)){
queryWrapper.notIn( queryWrapper.notIn(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), id); FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID), id);
} }
@ -231,7 +228,7 @@ public class MenuRestController extends BaseRestController<SysMenu, MenuModel, I
}else{ }else{
QueryBuilder<SysMenu> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysMenu> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysMenu> queryWrapper = queryBuilder.build(); QueryWrapper<SysMenu> queryWrapper = queryBuilder.build();
queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
// 获得菜单 // 获得菜单
List<SysMenu> menuList = IService.findList(queryWrapper); List<SysMenu> menuList = IService.findList(queryWrapper);

@ -30,7 +30,7 @@ import org.opsli.common.exception.ServiceException;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.msg.CoreMsg; import org.opsli.core.msg.CoreMsg;
import org.opsli.core.utils.OptionsUtil; import org.opsli.core.utils.OptionsUtil;
import org.opsli.core.utils.ValidationUtil; import org.opsli.core.utils.ValidatorUtil;
import org.opsli.modulars.system.SystemMsg; import org.opsli.modulars.system.SystemMsg;
import org.opsli.modulars.system.options.entity.SysOptions; import org.opsli.modulars.system.options.entity.SysOptions;
import org.opsli.modulars.system.options.mapper.SysOptionsMapper; import org.opsli.modulars.system.options.mapper.SysOptionsMapper;
@ -64,7 +64,7 @@ public class SysOptionsServiceImpl extends CrudServiceImpl<SysOptionsMapper, Sys
} }
// 验证数据 // 验证数据
ValidationUtil.verify(model); ValidatorUtil.verify(model);
// 唯一验证 // 唯一验证
Integer count = this.uniqueVerificationByCode(model); Integer count = this.uniqueVerificationByCode(model);
@ -94,7 +94,7 @@ public class SysOptionsServiceImpl extends CrudServiceImpl<SysOptionsMapper, Sys
} }
// 验证数据 // 验证数据
ValidationUtil.verify(model); ValidatorUtil.verify(model);
// 验证是否是内置数据 // 验证是否是内置数据
OptionsModel optionsModel = this.get(model); OptionsModel optionsModel = this.get(model);

@ -25,7 +25,7 @@ import org.opsli.api.wrapper.system.org.SysOrgModel;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.core.base.entity.HasChildren; import org.opsli.core.base.entity.HasChildren;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.persistence.querybuilder.GenQueryBuilder; import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
@ -35,8 +35,6 @@ import org.opsli.modulars.system.SystemMsg;
import org.opsli.modulars.system.org.entity.SysOrg; import org.opsli.modulars.system.org.entity.SysOrg;
import org.opsli.modulars.system.org.mapper.SysOrgMapper; import org.opsli.modulars.system.org.mapper.SysOrgMapper;
import org.opsli.modulars.system.org.service.ISysOrgService; import org.opsli.modulars.system.org.service.ISysOrgService;
import org.opsli.modulars.system.user.entity.SysUser;
import org.opsli.modulars.system.user.service.IUserOrgRefService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -174,7 +172,7 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
public void updateTenantByParentId(String parentId, String tenantId) { public void updateTenantByParentId(String parentId, String tenantId) {
QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysOrg> queryWrapper = queryBuilder.build(); QueryWrapper<SysOrg> queryWrapper = queryBuilder.build();
queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
List<SysOrg> entityList = super.findList(queryWrapper); List<SysOrg> entityList = super.findList(queryWrapper);
for (SysOrg sysOrg : entityList) { for (SysOrg sysOrg : entityList) {
sysOrg.setTenantId(tenantId); sysOrg.setTenantId(tenantId);
@ -192,7 +190,7 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
public void deleteByParentId(String parentId) { public void deleteByParentId(String parentId) {
QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysOrg> queryWrapper = queryBuilder.build(); QueryWrapper<SysOrg> queryWrapper = queryBuilder.build();
queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
List<SysOrg> entityList = super.findList(queryWrapper); List<SysOrg> entityList = super.findList(queryWrapper);
for (SysOrg sysOrg : entityList) { for (SysOrg sysOrg : entityList) {
super.delete(sysOrg.getId()); super.delete(sysOrg.getId());
@ -240,9 +238,9 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
} }
QueryWrapper<SysOrg> wrapper = new QueryWrapper<>(); QueryWrapper<SysOrg> wrapper = new QueryWrapper<>();
wrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds) wrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds)
.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) .eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); .groupBy(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID));
return mapper.hasChildren(wrapper); return mapper.hasChildren(wrapper);
} }

@ -19,16 +19,13 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig; import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.opsli.api.base.result.ResultVo; import org.opsli.api.base.result.ResultVo;
import org.opsli.api.web.system.org.SysOrgRestApi; import org.opsli.api.web.system.org.SysOrgRestApi;
@ -37,7 +34,7 @@ import org.opsli.common.annotation.ApiRestController;
import org.opsli.common.annotation.EnableLog; import org.opsli.common.annotation.EnableLog;
import org.opsli.common.annotation.RequiresPermissionsCus; import org.opsli.common.annotation.RequiresPermissionsCus;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.controller.BaseRestController; import org.opsli.core.base.controller.BaseRestController;
import org.opsli.core.base.entity.HasChildren; import org.opsli.core.base.entity.HasChildren;
@ -89,7 +86,7 @@ public class SysOrgRestController extends BaseRestController<SysOrg, SysOrgModel
QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysOrg> wrapper = queryBuilder.build(); QueryWrapper<SysOrg> wrapper = queryBuilder.build();
wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
// 获得用户 对应菜单 // 获得用户 对应菜单
List<SysOrg> dataList = IService.findList(wrapper); List<SysOrg> dataList = IService.findList(wrapper);
@ -127,7 +124,7 @@ public class SysOrgRestController extends BaseRestController<SysOrg, SysOrgModel
QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysOrg> wrapper = queryBuilder.build(); QueryWrapper<SysOrg> wrapper = queryBuilder.build();
wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
// 获得用户 对应菜单 // 获得用户 对应菜单
List<SysOrg> dataList = IService.findList(wrapper); List<SysOrg> dataList = IService.findList(wrapper);
@ -160,7 +157,7 @@ public class SysOrgRestController extends BaseRestController<SysOrg, SysOrgModel
QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysOrg> wrapper = queryBuilder.build(); QueryWrapper<SysOrg> wrapper = queryBuilder.build();
wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
// 获得用户 对应菜单 // 获得用户 对应菜单
List<SysOrg> dataList = IService.findList(wrapper); List<SysOrg> dataList = IService.findList(wrapper);

@ -27,7 +27,7 @@ import org.opsli.api.wrapper.system.user.UserModel;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.msg.CoreMsg; import org.opsli.core.msg.CoreMsg;
import org.opsli.core.utils.TenantUtil; import org.opsli.core.utils.TenantUtil;
@ -93,7 +93,7 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
UpdateWrapper<SysTenant> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<SysTenant> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("enable", enable) updateWrapper.set("enable", enable)
.eq( .eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), tenantId); FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID), tenantId);
if(this.update(updateWrapper)){ if(this.update(updateWrapper)){
// 清除缓存 // 清除缓存
this.clearCache(Collections.singletonList(tenantId)); this.clearCache(Collections.singletonList(tenantId));
@ -350,7 +350,7 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
// 如果有租户还在被引用 则不允许删除该租户 // 如果有租户还在被引用 则不允许删除该租户
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>(); QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT), queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT),
tenantIdList tenantIdList
); );
int count = iUserService.count(queryWrapper); int count = iUserService.count(queryWrapper);

@ -34,7 +34,7 @@ import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.enums.DictType; import org.opsli.common.enums.DictType;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.opsli.common.utils.CheckStrength; import org.opsli.common.utils.CheckStrength;
import org.opsli.common.utils.HumpUtil; import org.opsli.common.utils.FieldUtil;
import org.opsli.common.utils.ListDistinctUtil; import org.opsli.common.utils.ListDistinctUtil;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.base.service.impl.CrudServiceImpl;
@ -157,7 +157,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
QueryWrapper<SysRole> roleQueryWrapper = new QueryWrapper<>(); QueryWrapper<SysRole> roleQueryWrapper = new QueryWrapper<>();
roleQueryWrapper.eq("role_code", defRole); roleQueryWrapper.eq("role_code", defRole);
roleQueryWrapper.eq( roleQueryWrapper.eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC), FieldUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC),
DictType.NO_YES_NO.getValue()); DictType.NO_YES_NO.getValue());
SysRole sysRole = iRoleService.getOne(roleQueryWrapper); SysRole sysRole = iRoleService.getOne(roleQueryWrapper);
if(sysRole != null){ if(sysRole != null){
@ -255,7 +255,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("enable", enable) updateWrapper.set("enable", enable)
.eq( .eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), userId FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID), userId
); );
if(this.update(updateWrapper)){ if(this.update(updateWrapper)){
// 刷新用户缓存 // 刷新用户缓存
@ -352,7 +352,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
QueryBuilder<SysUser> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysUser> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysUser> queryWrapper = queryBuilder.build(); QueryWrapper<SysUser> queryWrapper = queryBuilder.build();
queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList);
List<UserModel> modelList = super.transformTs2Ms( List<UserModel> modelList = super.transformTs2Ms(
this.findList(queryWrapper) this.findList(queryWrapper)
); );
@ -399,7 +399,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
QueryBuilder<SysUser> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysUser> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysUser> queryWrapper = queryBuilder.build(); QueryWrapper<SysUser> queryWrapper = queryBuilder.build();
queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList);
List<UserModel> modelList = super.transformTs2Ms( List<UserModel> modelList = super.transformTs2Ms(
this.findList(queryWrapper) this.findList(queryWrapper)
); );
@ -415,12 +415,12 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
@Override @Override
public UserModel queryByUserName(String username) { public UserModel queryByUserName(String username) {
String key = HumpUtil.humpToUnderline("username"); String key = FieldUtil.humpToUnderline("username");
QueryBuilder<SysUser> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysUser> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysUser> queryWrapper = queryBuilder.build(); QueryWrapper<SysUser> queryWrapper = queryBuilder.build();
queryWrapper.eq(key, username); queryWrapper.eq(key, username);
queryWrapper.eq( queryWrapper.eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC) FieldUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC)
, "0"); , "0");
SysUser user = this.getOne(queryWrapper); SysUser user = this.getOne(queryWrapper);
return super.transformT2M(user); return super.transformT2M(user);
@ -700,7 +700,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
// 逻辑删除 查询未删除数据 // 逻辑删除 查询未删除数据
queryWrapper.eq( queryWrapper.eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC), DictType.NO_YES_NO.getValue()); FieldUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC), DictType.NO_YES_NO.getValue());
return mapper.findList(queryWrapper); return mapper.findList(queryWrapper);
} }

@ -39,8 +39,7 @@ import org.opsli.common.annotation.RequiresPermissionsCus;
import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.exception.ServiceException; import org.opsli.common.exception.ServiceException;
import org.opsli.common.exception.TokenException; import org.opsli.common.exception.TokenException;
import org.opsli.common.utils.CheckStrength; import org.opsli.common.utils.FieldUtil;
import org.opsli.common.utils.HumpUtil;
import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.controller.BaseRestController; import org.opsli.core.base.controller.BaseRestController;
import org.opsli.core.msg.TokenMsg; import org.opsli.core.msg.TokenMsg;
@ -575,7 +574,7 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
orgIds.add(org.getPostId()); orgIds.add(org.getPostId());
QueryWrapper<SysOrg> orgQueryWrapper = new QueryWrapper<>(); QueryWrapper<SysOrg> orgQueryWrapper = new QueryWrapper<>();
orgQueryWrapper.in( orgQueryWrapper.in(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID),
orgIds); orgIds);
List<SysOrg> orgList = iSysOrgService.findList(orgQueryWrapper); List<SysOrg> orgList = iSysOrgService.findList(orgQueryWrapper);
if(CollUtil.isNotEmpty(orgList)){ if(CollUtil.isNotEmpty(orgList)){

Loading…
Cancel
Save