diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/gentest/carinfo/TestCarModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/gentest/carinfo/TestCarModel.java index 5fdc730..03f73f9 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/gentest/carinfo/TestCarModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/gentest/carinfo/TestCarModel.java @@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.format.annotation.DateTimeFormat; @@ -42,24 +42,24 @@ public class TestCarModel extends ApiWrapper { @ApiModelProperty(value = "汽车名称") @ExcelProperty(value = "汽车名称", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(20) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(20) private String carName; /** 汽车类型 */ @ApiModelProperty(value = "汽车类型") @ExcelProperty(value = "汽车类型", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(20) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(20) private String carType; /** 汽车品牌 */ @ApiModelProperty(value = "汽车品牌") @ExcelProperty(value = "汽车品牌", order = 3) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(50) private String carBrand; /** 生产日期 */ @@ -74,7 +74,7 @@ public class TestCarModel extends ApiWrapper { @ApiModelProperty(value = "是否启用") @ExcelProperty(value = "是否启用", order = 5) @ExcelInfo( dictType = "no_yes" ) - @ValidationArgsLenMax(1) + @ValidatorLenMax(1) private String izUsable; diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/gentest/user/TestUserModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/gentest/user/TestUserModel.java index f745d02..84d3127 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/gentest/user/TestUserModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/gentest/user/TestUserModel.java @@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; import com.fasterxml.jackson.annotation.JsonFormat; @@ -43,31 +43,31 @@ public class TestUserModel extends ApiWrapper { @ApiModelProperty(value = "名称") @ExcelProperty(value = "名称", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(50) private String name; /** 金钱 */ @ApiModelProperty(value = "金钱") @ExcelProperty(value = "金钱", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_MONEY}) - @ValidationArgsLenMax(8) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_MONEY}) + @ValidatorLenMax(8) private Double money; /** 年龄 */ @ApiModelProperty(value = "年龄") @ExcelProperty(value = "年龄", order = 3) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_INTEGER}) - @ValidationArgsLenMax(5) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_INTEGER}) + @ValidatorLenMax(5) private Integer age; /** 生日 */ @ApiModelProperty(value = "生日") @ExcelProperty(value = "生日", order = 4) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, }) + @Validator({ValidatorType.IS_NOT_NULL, }) @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") private Date birth; @@ -76,8 +76,8 @@ public class TestUserModel extends ApiWrapper { @ApiModelProperty(value = "是否启用") @ExcelProperty(value = "是否启用", order = 5) @ExcelInfo( dictType = "no_yes" ) - @ValidationArgs({ValiArgsType.IS_NOT_NULL, }) - @ValidationArgsLenMax(1) + @Validator({ValidatorType.IS_NOT_NULL, }) + @ValidatorLenMax(1) private String izUsable; diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/area/SysAreaModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/area/SysAreaModel.java index 87bad6b..3a80da6 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/area/SysAreaModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/area/SysAreaModel.java @@ -15,15 +15,14 @@ */ package org.opsli.api.wrapper.system.area; -import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -40,23 +39,23 @@ public class SysAreaModel extends ApiWrapper { @ApiModelProperty(value = "父级主键") @ExcelProperty(value = "父级主键", order = 1) @ExcelInfo - @ValidationArgsLenMax(19) + @ValidatorLenMax(19) private String parentId; /** 地域编号 */ @ApiModelProperty(value = "地域编号") @ExcelProperty(value = "地域编号", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_INTEGER}) - @ValidationArgsLenMax(40) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_INTEGER}) + @ValidatorLenMax(40) private String areaCode; /** 地域名称 */ @ApiModelProperty(value = "地域名称") @ExcelProperty(value = "地域名称", order = 3) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(40) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(40) private String areaName; } diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/dict/DictDetailModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/dict/DictDetailModel.java index 3be8deb..50e6792 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/dict/DictDetailModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/dict/DictDetailModel.java @@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -40,53 +40,53 @@ public class DictDetailModel extends ApiWrapper { /** 字典ID */ @ApiModelProperty(value = "字典类型ID") @ExcelIgnore - @ValidationArgs(ValiArgsType.IS_NOT_NULL) + @Validator(ValidatorType.IS_NOT_NULL) private String typeId; /** 类型编号 - 冗余 */ @ApiModelProperty(value = "字典类型Code") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(120) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(120) private String typeCode; /** 字典名称 */ @ApiModelProperty(value = "字典名称") @ExcelProperty(value = "字典名称", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(120) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(120) private String dictName; /** 字典值 */ @ApiModelProperty(value = "字典值") @ExcelProperty(value = "字典值", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(120) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(120) private String dictValue; /** 是否内置数据 0否 1是*/ @ApiModelProperty(value = "是否内置数据 0否 1是") @ExcelProperty(value = "是否内置数据", order = 2) @ExcelInfo(dictType = "no_yes") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(1) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(1) private String izLock; /** 排序 */ @ApiModelProperty(value = "排序") @ExcelProperty(value = "排序", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_INTEGER}) - @ValidationArgsLenMax(10) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_INTEGER}) + @ValidatorLenMax(10) private Integer sortNo; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelProperty(value = "备注", order = 2) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/dict/DictModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/dict/DictModel.java index af8c905..b4d0286 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/dict/DictModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/dict/DictModel.java @@ -20,9 +20,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -41,31 +41,31 @@ public class DictModel extends ApiWrapper { @ApiModelProperty(value = "字典类型编号") @ExcelProperty(value = "字典类型编号", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(120) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(120) private String typeCode; /** 字典类型名称 */ @ApiModelProperty(value = "字典类型名称") @ExcelProperty(value = "字典类型名称", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(120) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(120) private String typeName; /** 是否内置数据 0否 1是*/ @ApiModelProperty(value = "是否内置数据 0否 1是") @ExcelProperty(value = "是否内置数据", order = 3) @ExcelInfo(dictType = "no_yes") - @ValidationArgs(ValiArgsType.IS_NOT_NULL) - @ValidationArgsLenMax(1) + @Validator(ValidatorType.IS_NOT_NULL) + @ValidatorLenMax(1) private String izLock; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelProperty(value = "备注", order = 4) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/menu/MenuFullModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/menu/MenuFullModel.java index fb41955..e09f812 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/menu/MenuFullModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/menu/MenuFullModel.java @@ -19,10 +19,9 @@ import com.alibaba.excel.annotation.ExcelIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import java.io.Serializable; @@ -41,28 +40,28 @@ public class MenuFullModel implements Serializable { /** 上级菜单ID */ @ApiModelProperty(value = "上级菜单ID") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(19) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(19) private String parentId; /** 菜单名称 */ @ApiModelProperty(value = "菜单名称") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(100) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(100) private String title; /** 模块名 */ @ApiModelProperty(value = "模块名") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(40) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(40) private String moduleName; /** 子模块名 */ @ApiModelProperty(value = "子模块名") @ExcelIgnore - @ValidationArgsLenMax(40) + @ValidatorLenMax(40) private String subModuleName; } diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/menu/MenuModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/menu/MenuModel.java index d26446d..520e6bb 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/menu/MenuModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/menu/MenuModel.java @@ -16,16 +16,13 @@ package org.opsli.api.wrapper.system.menu; import com.alibaba.excel.annotation.ExcelIgnore; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; -import org.opsli.plugins.excel.annotation.ExcelInfo; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; /** * 菜单表 @@ -40,70 +37,70 @@ public class MenuModel extends ApiWrapper { /** 父级主键 */ @ApiModelProperty(value = "父级主键") @ExcelIgnore - @ValidationArgsLenMax(20) + @ValidatorLenMax(20) private String parentId; /** 权限编号 */ @ApiModelProperty(value = "权限编号") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_GENERAL}) + @ValidatorLenMax(50) private String permissions; /** 菜单名称 */ @ApiModelProperty(value = "名称") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(50) private String menuName; /** 图标 */ @ApiModelProperty(value = "图标") @ExcelIgnore - @ValidationArgsLenMax(50) + @ValidatorLenMax(50) private String icon; /** 项目类型: 1-菜单 2-按钮 3-链接 */ @ApiModelProperty(value = "项目类型") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(20) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(20) private String type; /** url地址 */ @ApiModelProperty(value = "url地址") @ExcelIgnore - @ValidationArgsLenMax(200) + @ValidatorLenMax(200) private String url; /** 组件 - vue 对应组件 */ @ApiModelProperty(value = "组件") @ExcelIgnore - @ValidationArgsLenMax(200) + @ValidatorLenMax(200) private String component; /** 重定向 */ @ApiModelProperty(value = "重定向") @ExcelIgnore - @ValidationArgsLenMax(200) + @ValidatorLenMax(200) private String redirect; /** 排序 */ @ApiModelProperty(value = "排序") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) + @Validator({ValidatorType.IS_NOT_NULL}) private Integer sortNo; /** 是否隐藏 0为否 1为是 */ @ApiModelProperty(value = "是否隐藏") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) + @Validator({ValidatorType.IS_NOT_NULL}) private String hidden; /** 是否总是显示 0为否 1为是 */ @ApiModelProperty(value = "是否隐藏") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) + @Validator({ValidatorType.IS_NOT_NULL}) private String alwaysShow; } diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/options/OptionsModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/options/OptionsModel.java index 1658f6b..f7474ed 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/options/OptionsModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/options/OptionsModel.java @@ -22,9 +22,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -44,36 +44,36 @@ public class OptionsModel extends ApiWrapper { @ApiModelProperty(value = "参数编号") @ExcelProperty(value = "参数编号", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(100) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(100) private String optionCode; /** 参数名称 */ @ApiModelProperty(value = "参数名称") @ExcelProperty(value = "参数名称", order = 2) @ExcelInfo - @ValidationArgsLenMax(200) + @ValidatorLenMax(200) private String optionName; /** 参数值 */ @ApiModelProperty(value = "参数值") @ExcelProperty(value = "参数值", order = 3) @ExcelInfo - @ValidationArgsLenMax(10000) + @ValidatorLenMax(10000) private String optionValue; /** 是否内置数据 0否 1是*/ @ApiModelProperty(value = "是否内置数据 0否 1是") @ExcelProperty(value = "是否内置数据", order = 4) @ExcelInfo(dictType = "no_yes") - @ValidationArgsLenMax(1) + @ValidatorLenMax(1) private String izLock; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelProperty(value = "备注", order = 5) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; } diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/org/SysOrgModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/org/SysOrgModel.java index 4438084..9e339d5 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/org/SysOrgModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/org/SysOrgModel.java @@ -22,9 +22,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -41,44 +41,44 @@ public class SysOrgModel extends ApiWrapper { @ApiModelProperty(value = "父级主键") @ExcelProperty(value = "父级主键", order = 1) @ExcelInfo - @ValidationArgsLenMax(19) + @ValidatorLenMax(19) private String parentId; /** 组织机构编号 */ @ApiModelProperty(value = "组织机构编号") @ExcelProperty(value = "组织机构编号", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(120) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(120) private String orgCode; /** 组织机构名称 */ @ApiModelProperty(value = "组织机构名称") @ExcelProperty(value = "组织机构名称", order = 3) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(120) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(120) private String orgName; /** 组织机构类型 1-公司 2-部门 3-岗位*/ @ApiModelProperty(value = "组织机构类型") @ExcelProperty(value = "组织机构类型", order = 4) @ExcelInfo( dictType = "org_type") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(3) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(3) private String orgType; /** 排序 */ @ApiModelProperty(value = "排序") @ExcelProperty(value = "排序", order = 5) @ExcelInfo - @ValidationArgsLenMax(10) + @ValidatorLenMax(10) private Integer sortNo; /** 多租户字段 */ @ApiModelProperty(value = "多租户ID") @ExcelIgnore - @ValidationArgsLenMax(20) + @ValidatorLenMax(20) private String tenantId; } diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/role/RoleMenuRefModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/role/RoleMenuRefModel.java index 01b1061..9adffae 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/role/RoleMenuRefModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/role/RoleMenuRefModel.java @@ -19,9 +19,9 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import java.io.Serializable; @@ -38,8 +38,8 @@ public class RoleMenuRefModel implements Serializable { /** 角色ID */ @ApiModelProperty(value = "角色ID") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(50) private String roleId; /** 权限数组 */ diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/role/RoleModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/role/RoleModel.java index 6a098ab..4b70cf9 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/role/RoleModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/role/RoleModel.java @@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -40,38 +40,38 @@ public class RoleModel extends ApiWrapper { @ApiModelProperty(value = "角色编码") @ExcelProperty(value = "角色编码", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(50) private String roleCode; /** 角色名称 */ @ApiModelProperty(value = "角色编码") @ExcelProperty(value = "角色编码", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(50) private String roleName; /** 是否内置数据 0否 1是*/ @ApiModelProperty(value = "是否内置数据 0否 1是") @ExcelProperty(value = "是否内置数据", order = 3) @ExcelInfo(dictType = "no_yes") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(1) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(1) private String izLock; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelProperty(value = "备注", order = 4) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; /** 多租户字段 */ @ApiModelProperty(value = "多租户ID") @ExcelIgnore - @ValidationArgsLenMax(20) + @ValidatorLenMax(20) private String tenantId; } diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/tenant/TenantModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/tenant/TenantModel.java index ebf11cc..0b4b858 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/tenant/TenantModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/tenant/TenantModel.java @@ -20,9 +20,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -40,23 +40,23 @@ public class TenantModel extends ApiWrapper { @ApiModelProperty(value = "租户名称") @ExcelProperty(value = "租户名称", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(50) private String tenantName; /** 是否启用 0否 1是*/ @ApiModelProperty(value = "是否启用") @ExcelProperty(value = "是否启用", order = 2) @ExcelInfo(dictType = "no_yes") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(1) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(1) private String enable; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelProperty(value = "备注", order = 3) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserAndOrgModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserAndOrgModel.java index e6f860f..362f93f 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserAndOrgModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserAndOrgModel.java @@ -21,10 +21,10 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.annotation.validation.ValidationArgsLenMin; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.annotation.validator.ValidatorLenMin; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -41,100 +41,100 @@ public class UserAndOrgModel extends ApiWrapper { /** 登录账户 */ @ApiModelProperty(value = "登录账户") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(32) - @ValidationArgsLenMin(5) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(32) + @ValidatorLenMin(5) private String username; /** 登录密码 */ @ApiModelProperty(value = "登录密码") @ExcelIgnore - @ValidationArgsLenMin(6) - @ValidationArgsLenMax(50) + @ValidatorLenMin(6) + @ValidatorLenMax(50) private String password; /** 登录密码强度 */ @ApiModelProperty(value = "登录密码强度") @ExcelIgnore - @ValidationArgsLenMin(1) - @ValidationArgsLenMax(1) + @ValidatorLenMin(1) + @ValidatorLenMax(1) private String passwordLevel; /** 盐值,密码秘钥 */ @ApiModelProperty(value = "盐值,密码秘钥") @ExcelIgnore - @ValidationArgsLenMax(50) + @ValidatorLenMax(50) private String secretKey; /** 启用状态 */ @ApiModelProperty(value = "启用状态") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(1) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(1) private String enable; /** 真实姓名 */ @ApiModelProperty(value = "真实姓名") @ExcelProperty(value = "真实姓名", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(50) private String realName; /** 手机 */ @ApiModelProperty(value = "手机") @ExcelProperty(value = "手机", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_MOBILE}) + @Validator({ValidatorType.IS_MOBILE}) private String mobile; /** 邮箱 */ @ApiModelProperty(value = "邮箱") @ExcelProperty(value = "邮箱", order = 3) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_EMAIL}) - @ValidationArgsLenMax(100) + @Validator({ValidatorType.IS_EMAIL}) + @ValidatorLenMax(100) private String email; /** 工号 */ @ApiModelProperty(value = "工号") @ExcelProperty(value = "工号", order = 4) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(32) + @Validator({ValidatorType.IS_GENERAL}) + @ValidatorLenMax(32) private String no; /** 头像 */ @ApiModelProperty(value = "头像") @ExcelIgnore - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String avatar; /** 最后登陆IP */ @ApiModelProperty(value = "最后登陆IP") @ExcelIgnore - @ValidationArgs(ValiArgsType.IS_IPV4) + @Validator(ValidatorType.IS_IPV4) private String loginIp; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelProperty(value = "备注", order = 5) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; /** 签名 */ @ApiModelProperty(value = "签名") @ExcelProperty(value = "签名", order = 5) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String sign; /** 多租户字段 */ @ApiModelProperty(value = "多租户ID") @ExcelIgnore - @ValidationArgsLenMax(20) + @ValidatorLenMax(20) private String tenantId; /** 组织机构 */ diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserInfo.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserInfo.java index e8f21f4..6b432b3 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserInfo.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserInfo.java @@ -16,15 +16,14 @@ package org.opsli.api.wrapper.system.user; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.annotation.validation.ValidationArgsLenMin; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.annotation.validator.ValidatorLenMin; +import org.opsli.common.enums.ValidatorType; import java.util.List; @@ -42,46 +41,46 @@ public class UserInfo extends ApiWrapper { /** 登录账户 */ @ApiModelProperty(value = "登录账户") - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(32) - @ValidationArgsLenMin(5) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(32) + @ValidatorLenMin(5) private String username; /** 真实姓名 */ @ApiModelProperty(value = "真实姓名") - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(50) private String realName; /** 手机 */ @ApiModelProperty(value = "手机") - @ValidationArgs({ValiArgsType.IS_MOBILE}) + @Validator({ValidatorType.IS_MOBILE}) private String mobile; /** 邮箱 */ @ApiModelProperty(value = "邮箱") - @ValidationArgs({ValiArgsType.IS_EMAIL}) + @Validator({ValidatorType.IS_EMAIL}) private String email; /** 工号 */ @ApiModelProperty(value = "工号") - @ValidationArgs({ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(32) + @Validator({ValidatorType.IS_GENERAL}) + @ValidatorLenMax(32) private String no; /** 头像 */ @ApiModelProperty(value = "头像") - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String avatar; /** 备注 */ @ApiModelProperty(value = "备注") - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; /** 签名 */ @ApiModelProperty(value = "签名") - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String sign; /** 角色列表 */ diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserModel.java index 2f51c44..b3112ba 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserModel.java @@ -21,10 +21,10 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.annotation.validation.ValidationArgsLenMin; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.annotation.validator.ValidatorLenMin; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -40,99 +40,99 @@ public class UserModel extends ApiWrapper { /** 登录账户 */ @ApiModelProperty(value = "登录账户") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(32) - @ValidationArgsLenMin(5) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(32) + @ValidatorLenMin(5) private String username; /** 登录密码 */ @ApiModelProperty(value = "登录密码") @ExcelIgnore - @ValidationArgsLenMin(6) - @ValidationArgsLenMax(50) + @ValidatorLenMin(6) + @ValidatorLenMax(50) private String password; /** 登录密码强度 */ @ApiModelProperty(value = "登录密码强度") @ExcelIgnore - @ValidationArgsLenMin(1) - @ValidationArgsLenMax(1) + @ValidatorLenMin(1) + @ValidatorLenMax(1) private String passwordLevel; /** 盐值,密码秘钥 */ @ApiModelProperty(value = "盐值,密码秘钥") @ExcelIgnore - @ValidationArgsLenMax(50) + @ValidatorLenMax(50) private String secretKey; /** 是否启用 */ @ApiModelProperty(value = "是否启用") @ExcelIgnore - @ValidationArgsLenMax(1) + @ValidatorLenMax(1) private String enable; /** 真实姓名 */ @ApiModelProperty(value = "真实姓名") @ExcelProperty(value = "真实姓名", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL_WITH_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL_WITH_CHINESE}) + @ValidatorLenMax(50) private String realName; /** 手机 */ @ApiModelProperty(value = "手机") @ExcelProperty(value = "手机", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_MOBILE}) + @Validator({ValidatorType.IS_MOBILE}) private String mobile; /** 邮箱 */ @ApiModelProperty(value = "邮箱") @ExcelProperty(value = "邮箱", order = 3) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_EMAIL}) - @ValidationArgsLenMax(100) + @Validator({ValidatorType.IS_EMAIL}) + @ValidatorLenMax(100) private String email; /** 工号 */ @ApiModelProperty(value = "工号") @ExcelProperty(value = "工号", order = 4) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(32) + @Validator({ValidatorType.IS_GENERAL}) + @ValidatorLenMax(32) private String no; /** 头像 */ @ApiModelProperty(value = "头像") @ExcelIgnore - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String avatar; /** 最后登陆IP */ @ApiModelProperty(value = "最后登陆IP") @ExcelIgnore - @ValidationArgs(ValiArgsType.IS_IPV4) + @Validator(ValidatorType.IS_IPV4) private String loginIp; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelProperty(value = "备注", order = 5) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; /** 签名 */ @ApiModelProperty(value = "签名") @ExcelProperty(value = "签名", order = 5) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String sign; /** 多租户字段 */ @ApiModelProperty(value = "多租户ID") @ExcelIgnore - @ValidationArgsLenMax(20) + @ValidatorLenMax(20) private String tenantId; diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserOrgRefModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserOrgRefModel.java index 2faa8f7..b9c343e 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserOrgRefModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserOrgRefModel.java @@ -19,9 +19,9 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import java.io.Serializable; @@ -38,27 +38,27 @@ public class UserOrgRefModel implements Serializable { /** 用户ID */ @ApiModelProperty(value = "用户ID") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(50) private String userId; @ApiModelProperty(value = "公司") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(19) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(19) private String companyId; @ApiModelProperty(value = "公司名称") private String companyName; @ApiModelProperty(value = "部门ID") - @ValidationArgsLenMax(19) + @ValidatorLenMax(19) private String departmentId; @ApiModelProperty(value = "部门名称") private String departmentName; @ApiModelProperty(value = "岗位ID") - @ValidationArgsLenMax(19) + @ValidatorLenMax(19) private String postId; @ApiModelProperty(value = "岗位名称") diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserPassword.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserPassword.java index 9531c4c..c685c0c 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserPassword.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserPassword.java @@ -20,10 +20,10 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.annotation.validation.ValidationArgsLenMin; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.annotation.validator.ValidatorLenMin; +import org.opsli.common.enums.ValidatorType; import java.io.Serializable; @@ -46,29 +46,29 @@ public class UserPassword implements Serializable { /** 旧密码 */ @ApiModelProperty(value = "旧密码") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMin(6) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMin(6) + @ValidatorLenMax(50) private String oldPassword; /** 新密码 */ @ApiModelProperty(value = "新密码") - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_SECURITY_PASSWORD}) - @ValidationArgsLenMin(6) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_SECURITY_PASSWORD}) + @ValidatorLenMin(6) + @ValidatorLenMax(50) private String newPassword; /** 盐值,密码秘钥 前端不可改*/ @ApiModelProperty(value = "盐值,密码秘钥 前端不可改") @ExcelIgnore - @ValidationArgsLenMax(50) + @ValidatorLenMax(50) private String salt; /** 登录密码强度 前端不可改 */ @ApiModelProperty(value = "登录密码强度 前端不可改") @ExcelIgnore - @ValidationArgsLenMin(1) - @ValidationArgsLenMax(1) + @ValidatorLenMin(1) + @ValidatorLenMax(1) private String passwordLevel; } diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserRoleRefModel.java b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserRoleRefModel.java index d0dd74f..12ed8d5 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserRoleRefModel.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/system/user/UserRoleRefModel.java @@ -19,9 +19,9 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import java.io.Serializable; @@ -38,8 +38,8 @@ public class UserRoleRefModel implements Serializable { /** 用户ID */ @ApiModelProperty(value = "用户ID") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(50) private String userId; /** 角色数组 */ diff --git a/opsli-api/src/main/java/org/opsli/api/wrapper/testt/Test3Model.java b/opsli-api/src/main/java/org/opsli/api/wrapper/testt/Test3Model.java index 9a14607..d86a856 100644 --- a/opsli-api/src/main/java/org/opsli/api/wrapper/testt/Test3Model.java +++ b/opsli-api/src/main/java/org/opsli/api/wrapper/testt/Test3Model.java @@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.format.annotation.DateTimeFormat; @@ -42,24 +42,24 @@ public class Test3Model extends ApiWrapper { @ApiModelProperty(value = "金钱") @ExcelProperty(value = "金钱", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_MONEY}) - @ValidationArgsLenMax(10) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_MONEY}) + @ValidatorLenMax(10) private Double money; /** 年龄 */ @ApiModelProperty(value = "年龄") @ExcelProperty(value = "年龄", order = 2) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_INTEGER}) - @ValidationArgsLenMax(3) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_INTEGER}) + @ValidatorLenMax(3) private Integer age; /** 名称 */ @ApiModelProperty(value = "名称") @ExcelProperty(value = "名称", order = 3) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_CHINESE}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_CHINESE}) + @ValidatorLenMax(50) private String name; /** 生日 */ @@ -74,7 +74,7 @@ public class Test3Model extends ApiWrapper { @ApiModelProperty(value = "是否启用") @ExcelProperty(value = "是否启用", order = 5) @ExcelInfo( dictType = "no_yes" ) - @ValidationArgsLenMax(1) + @ValidatorLenMax(1) private String izUsable; diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgs.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/Validator.java similarity index 84% rename from opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgs.java rename to opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/Validator.java index 86d4330..2eecf7d 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgs.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/Validator.java @@ -13,9 +13,9 @@ * License for the specific language governing permissions and limitations under * 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.*; @@ -28,8 +28,8 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @Documented -public @interface ValidationArgs { +public @interface Validator { - ValiArgsType[] value(); + ValidatorType[] value(); } diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgsLenMax.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/ValidatorLenMax.java similarity index 91% rename from opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgsLenMax.java rename to opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/ValidatorLenMax.java index 27300ac..b39b777 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgsLenMax.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/ValidatorLenMax.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.opsli.common.annotation.validation; +package org.opsli.common.annotation.validator; import java.lang.annotation.*; @@ -28,7 +28,7 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @Documented -public @interface ValidationArgsLenMax { +public @interface ValidatorLenMax { int value(); diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgsLenMin.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/ValidatorLenMin.java similarity index 91% rename from opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgsLenMin.java rename to opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/ValidatorLenMin.java index e17a51a..b178aed 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validation/ValidationArgsLenMin.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/annotation/validator/ValidatorLenMin.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.opsli.common.annotation.validation; +package org.opsli.common.annotation.validator; import java.lang.annotation.*; @@ -28,7 +28,7 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @Documented -public @interface ValidationArgsLenMin { +public @interface ValidatorLenMin { int value(); diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/constants/OrderConstants.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/constants/OrderConstants.java index 2d8083b..dff09a5 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/constants/OrderConstants.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/constants/OrderConstants.java @@ -39,7 +39,7 @@ public interface OrderConstants { int HOT_DATA_ORDER = 180; /** 参数非法验证顺序 */ - int PARAM_VALIDATE_AOP_SORT = 185; + int VERIFY_ARGS_AOP_SORT = 185; /** 搜索历史 */ int SEARCH_HIS_AOP_SORT = 186; diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/enums/ValiArgsType.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/enums/ValidatorType.java similarity index 98% rename from opsli-base-support/opsli-common/src/main/java/org/opsli/common/enums/ValiArgsType.java rename to opsli-base-support/opsli-common/src/main/java/org/opsli/common/enums/ValidatorType.java index 7128c76..0917730 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/enums/ValiArgsType.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/enums/ValidatorType.java @@ -22,7 +22,7 @@ package org.opsli.common.enums; * @author Parker * @date 2020-09-17 23:40 */ -public enum ValiArgsType { +public enum ValidatorType { /** 不能为空 */ IS_NOT_NULL, diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/msg/ValidationMsg.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/msg/ValidatorMsg.java similarity index 96% rename from opsli-base-support/opsli-core/src/main/java/org/opsli/core/msg/ValidationMsg.java rename to opsli-base-support/opsli-common/src/main/java/org/opsli/common/msg/ValidatorMsg.java index 8f4a23f..f62ea26 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/msg/ValidationMsg.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/msg/ValidatorMsg.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.opsli.core.msg; +package org.opsli.common.msg; import org.opsli.common.base.msg.BaseMsg; @@ -23,7 +23,7 @@ import org.opsli.common.base.msg.BaseMsg; * @author Parker * @date 2020-09-13 19:36 */ -public enum ValidationMsg implements BaseMsg { +public enum ValidatorMsg implements BaseMsg { /** 不能为空 */ EXCEPTION_IS_NOT_NULL(9800,"不能为空! "), @@ -84,7 +84,7 @@ public enum ValidationMsg implements BaseMsg { private final String message; private String fieldName; - ValidationMsg(int code, String message){ + ValidatorMsg(int code, String message){ this.code = code; this.message = message; } diff --git a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/HumpUtil.java b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/FieldUtil.java similarity index 70% rename from opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/HumpUtil.java rename to opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/FieldUtil.java index e7ae571..9dc1efe 100644 --- a/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/HumpUtil.java +++ b/opsli-base-support/opsli-common/src/main/java/org/opsli/common/utils/FieldUtil.java @@ -15,18 +15,17 @@ */ package org.opsli.common.utils; +import org.springframework.util.StringUtils; + /** - * 驼峰转换 + * 字段处理工具类 * * @author Parker * @date 2020-09-19 23:21 */ -public final class HumpUtil { - - private final static String UNDERLINE = "_"; +public final class FieldUtil { - - private HumpUtil(){} + public final static String UNDERLINE = "_"; /*** @@ -75,21 +74,35 @@ public final class HumpUtil { } /** - * 首字母大写 + * 将第一个字母转换成大写 + * * @param str 字符串 - * @return String + * @return 返回新字段 */ - public static String captureName(String str) { - char[] cs = str.toCharArray(); - cs[0] -= 32; - return String.valueOf(cs); + public static String upperFirstLetter(String str) { + if (StringUtils.hasText(str)) { + String firstUpper = str.substring(0, 1).toUpperCase(); + 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); - System.out.println(bb); + /** + * 将第一个字母转换成小写 + * + * @param str 字符串 + * @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(){} + } diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/autoconfigure/conf/ShiroConfig.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/autoconfigure/conf/ShiroConfig.java index c7c009f..1322480 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/autoconfigure/conf/ShiroConfig.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/autoconfigure/conf/ShiroConfig.java @@ -129,8 +129,9 @@ public class ShiroConfig { List realms = Lists.newArrayList(); // 拿到state包下 实现了 FlagRealm 接口的,所有子类 - Set> clazzSet = ClassUtil.scanPackageBySuper(FlagRealm.class.getPackage().getName() - , FlagRealm.class + Set> clazzSet = ClassUtil.scanPackageBySuper( + FlagRealm.class.getPackage().getName(), + FlagRealm.class ); for (Class aClass : clazzSet) { // 位运算 去除抽象类 diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/receiver/RedisPushSubReceiver.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/receiver/RedisPushSubReceiver.java index 603f771..ab48625 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/receiver/RedisPushSubReceiver.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/cache/pushsub/receiver/RedisPushSubReceiver.java @@ -71,8 +71,9 @@ public class RedisPushSubReceiver extends BaseReceiver { public void initRedisPushSubHandler(){ // 拿到state包下 实现了 SystemEventState 接口的,所有子类 - Set> clazzSet = ClassUtil.scanPackageBySuper(RedisPushSubHandler.class.getPackage().getName() - , RedisPushSubHandler.class + Set> clazzSet = ClassUtil.scanPackageBySuper( + RedisPushSubHandler.class.getPackage().getName(), + RedisPushSubHandler.class ); for (Class aClass : clazzSet) { diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ValitaionArgsAop.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ValidatorAop.java similarity index 92% rename from opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ValitaionArgsAop.java rename to opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ValidatorAop.java index c05f217..49d37a0 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ValitaionArgsAop.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/filters/aspect/ValidatorAop.java @@ -21,7 +21,7 @@ import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; 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.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -31,7 +31,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; 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 */ @Slf4j -@Order(PARAM_VALIDATE_AOP_SORT) +@Order(VERIFY_ARGS_AOP_SORT) @Aspect @Component -public class ValitaionArgsAop { +public class ValidatorAop { /** post请求 */ private static final String POST_TYPE = "POST"; @@ -76,7 +76,7 @@ public class ValitaionArgsAop { ApiWrapper apiWrapper = (ApiWrapper) arg; // 如果是内部调用 则不判断参数非法情况 if(apiWrapper.getIzApi() != null && !apiWrapper.getIzApi()){ - ValidationUtil.verify(arg); + ValidatorUtil.verify(arg); } } } diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/querybuilder/WebQueryBuilder.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/querybuilder/WebQueryBuilder.java index 517b918..5da15a9 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/querybuilder/WebQueryBuilder.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/querybuilder/WebQueryBuilder.java @@ -19,7 +19,7 @@ import cn.hutool.core.util.ReflectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.commons.lang3.StringUtils; 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.persistence.querybuilder.conf.WebQueryConf; @@ -173,7 +173,7 @@ public class WebQueryBuilder implements QueryBuilder{ key = keyStr; }else{ // 转换驼峰 为 数据库下划线字段 - key = HumpUtil.humpToUnderline(key); + key = FieldUtil.humpToUnderline(key); } queryWrapper.orderByDesc(key); @@ -205,7 +205,7 @@ public class WebQueryBuilder implements QueryBuilder{ key = keyStr; }else{ // 转换驼峰 为 数据库下划线字段 - key = HumpUtil.humpToUnderline(key); + key = FieldUtil.humpToUnderline(key); } switch (handle) { diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/querybuilder/chain/TenantHandler.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/querybuilder/chain/TenantHandler.java index d29d199..df81d40 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/querybuilder/chain/TenantHandler.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/querybuilder/chain/TenantHandler.java @@ -20,7 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.commons.lang3.StringUtils; import org.opsli.api.wrapper.system.user.UserModel; 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.utils.UserUtil; @@ -59,7 +59,7 @@ public class TenantHandler implements QueryBuilderChain{ if(!UserUtil.SUPER_ADMIN.equals(user.getUsername()) && StringUtils.isNotEmpty(tenantId) ){ - wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT), tenantId); + wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT), tenantId); } } diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/ValidationUtil.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/ValidatorUtil.java similarity index 70% rename from opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/ValidationUtil.java rename to opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/ValidatorUtil.java index 9d570bf..9a5f622 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/ValidationUtil.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/utils/ValidatorUtil.java @@ -16,19 +16,17 @@ package org.opsli.core.utils; import cn.hutool.core.convert.Convert; -import cn.hutool.core.lang.Validator; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ReflectUtil; import io.swagger.annotations.ApiModelProperty; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; 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.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.annotation.validation.ValidationArgsLenMin; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.annotation.validator.ValidatorLenMin; import org.opsli.common.exception.ServiceException; import java.lang.reflect.Field; @@ -41,7 +39,7 @@ import java.nio.charset.StandardCharsets; * @date 2020-09-19 20:03 */ @Slf4j -public final class ValidationUtil { +public final class ValidatorUtil { /** * 验证对象 @@ -55,27 +53,27 @@ public final class ValidationUtil { Field[] fields = ReflectUtil.getFields(obj.getClass()); for (Field field : fields) { // 获得 统一验证 注解 - ValidationArgs validationArgs = field.getAnnotation(ValidationArgs.class); - if (validationArgs != null) { - ValiArgsType[] types = validationArgs.value(); + Validator validator = field.getAnnotation(Validator.class); + if (validator != null) { + org.opsli.common.enums.ValidatorType[] types = validator.value(); 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) { int maxLength = validationArgsMax.value(); 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) { int minLength = validationArgsMin.value(); 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 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(); ApiModelProperty annotation = field.getAnnotation(ApiModelProperty.class); @@ -97,15 +95,15 @@ public final class ValidationUtil { String value = Convert.toStr(fieldValue); // 循环验证 - for (ValiArgsType type : types) { + for (org.opsli.common.enums.ValidatorType type : types) { try { - boolean validateRet; + boolean verifyRet; switch (type) { // 不能为空 case IS_NOT_NULL: { - validateRet = Validator.isNotEmpty(fieldValue); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_NOT_NULL; + verifyRet = cn.hutool.core.lang.Validator.isNotEmpty(fieldValue); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_NOT_NULL; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -116,9 +114,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isGeneral(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_GENERAL; + verifyRet = cn.hutool.core.lang.Validator.isGeneral(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_GENERAL; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -129,9 +127,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = NumberUtil.isInteger(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_INTEGER; + verifyRet = NumberUtil.isInteger(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_INTEGER; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -142,9 +140,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = NumberUtil.isDouble(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_DECIMAL; + verifyRet = NumberUtil.isDouble(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_DECIMAL; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -156,10 +154,10 @@ public final class ValidationUtil { break; } // 先验证 是否是 整数, 再验证是否是 质数 - validateRet = NumberUtil.isInteger(value) && + verifyRet = NumberUtil.isInteger(value) && NumberUtil.isPrimes(Convert.toInt(value)); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_PRIMES; + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_PRIMES; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -170,9 +168,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isLetter(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_LETTER; + verifyRet = cn.hutool.core.lang.Validator.isLetter(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_LETTER; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -183,9 +181,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isUpperCase(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_UPPER_CASE; + verifyRet = cn.hutool.core.lang.Validator.isUpperCase(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_UPPER_CASE; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -196,9 +194,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isLowerCase(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_LOWER_CASE; + verifyRet = cn.hutool.core.lang.Validator.isLowerCase(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_LOWER_CASE; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -209,9 +207,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isIpv4(value) || Validator.isIpv6(value) ; - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_IP; + verifyRet = cn.hutool.core.lang.Validator.isIpv4(value) || cn.hutool.core.lang.Validator.isIpv6(value) ; + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_IP; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -222,9 +220,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isIpv4(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_IPV4; + verifyRet = cn.hutool.core.lang.Validator.isIpv4(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_IPV4; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -235,9 +233,9 @@ public final class ValidationUtil { if(StringUtils.isEmpty(value)){ break; } - validateRet = Validator.isIpv6(value); - if(!validateRet){ - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_IPV6; + verifyRet = cn.hutool.core.lang.Validator.isIpv6(value); + if(!verifyRet){ + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_IPV6; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -248,9 +246,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isMoney(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MONEY; + verifyRet = cn.hutool.core.lang.Validator.isMoney(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MONEY; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -261,9 +259,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isEmail(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_EMAIL; + verifyRet = cn.hutool.core.lang.Validator.isEmail(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_EMAIL; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -274,9 +272,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isMobile(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MOBILE; + verifyRet = cn.hutool.core.lang.Validator.isMobile(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MOBILE; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -287,9 +285,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isCitizenId(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_CITIZENID; + verifyRet = cn.hutool.core.lang.Validator.isCitizenId(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_CITIZENID; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -300,9 +298,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isZipCode(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_ZIPCODE; + verifyRet = cn.hutool.core.lang.Validator.isZipCode(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_ZIPCODE; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -313,9 +311,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isUrl(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_URL; + verifyRet = cn.hutool.core.lang.Validator.isUrl(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_URL; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -326,9 +324,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isChinese(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_CHINESE; + verifyRet = cn.hutool.core.lang.Validator.isChinese(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_CHINESE; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -339,9 +337,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isGeneralWithChinese(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_GENERAL_WITH_CHINESE; + verifyRet = cn.hutool.core.lang.Validator.isGeneralWithChinese(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_GENERAL_WITH_CHINESE; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -352,9 +350,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isMac(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MAC; + verifyRet = cn.hutool.core.lang.Validator.isMac(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MAC; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -365,9 +363,9 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isPlateNumber(value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_PLATE_NUMBER; + verifyRet = cn.hutool.core.lang.Validator.isPlateNumber(value); + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_PLATE_NUMBER; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -378,10 +376,10 @@ public final class ValidationUtil { if (StringUtils.isEmpty(value)) { break; } - validateRet = Validator.isMatchRegex( + verifyRet = cn.hutool.core.lang.Validator.isMatchRegex( DefPatternPool.SECURITY_PASSWORD, value); - if (!validateRet) { - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_SECURITY_PASSWORD; + if (!verifyRet) { + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_SECURITY_PASSWORD; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -420,7 +418,7 @@ public final class ValidationUtil { // 转换为 数据库真实 长度 int strLength = value.getBytes(StandardCharsets.UTF_8).length; if(strLength > maxLength){ - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MAX; + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MAX; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -453,7 +451,7 @@ public final class ValidationUtil { // 转换为 数据库真实 长度 int strLength = value.getBytes(StandardCharsets.UTF_8).length; if(strLength < minLength){ - ValidationMsg msg = ValidationMsg.EXCEPTION_IS_MIN; + ValidatorMsg msg = ValidatorMsg.EXCEPTION_IS_MIN; msg.setFieldName(fieldName); throw new ServiceException(msg); } @@ -472,12 +470,12 @@ public final class ValidationUtil { dictModel.setRemark("测试11232131231231223123"); dictModel.setIzLock("1"); - ValidationUtil.verify(dictModel); + ValidatorUtil.verify(dictModel); } // ================ - private ValidationUtil(){} + private ValidatorUtil(){} } diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/email/service/impl/EmailServiceImpl.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/email/service/impl/EmailServiceImpl.java index ed80e7f..74653b5 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/email/service/impl/EmailServiceImpl.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/email/service/impl/EmailServiceImpl.java @@ -6,7 +6,7 @@ import cn.hutool.extra.mail.MailUtil; import org.opsli.api.wrapper.system.options.OptionsModel; import org.opsli.common.enums.DictType; 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.service.IEmailService; import org.opsli.plugins.email.wrapper.EmailModel; @@ -52,7 +52,7 @@ public class EmailServiceImpl implements IEmailService { emailModel.setTo(to); emailModel.setSubject(subject); emailModel.setContent(content); - ValidationUtil.verify(emailModel); + ValidatorUtil.verify(emailModel); } // 获得配置信息 diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/email/wrapper/EmailModel.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/email/wrapper/EmailModel.java index 3d511a4..bbb4a07 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/email/wrapper/EmailModel.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/email/wrapper/EmailModel.java @@ -3,9 +3,9 @@ package org.opsli.plugins.email.wrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; /** * 邮件服务 @@ -20,19 +20,19 @@ public class EmailModel { /** 收件人 */ @ApiModelProperty(value = "收件人") - @ValidationArgs({ValiArgsType.IS_EMAIL, ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(200) + @Validator({ValidatorType.IS_EMAIL, ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(200) private String to; /** 主题 */ @ApiModelProperty(value = "主题") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(200) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(200) private String subject; /** 内容 */ @ApiModelProperty(value = "内容") - @ValidationArgsLenMax(20000) + @ValidatorLenMax(20000) private String content; diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/oss/OssStorageFactory.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/oss/OssStorageFactory.java index 1627fc5..d2b2109 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/oss/OssStorageFactory.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/oss/OssStorageFactory.java @@ -83,7 +83,7 @@ public enum OssStorageFactory { // 拿到实现了 OssStorageService 接口的,所有子类 Set> clazzSet = ClassUtil.scanPackageBySuper( - OssStorageService.class.getPackage().getName()+".impl", + OssStorageService.class.getPackage().getName(), OssStorageService.class ); diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/oss/factory/LocalConfigFactory.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/oss/factory/LocalConfigFactory.java index edcbec1..eeb93b5 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/oss/factory/LocalConfigFactory.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/plugins/oss/factory/LocalConfigFactory.java @@ -18,9 +18,9 @@ package org.opsli.plugins.oss.factory; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.opsli.common.annotation.OptionDict; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.core.utils.OptionsUtil; import java.io.Serializable; @@ -64,14 +64,14 @@ public enum LocalConfigFactory implements ConfigFactoryopsli-modulars-generator + + com.baomidou + mybatis-plus-generator + 3.4.1 + + + + org.apache.velocity + velocity-engine-core + 2.3 + + com.jfinal enjoy diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/mysql/enums/MySQLSyncColumnType.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/mysql/enums/MySQLSyncColumnType.java deleted file mode 100644 index c057af5..0000000 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/mysql/enums/MySQLSyncColumnType.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com - *

- * 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 - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * 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 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); - } - -} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/column/service/impl/GenTableColumnServiceImpl.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/column/service/impl/GenTableColumnServiceImpl.java index 8e2c241..b3d881c 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/column/service/impl/GenTableColumnServiceImpl.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/column/service/impl/GenTableColumnServiceImpl.java @@ -19,11 +19,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.commons.lang3.StringUtils; import org.opsli.common.constants.MyBatisConstants; import org.opsli.core.base.service.impl.CrudServiceImpl; -import org.opsli.core.generator.exception.GeneratorException; -import org.opsli.core.generator.msg.GeneratorMsg; +import org.opsli.plugins.generator.exception.GeneratorException; +import org.opsli.plugins.generator.msg.GeneratorMsg; import org.opsli.core.persistence.querybuilder.GenQueryBuilder; 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.mapper.GenTableColumnMapper; import org.opsli.modulars.generator.column.service.IGenTableColumnService; @@ -52,7 +52,7 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl validateTypeList; - /** 后端验证集合 */ + /** 验证集合(含逗号) */ @JsonIgnore @ExcelIgnore - private List backendValidateTypeList; - - /** 前端验证集合 */ - @JsonIgnore - @ExcelIgnore - private String frontendValidateType; - - /** 前端验证集合 */ - @JsonIgnore - @ExcelIgnore - private List frontendValidateTypeList; + private List validateTypeAndCommaList; } diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/ImportTableUtil.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/ImportTableUtil.java index 2a1115e..944529e 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/ImportTableUtil.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/ImportTableUtil.java @@ -16,13 +16,15 @@ package org.opsli.modulars.generator.importable; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ClassUtil; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; 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.modulars.generator.importable.entity.DatabaseColumn; import org.opsli.modulars.generator.importable.entity.DatabaseTable; @@ -174,6 +176,64 @@ public class ImportTableUtil{ return databaseTableService.findColumns(dataSource.getDbName(), tableName); } + /** + * 获得数据库类型下 字段类型 + * @return List + */ + public static List getFieldTypes() { + DatabaseTableService databaseTableService = getDatabaseTableService(); + if(databaseTableService == null){ + return ListUtil.empty(); + } + return databaseTableService.getFieldTypes(); + } + + /** + * 获得数据库类型下 全部类型对应Java类型 + * @return List + */ + public static Map getJavaFieldTypes() { + DatabaseTableService databaseTableService = getDatabaseTableService(); + if(databaseTableService == null){ + return Maps.newHashMap(); + } + return databaseTableService.getJavaFieldTypes(); + } + + /** + * 获得全部类型对应Java类型集合(兜底String 类型) + * @return List + */ + public static Map> getJavaFieldTypesBySafety() { + DatabaseTableService databaseTableService = getDatabaseTableService(); + if(databaseTableService == null){ + return Maps.newHashMap(); + } + return databaseTableService.getJavaFieldTypesBySafety(); + } + + /** + * 获得当前数据处理Service + * @return DatabaseTableService + */ + private static DatabaseTableService getDatabaseTableService(){ + Map 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(){ // 拿到state包下 实现了 SystemEventState 接口的,所有子类 - Set> clazzSet = ClassUtil.scanPackageBySuper(DatabaseTableService.class.getPackage().getName() - , DatabaseTableService.class + Set> clazzSet = ClassUtil.scanPackageBySuper( + DatabaseTableService.class.getPackage().getName(), + DatabaseTableService.class ); for (Class aClass : clazzSet) { @@ -199,7 +260,7 @@ public class ImportTableUtil{ } @Autowired - public void setDbSourceProperties(DbSourceProperties dbSourceProperties) { + public void init(DbSourceProperties dbSourceProperties) { ImportTableUtil.dbSourceProperties = dbSourceProperties; } } diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/DatabaseTableService.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/DatabaseTableService.java index 2ce5908..4c9b770 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/DatabaseTableService.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/DatabaseTableService.java @@ -15,11 +15,12 @@ */ 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.DatabaseTable; import java.util.List; +import java.util.Map; /** @@ -36,6 +37,25 @@ public interface DatabaseTableService { */ DataBaseType getType(); + /** + * 获得数据库类型下 字段类型 + * @return List + */ + List getFieldTypes(); + + /** + * 获得数据库类型下 全部类型对应Java类型 + * @return List + */ + Map getJavaFieldTypes(); + + /** + * 获得全部类型对应Java类型集合(兜底String 类型) + * @return List + */ + Map> getJavaFieldTypesBySafety(); + + /** * 获得当前库中 数据库名 * @param dbName 表名 diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/MySQLDatabaseTableServiceImpl.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/MySQLDatabaseTableServiceImpl.java index 44e2a0d..9035a74 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/MySQLDatabaseTableServiceImpl.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/MySQLDatabaseTableServiceImpl.java @@ -17,7 +17,8 @@ package org.opsli.modulars.generator.importable.service; import org.apache.commons.lang3.StringUtils; 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.DatabaseTable; 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 java.util.List; +import java.util.Map; /** @@ -56,6 +58,21 @@ public class MySQLDatabaseTableServiceImpl implements DatabaseTableService { return DataBaseType.MYSQL; } + @Override + public List getFieldTypes() { + return MySqlSyncColumnType.INSTANCE.getFieldTypes(); + } + + @Override + public Map getJavaFieldTypes() { + return MySqlSyncColumnType.INSTANCE.getJavaFieldTypes(); + } + + @Override + public Map> getJavaFieldTypesBySafety() { + return MySqlSyncColumnType.INSTANCE.getJavaFieldTypesBySafety(); + } + @Override public List findTables(String dbName) { return this.findTables(dbName, null); diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/service/impl/GenLogsServiceImpl.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/service/impl/GenLogsServiceImpl.java index 43aac3b..ed18a77 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/service/impl/GenLogsServiceImpl.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/service/impl/GenLogsServiceImpl.java @@ -23,9 +23,9 @@ import org.opsli.api.web.system.menu.MenuApi; import org.opsli.api.wrapper.system.menu.MenuFullModel; import org.opsli.common.utils.WrapperUtil; import org.opsli.core.base.service.impl.CrudServiceImpl; -import org.opsli.core.generator.exception.GeneratorException; -import org.opsli.core.generator.msg.GeneratorMsg; -import org.opsli.core.generator.strategy.create.CodeBuilder; +import org.opsli.plugins.generator.exception.GeneratorException; +import org.opsli.plugins.generator.msg.GeneratorMsg; +import org.opsli.plugins.generator.strategy.create.CodeBuilder; import org.opsli.core.persistence.Page; import org.opsli.core.persistence.querybuilder.GenQueryBuilder; import org.opsli.core.persistence.querybuilder.QueryBuilder; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/wrapper/GenLogsModel.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/wrapper/GenLogsModel.java index 98ca7cd..a1c0f8b 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/wrapper/GenLogsModel.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/wrapper/GenLogsModel.java @@ -20,9 +20,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; /** * 代码生成器 - 生成日志 模型 @@ -38,51 +38,51 @@ public class GenLogsModel extends ApiWrapper { /** 归属表ID */ @ApiModelProperty(value = "归属表ID") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(19) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(19) private String tableId; /** 包名 */ @ApiModelProperty(value = "包名") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(255) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(255) private String packageName; /** 模块名 */ @ApiModelProperty(value = "模块名") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(40) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(40) private String moduleName; /** 子模块名 */ @ApiModelProperty(value = "子模块名") @ExcelIgnore - @ValidationArgsLenMax(40) + @ValidatorLenMax(40) private String subModuleName; /** 代码标题 */ @ApiModelProperty(value = "代码标题") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(100) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(100) private String codeTitle; /** 代码标题简介 */ @ApiModelProperty(value = "代码标题简介") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(100) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(100) private String codeTitleBrief; /** 作者名 */ @ApiModelProperty(value = "作者名") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(64) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(64) private String authorName; } diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/api/TableApi.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/api/TableApi.java index 5d18a48..f6d5e8a 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/api/TableApi.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/api/TableApi.java @@ -24,6 +24,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Map; /** * 代码生成器 - 表 API @@ -121,4 +123,26 @@ public interface TableApi { @PostMapping("/importTables") ResultVo importTables(String tableNames); + /** + * 获得数据库类型下 字段类型 + * @return List + */ + @GetMapping("/getFieldTypes") + ResultVo> getFieldTypes(); + + /** + * 获得数据库类型下 全部类型对应Java类型 + * @return List + */ + @GetMapping("/getJavaFieldTypes") + ResultVo > getJavaFieldTypes(); + + /** + * 获得全部类型对应Java类型集合(兜底String 类型) + * @return List + */ + @GetMapping("/getJavaFieldTypesBySafety") + ResultVo>> getJavaFieldTypesBySafety(); + + } diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/service/impl/GenTableServiceImpl.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/service/impl/GenTableServiceImpl.java index 1c4b96f..ed31c4f 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/service/impl/GenTableServiceImpl.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/service/impl/GenTableServiceImpl.java @@ -23,8 +23,8 @@ import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.enums.DictType; import org.opsli.common.utils.WrapperUtil; import org.opsli.core.base.service.impl.CrudServiceImpl; -import org.opsli.core.generator.exception.GeneratorException; -import org.opsli.core.generator.msg.GeneratorMsg; +import org.opsli.plugins.generator.exception.GeneratorException; +import org.opsli.plugins.generator.msg.GeneratorMsg; import org.opsli.modulars.generator.column.service.IGenTableColumnService; import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; import org.opsli.modulars.generator.logs.service.IGenLogsService; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/web/GenTableRestController.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/web/GenTableRestController.java index 7ad0585..f928d30 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/web/GenTableRestController.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/web/GenTableRestController.java @@ -26,9 +26,9 @@ import org.opsli.common.annotation.EnableLog; import org.opsli.common.exception.ServiceException; import org.opsli.common.utils.WrapperUtil; import org.opsli.core.base.controller.BaseRestController; -import org.opsli.core.generator.exception.GeneratorException; -import org.opsli.core.generator.msg.GeneratorMsg; -import org.opsli.core.generator.strategy.sync.util.SqlSyncUtil; +import org.opsli.plugins.generator.exception.GeneratorException; +import org.opsli.plugins.generator.msg.GeneratorMsg; +import org.opsli.plugins.generator.SqlSyncUtil; import org.opsli.core.msg.CoreMsg; import org.opsli.core.persistence.Page; import org.opsli.core.persistence.querybuilder.QueryBuilder; @@ -45,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Map; /** @@ -254,4 +255,25 @@ public class GenTableRestController extends BaseRestController> getFieldTypes() { + return ResultVo.success(ImportTableUtil.getFieldTypes()); + } + + @ApiOperation(value = "获得数据库类型下 全部类型对应Java类型", + notes = "获得数据库类型下 全部类型对应Java类型") + @Override + public ResultVo> getJavaFieldTypes() { + return ResultVo.success(ImportTableUtil.getJavaFieldTypes()); + } + + @ApiOperation(value = "获得全部类型对应Java类型集合(兜底String 类型)", + notes = "获得全部类型对应Java类型集合(兜底String 类型)") + @Override + public ResultVo>> getJavaFieldTypesBySafety() { + return ResultVo.success(ImportTableUtil.getJavaFieldTypesBySafety()); + } } diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/wrapper/GenTableAndColumnModel.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/wrapper/GenTableAndColumnModel.java index cbc6d7a..1d99074 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/wrapper/GenTableAndColumnModel.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/wrapper/GenTableAndColumnModel.java @@ -21,12 +21,11 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; -import java.util.ArrayList; import java.util.List; /** @@ -43,8 +42,8 @@ public class GenTableAndColumnModel extends ApiWrapper { /** 表名称 */ @ApiModelProperty(value = "表名称") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(100) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(100) private String tableName; /** 旧表名称 */ @@ -55,39 +54,39 @@ public class GenTableAndColumnModel extends ApiWrapper { /** 表类型 */ @ApiModelProperty(value = "表类型") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(1) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(1) private String tableType; /** 数据库类型 */ @ApiModelProperty(value = "数据库类型") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(30) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(30) private String jdbcType; /** 描述 */ @ApiModelProperty(value = "描述") @ExcelIgnore - @ValidationArgsLenMax(200) + @ValidatorLenMax(200) private String comments; /** 同步 */ @ApiModelProperty(value = "同步") @ExcelIgnore - @ValidationArgsLenMax(1) + @ValidatorLenMax(1) private String izSync; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelIgnore - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; /** 表结构 */ @ApiModelProperty(value = "表结构") @ExcelIgnore - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) + @Validator({ValidatorType.IS_NOT_NULL}) private List columnList; // ======================= @@ -97,6 +96,11 @@ public class GenTableAndColumnModel extends ApiWrapper { @ExcelIgnore private String tableHumpName; + /** Entity 包地址 */ + @JsonIgnore + @ExcelIgnore + private List entityPkgList; + /** 前端Form集合 */ @JsonIgnore @ExcelIgnore @@ -112,9 +116,4 @@ public class GenTableAndColumnModel extends ApiWrapper { @ExcelIgnore private List moreQueryList; - /** 前端验证集合 */ - @JsonIgnore - @ExcelIgnore - private String frontendValidateType; - } diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/wrapper/GenTableModel.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/wrapper/GenTableModel.java index 72ccfec..c0d38b8 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/wrapper/GenTableModel.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/wrapper/GenTableModel.java @@ -21,9 +21,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; /** @@ -41,8 +41,8 @@ public class GenTableModel extends ApiWrapper { @ApiModelProperty(value = "表名称") @ExcelProperty(value = "表名称", order = 1) @ExcelInfo - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(100) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(100) private String tableName; /** 旧表名称 */ @@ -54,37 +54,37 @@ public class GenTableModel extends ApiWrapper { @ApiModelProperty(value = "表类型") @ExcelProperty(value = "表类型", order = 2) @ExcelInfo(dictType = "table_type") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(1) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(1) private String tableType; /** 数据库类型 */ @ApiModelProperty(value = "数据库类型") @ExcelProperty(value = "数据库类型", order = 3) @ExcelInfo(dictType = "jdbc_type") - @ValidationArgs({ValiArgsType.IS_NOT_NULL}) - @ValidationArgsLenMax(30) + @Validator({ValidatorType.IS_NOT_NULL}) + @ValidatorLenMax(30) private String jdbcType; /** 描述 */ @ApiModelProperty(value = "描述") @ExcelProperty(value = "描述", order = 4) @ExcelInfo - @ValidationArgsLenMax(200) + @ValidatorLenMax(200) private String comments; /** 同步 */ @ApiModelProperty(value = "同步") @ExcelProperty(value = "是否同步", order = 5) @ExcelInfo(dictType = "no_yes") - @ValidationArgsLenMax(1) + @ValidatorLenMax(1) private String izSync; /** 备注 */ @ApiModelProperty(value = "备注") @ExcelProperty(value = "备注", order = 6) @ExcelInfo - @ValidationArgsLenMax(255) + @ValidatorLenMax(255) private String remark; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/mysql/entity/FieldTypeAttribute.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/FieldTypeAttribute.java similarity index 94% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/mysql/entity/FieldTypeAttribute.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/FieldTypeAttribute.java index 9859c34..03c6a46 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/mysql/entity/FieldTypeAttribute.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/FieldTypeAttribute.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.opsli.core.generator.strategy.sync.mysql.entity; +package org.opsli.plugins.generator; import lombok.Data; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/util/SqlSyncUtil.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/SqlSyncUtil.java similarity index 88% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/util/SqlSyncUtil.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/SqlSyncUtil.java index 68ae3e5..4e2f2af 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/util/SqlSyncUtil.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/SqlSyncUtil.java @@ -13,12 +13,12 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.opsli.core.generator.strategy.sync.util; +package org.opsli.plugins.generator; import cn.hutool.core.util.ClassUtil; import lombok.extern.slf4j.Slf4j; -import org.opsli.core.generator.enums.DataBaseType; -import org.opsli.core.generator.strategy.sync.SyncStrategy; +import org.opsli.plugins.generator.enums.DataBaseType; +import org.opsli.plugins.generator.SyncStrategy; import org.opsli.core.utils.SpringContextHolder; import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel; import org.springframework.context.annotation.Bean; @@ -48,8 +48,9 @@ public class SqlSyncUtil { public void initSyncStrategy(){ // 拿到state包下 实现了 SystemEventState 接口的,所有子类 - Set> clazzSet = ClassUtil.scanPackageBySuper(SyncStrategy.class.getPackage().getName() - , SyncStrategy.class + Set> clazzSet = ClassUtil.scanPackageBySuper( + SyncStrategy.class.getPackage().getName(), + SyncStrategy.class ); for (Class aClass : clazzSet) { diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/SyncStrategy.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/SyncStrategy.java similarity index 91% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/SyncStrategy.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/SyncStrategy.java index 7020a48..e5c3a3e 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/SyncStrategy.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/SyncStrategy.java @@ -13,9 +13,9 @@ * License for the specific language governing permissions and limitations under * 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; /** diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/TypeFormatter.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/TypeFormatter.java new file mode 100644 index 0000000..124bfef --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/TypeFormatter.java @@ -0,0 +1,177 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 2021年5月26日14: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 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); +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/converter/ColumnTypeConverter.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/converter/ColumnTypeConverter.java new file mode 100644 index 0000000..024b8d8 --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/converter/ColumnTypeConverter.java @@ -0,0 +1,44 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 2021年5月26日14:22:31 + */ +public interface ColumnTypeConverter { + + /** + * 将数据库类型转成基本类型 + * @param type 数据库类型 + * @return 基本类型 + */ + String convertType(TypeEnum type); + + /** + * 将数据库类型转成基本类型 (会多返 一个String 兜底类型) + * @param type 数据库类型 + * @return List 基本类型 + */ + List convertTypeBySafety(TypeEnum type); + +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/converter/JavaColumnTypeConverter.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/converter/JavaColumnTypeConverter.java new file mode 100644 index 0000000..b0fdb92 --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/converter/JavaColumnTypeConverter.java @@ -0,0 +1,67 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 2021年5月26日14:25:47 + */ +public class JavaColumnTypeConverter implements ColumnTypeConverter { + + private static final Map 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 convertTypeBySafety(TypeEnum type) { + String currType = TYPE_MAP.getOrDefault(type, TYPE_MAP.get(TypeEnum.VARCHAR)).getType(); + String defType = TYPE_MAP.get(TypeEnum.VARCHAR).getType(); + List typeList = Lists.newArrayListWithCapacity(2); + typeList.add(currType); + typeList.add(defType); + return ListDistinctUtil.distinct(typeList); + } +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/MySQLSyncBuilder.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlSyncBuilder.java similarity index 88% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/MySQLSyncBuilder.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlSyncBuilder.java index 95f66a1..65ed5b3 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/sync/MySQLSyncBuilder.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlSyncBuilder.java @@ -13,16 +13,16 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.opsli.core.generator.strategy.sync; +package org.opsli.plugins.generator.database.mysql; import org.apache.commons.lang3.StringUtils; import org.opsli.common.enums.DictType; import org.opsli.common.utils.Props; -import org.opsli.core.generator.enums.DataBaseType; -import org.opsli.core.generator.exception.GeneratorException; -import org.opsli.core.generator.msg.GeneratorMsg; -import org.opsli.core.generator.strategy.sync.mysql.entity.FieldTypeAttribute; -import org.opsli.core.generator.strategy.sync.mysql.enums.MySQLSyncColumnType; +import org.opsli.plugins.generator.enums.DataBaseType; +import org.opsli.plugins.generator.exception.GeneratorException; +import org.opsli.plugins.generator.msg.GeneratorMsg; +import org.opsli.plugins.generator.SyncStrategy; +import org.opsli.plugins.generator.FieldTypeAttribute; import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; import org.opsli.modulars.generator.general.actuator.SQLActuator; import org.opsli.modulars.generator.table.service.IGenTableService; @@ -43,7 +43,7 @@ import java.util.List; */ @Service @Transactional(readOnly = true) -public class MySQLSyncBuilder implements SyncStrategy { +public class MySqlSyncBuilder implements SyncStrategy { /** 数据库引擎 */ 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.getTableName())); + sqlActuator.execute(this.genDropTableSql(model.getOldTableName())); + sqlActuator.execute(this.genDropTableSql(model.getTableName())); // 新建表 - sqlActuator.execute(this.genCreateTableSQL(model)); + sqlActuator.execute(this.genCreateTableSql(model)); // 更新同步状态 iGenTableService.renewSyncState(model.getId()); @@ -109,7 +109,7 @@ public class MySQLSyncBuilder implements SyncStrategy { * @param tableName 表名 * @return sql */ - private String genDropTableSQL(String tableName) { + private String genDropTableSql(String tableName) { return "DROP TABLE IF EXISTS " + SQLFilterKit.replaceSQL(tableName) + ";"; } @@ -118,7 +118,7 @@ public class MySQLSyncBuilder implements SyncStrategy { * @param model 模型 * @return sql */ - private String genCreateTableSQL(GenTableAndColumnModel model){ + private String genCreateTableSql(GenTableAndColumnModel model){ // 表名 String tableName = model.getTableName(); // 表字段 @@ -138,7 +138,7 @@ public class MySQLSyncBuilder implements SyncStrategy { // 字段类型 String fieldType = SQLFilterKit.replaceSQL(tmp.getFieldType()); - FieldTypeAttribute fieldAttr = MySQLSyncColumnType.INSTANCE.getAttr(fieldType); + FieldTypeAttribute fieldAttr = MySqlSyncColumnType.INSTANCE.getAttr(fieldType); str.append(" ").append(fieldType); if(fieldAttr != null){ // 字段有长度 diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlSyncColumnType.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlSyncColumnType.java new file mode 100644 index 0000000..9e941d8 --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlSyncColumnType.java @@ -0,0 +1,108 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 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 getFieldTypes(){ + List fieldTypes = Lists.newArrayListWithCapacity(fieldTypeMap.size()); + fieldTypes.addAll(fieldTypeMap.keySet()); + return ListDistinctUtil.distinct(fieldTypes); + } + + /** + * 获得全部类型对应Java类型 + * @return List + */ + public Map getJavaFieldTypes(){ + List fieldTypes = this.getFieldTypes(); + Map fieldJavaTypeMap = Maps.newHashMapWithExpectedSize(fieldTypes.size()); + for (String fieldType : fieldTypes) { + fieldJavaTypeMap.put(fieldType, columnTypeConverter.convertType( + TypeEnum.getType(fieldType))); + } + return fieldJavaTypeMap; + } + + /** + * 获得全部类型对应Java类型集合(兜底String 类型) + * @return List + */ + public Map> getJavaFieldTypesBySafety(){ + List fieldTypes = this.getFieldTypes(); + Map> 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); + } + +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlTypeFormatter.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlTypeFormatter.java new file mode 100644 index 0000000..8db6033 --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/mysql/MySqlTypeFormatter.java @@ -0,0 +1,96 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 2021年5月26日14: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; + } +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/oracle/OracleTypeFormatter.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/oracle/OracleTypeFormatter.java new file mode 100644 index 0000000..568fde6 --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/oracle/OracleTypeFormatter.java @@ -0,0 +1,96 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 2021年5月26日14: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; + } +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/postgresql/PostgreSqlTypeFormatter.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/postgresql/PostgreSqlTypeFormatter.java new file mode 100644 index 0000000..18733bc --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/postgresql/PostgreSqlTypeFormatter.java @@ -0,0 +1,96 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 2021年5月26日14: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); + } +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/sqlserver/SqlServerTypeFormatter.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/sqlserver/SqlServerTypeFormatter.java new file mode 100644 index 0000000..b68901b --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/database/sqlserver/SqlServerTypeFormatter.java @@ -0,0 +1,96 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 2021年5月26日14: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; + } +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/enums/DataBaseType.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/DataBaseType.java similarity index 72% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/enums/DataBaseType.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/DataBaseType.java index ae48705..90d85b5 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/enums/DataBaseType.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/DataBaseType.java @@ -1,4 +1,19 @@ -package org.opsli.core.generator.enums; +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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; /** * 数据库类型 diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/JavaType.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/JavaType.java new file mode 100644 index 0000000..4dd7679 --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/JavaType.java @@ -0,0 +1,103 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 2021年5月26日16: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", "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 getPkgList(List typeList) { + if(typeList == null || typeList.size() == 0){ + return Collections.emptyList(); + } + + List 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); + } + +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/TypeEnum.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/TypeEnum.java new file mode 100644 index 0000000..1c38167 --- /dev/null +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/enums/TypeEnum.java @@ -0,0 +1,73 @@ +/** + * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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; + } +} diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/exception/GeneratorException.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/exception/GeneratorException.java similarity index 95% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/exception/GeneratorException.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/exception/GeneratorException.java index ffdba0a..84794ef 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/exception/GeneratorException.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/exception/GeneratorException.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * 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.exception.ServiceException; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/msg/GeneratorMsg.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/msg/GeneratorMsg.java similarity index 98% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/msg/GeneratorMsg.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/msg/GeneratorMsg.java index 974e56f..d129ff3 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/msg/GeneratorMsg.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/msg/GeneratorMsg.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.opsli.core.generator.msg; +package org.opsli.plugins.generator.msg; import org.opsli.common.base.msg.BaseMsg; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/CodeBuilder.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/CodeBuilder.java similarity index 87% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/CodeBuilder.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/CodeBuilder.java index 7d66899..e84fe48 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/CodeBuilder.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/CodeBuilder.java @@ -13,26 +13,22 @@ * License for the specific language governing permissions and limitations under * 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.io.IoUtil; +import com.baomidou.mybatisplus.generator.AutoGenerator; +import com.baomidou.mybatisplus.generator.config.GlobalConfig; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.opsli.api.ApiFlag; -import org.opsli.common.enums.DictType; -import org.opsli.common.enums.ValiArgsType; -import org.opsli.common.utils.HumpUtil; +import org.opsli.common.enums.ValidatorType; import org.opsli.common.utils.Props; import org.opsli.common.utils.ZipUtils; -import org.opsli.core.generator.strategy.create.backend.JavaCodeBuilder; -import org.opsli.core.generator.strategy.create.foreend.VueCodeBuilder; -import org.opsli.core.generator.strategy.create.readme.ReadMeBuilder; -import org.opsli.core.generator.utils.GeneratorHandleUtil; -import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; +import org.opsli.plugins.generator.strategy.create.backend.JavaCodeBuilder; +import org.opsli.plugins.generator.strategy.create.foreend.VueCodeBuilder; +import org.opsli.plugins.generator.strategy.create.readme.ReadMeBuilder; +import org.opsli.plugins.generator.utils.GeneratorHandleUtil; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; -import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; @@ -146,7 +142,12 @@ public enum CodeBuilder { } public static void main(String[] args) { - System.out.println(ValiArgsType.IS_NOT_NULL.toString()); + // 代码生成器 + AutoGenerator mpg = new AutoGenerator(); + + // 全局配置 + GlobalConfig gc = new GlobalConfig(); + } } diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/backend/JavaCodeBuilder.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/backend/JavaCodeBuilder.java similarity index 97% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/backend/JavaCodeBuilder.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/backend/JavaCodeBuilder.java index 2d10471..c4ddec4 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/backend/JavaCodeBuilder.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/backend/JavaCodeBuilder.java @@ -13,23 +13,18 @@ * License for the specific language governing permissions and limitations under * 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 com.jfinal.kit.Kv; 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.ZipUtils; -import org.opsli.core.generator.strategy.create.CodeBuilder; -import org.opsli.core.generator.utils.EnjoyUtil; -import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; +import org.opsli.plugins.generator.strategy.create.CodeBuilder; +import org.opsli.plugins.generator.utils.EnjoyUtil; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; import java.util.HashMap; -import java.util.List; import java.util.Map; /** diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/foreend/VueCodeBuilder.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/foreend/VueCodeBuilder.java similarity index 95% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/foreend/VueCodeBuilder.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/foreend/VueCodeBuilder.java index 60de1b3..aa9e364 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/foreend/VueCodeBuilder.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/foreend/VueCodeBuilder.java @@ -13,20 +13,16 @@ * License for the specific language governing permissions and limitations under * 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 com.jfinal.kit.Kv; 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.WrapperUtil; import org.opsli.common.utils.ZipUtils; -import org.opsli.core.generator.strategy.create.CodeBuilder; -import org.opsli.core.generator.utils.EnjoyUtil; -import org.opsli.modulars.generator.column.wrapper.GenTableColumnModel; +import org.opsli.plugins.generator.strategy.create.CodeBuilder; +import org.opsli.plugins.generator.utils.EnjoyUtil; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; import java.util.*; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/readme/ReadMeBuilder.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/readme/ReadMeBuilder.java similarity index 92% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/readme/ReadMeBuilder.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/readme/ReadMeBuilder.java index 653961c..ad60c20 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/strategy/create/readme/ReadMeBuilder.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/strategy/create/readme/ReadMeBuilder.java @@ -13,14 +13,14 @@ * License for the specific language governing permissions and limitations under * 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 com.jfinal.kit.Kv; import org.opsli.common.utils.WrapperUtil; import org.opsli.common.utils.ZipUtils; -import org.opsli.core.generator.strategy.create.CodeBuilder; -import org.opsli.core.generator.utils.EnjoyUtil; +import org.opsli.plugins.generator.strategy.create.CodeBuilder; +import org.opsli.plugins.generator.utils.EnjoyUtil; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; import java.util.HashMap; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/utils/EnjoyUtil.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/utils/EnjoyUtil.java similarity index 98% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/utils/EnjoyUtil.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/utils/EnjoyUtil.java index 0d6b48a..404f41b 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/utils/EnjoyUtil.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/utils/EnjoyUtil.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package org.opsli.core.generator.utils; +package org.opsli.plugins.generator.utils; import cn.hutool.core.io.IoUtil; import com.google.common.collect.Maps; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/utils/GeneratorHandleUtil.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/utils/GeneratorHandleUtil.java similarity index 70% rename from opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/utils/GeneratorHandleUtil.java rename to opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/utils/GeneratorHandleUtil.java index 6443cf1..575ae0c 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/core/generator/utils/GeneratorHandleUtil.java +++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/plugins/generator/utils/GeneratorHandleUtil.java @@ -13,24 +13,25 @@ * License for the specific language governing permissions and limitations under * 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.ListUtil; import cn.hutool.core.convert.Convert; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; 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.enums.ValidatorType; +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.importable.ImportTableUtil; import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel; 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.Set; +import java.util.Map; /*** * 代码生成器 处理工具类 @@ -41,9 +42,9 @@ import java.util.Set; 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(); // 数据库表名转驼峰 model.setTableHumpName( - HumpUtil.captureName( - HumpUtil.underlineToHump( + FieldUtil.upperFirstLetter( + FieldUtil.underlineToHump( model.getTableName() ) ) @@ -84,55 +85,40 @@ public final class GeneratorHandleUtil { for (GenTableColumnModel columnModel : columnList) { // 1. 数据库字段名转驼峰 columnModel.setFieldHumpName( - HumpUtil.underlineToHump( + FieldUtil.underlineToHump( columnModel.getFieldName() ) ); // 验证集合 - Set validateTypeSet = Sets.newHashSet(columnModel.getValidateType()); + List validateTypeList = Convert.toList(String.class, columnModel.getValidateType()); // 如果非空 则开启非空验证 if(DictType.NO_YES_YES.getValue().equals(columnModel.getIzNotNull())){ - validateTypeSet.add(ValiArgsType.IS_NOT_NULL.toString()); + validateTypeList.add(ValidatorType.IS_NOT_NULL.toString()); } - List validateTypeList = Convert.toList(String.class, validateTypeSet); + // 去空项 validateTypeList.removeIf(StringUtils::isBlank); + // 去重复 + validateTypeList = ListDistinctUtil.distinct(validateTypeList); - // 2. 后端字段验证 - // 处理验证器 + // 2. 处理字段验证器 if(!CollUtil.isEmpty(validateTypeList)){ - StringBuilder backendStb = new StringBuilder(); - StringBuilder frontendStb = new StringBuilder(); - - columnModel.setFrontendValidateTypeList(Lists.newArrayList()); - List backendList = Lists.newArrayListWithCapacity(validateTypeList.size()); - List frontendList = Lists.newArrayListWithCapacity(validateTypeList.size()); + List typeList = Lists.newArrayListWithCapacity(validateTypeList.size()); + List typeAndCommaList = Lists.newArrayListWithCapacity(validateTypeList.size()); for (int i = 0; i < validateTypeList.size(); i++) { String validate = validateTypeList.get(i); - - 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())); + String validateAndComma = validate; if(i < validateTypeList.size() - 1 ){ - backendStb.append(", "); - frontendStb.append(", "); + validateAndComma+=", "; } - } + typeList.add(validate); + typeAndCommaList.add(validateAndComma); + } - columnModel.setBackendValidateType(backendStb.toString()); - columnModel.setFrontendValidateType(frontendStb.toString()); - model.setFrontendValidateType(frontendStb.toString()); - - columnModel.setBackendValidateTypeList(backendList); - columnModel.setFrontendValidateTypeList(frontendList); + columnModel.setValidateTypeList(typeList); + columnModel.setValidateTypeAndCommaList(typeAndCommaList); } // 3. 处理 Form 表单字段 @@ -172,6 +158,15 @@ public final class GeneratorHandleUtil { } } + // 6. Entity 引入 import + Map javaFieldTypes = ImportTableUtil.getJavaFieldTypes(); + List javaTypeList = Lists.newArrayListWithCapacity(javaFieldTypes.size()); + for (Map.Entry entry : javaFieldTypes.entrySet()) { + javaTypeList.add(entry.getValue()); + } + List pkgList = JavaType.getPkgList(javaTypeList); + model.setEntityPkgList(pkgList); + } return builderModel; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/backend/entity/TemplateEntity.html b/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/backend/entity/TemplateEntity.html index f3697c5..64320fa 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/backend/entity/TemplateEntity.html +++ b/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/backend/entity/TemplateEntity.html @@ -19,7 +19,9 @@ package #(data.packageName+"."+data.moduleName+"."+data.subModuleName).entity; package #(data.packageName+"."+data.moduleName).entity; #end -import java.util.Date; +#for(pkg : data.model.entityPkgList) +import #(pkg); +#end import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableLogic; diff --git a/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/backend/model/TemplateModel.html b/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/backend/model/TemplateModel.html index 93a5b57..4485dde 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/backend/model/TemplateModel.html +++ b/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/backend/model/TemplateModel.html @@ -19,25 +19,28 @@ package #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName); package #(apiPath).wrapper.#(data.moduleName); #end -import java.util.Date; +#for(pkg : data.model.entityPkgList) +import #(pkg); +#end import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import #(apiPath).base.warpper.ApiWrapper; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.annotation.validator.ValidatorLenMin; +import org.opsli.common.enums.ValidatorType; import org.opsli.plugins.excel.annotation.ExcelInfo; import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.format.annotation.DateTimeFormat; /** - * #(data.codeTitle) Model - * - * @author #(data.authorName) - * @date #(currTime) - */ +* #(data.codeTitle) Model +* +* @author #(data.authorName) +* @date #(currTime) +*/ @Data @EqualsAndHashCode(callSuper = false) public class #(data.model.tableHumpName)Model extends ApiWrapper { @@ -53,14 +56,18 @@ public class #(data.model.tableHumpName)Model extends ApiWrapper { #else @ExcelInfo #end - #if(column.backendValidateType != null && column.backendValidateType != "") - @ValidationArgs({#(column.backendValidateType)}) + #if(column.validateTypeAndCommaList != null && column.validateTypeAndCommaList.size() > 0) + @Validator({ + #for(typeAndComma : column.validateTypeAndCommaList) + ValidatorType.#(typeAndComma) + #end + }) #end #if(column.fieldLength != null && column.fieldLength > 0) #if(column.fieldPrecision != null && column.fieldPrecision > 0) - @ValidationArgsLenMax(#(column.fieldLength+column.fieldPrecision)) + @ValidatorLenMax(#(column.fieldLength+column.fieldPrecision)) #else - @ValidationArgsLenMax(#(column.fieldLength)) + @ValidatorLenMax(#(column.fieldLength)) #end #end ### 日期处理 diff --git a/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/foreend/components/TemplateEdit.html b/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/foreend/components/TemplateEdit.html index 153234b..624ff08 100644 --- a/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/foreend/components/TemplateEdit.html +++ b/opsli-modulars/opsli-modulars-generator/src/main/resources/tpl/foreend/components/TemplateEdit.html @@ -81,9 +81,8 @@ #else import { doInsert, doUpdate } from "@/api/#(data.moduleName)/#(data.model.tableHumpName)Management"; #end - import { formateDate } from "@/utils/format"; import { isNull } from "@/utils/validate"; - import { #(data.model.frontendValidateType) } from "@/utils/validateRlue"; + import { validatorRule } from "@/utils/validateRlue"; export default { name: "#(data.model.tableHumpName)ManagementEdit", @@ -98,20 +97,20 @@ rules: { #for(columnList : data.model.formList) #for(column : columnList) - #if(column.frontendValidateTypeList.size() > 0) - #(column.fieldHumpName): [ - #for(validate : column.frontendValidateTypeList) - #if(validate == "isNotNull") - { required: true, trigger: "blur", message: "#(column.fieldComments)非空" }, + #if(column.validateTypeList != null && column.validateTypeList.size() > 0) + #(column.fieldHumpName): [ + #for(typeNotComma : column.validateTypeList) + #if(typeNotComma == "IS_NOT_NULL") + { required: true, trigger: "blur", message: "#(column.fieldComments)非空" }, + #end + #end + #for(typeNotComma : column.validateTypeList) + #if(typeNotComma != "IS_NOT_NULL") + { required: false, trigger: "blur", validator: validatorRule.#(typeNotComma) }, + #end + #end + ], #end - #end - #for(validate : column.frontendValidateTypeList) - #if(validate != "isNotNull") - { required: false, trigger: "blur", validator: #(validate) }, - #end - #end - ], - #end #end #end }, diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/service/impl/SysAreaServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/service/impl/SysAreaServiceImpl.java index d04c3b6..f5410f7 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/service/impl/SysAreaServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/service/impl/SysAreaServiceImpl.java @@ -23,7 +23,7 @@ import org.opsli.api.wrapper.system.area.SysAreaModel; import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.enums.DictType; 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.service.impl.CrudServiceImpl; import org.opsli.core.persistence.querybuilder.GenQueryBuilder; @@ -132,7 +132,7 @@ public class SysAreaServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); - queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); List childList = super.findList(queryWrapper); for (SysArea child : childList) { super.delete(child.getId()); @@ -181,9 +181,9 @@ public class SysAreaServiceImpl extends CrudServiceImpl 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()) - .groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); + .groupBy(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); return mapper.hasChildren(wrapper); } diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/web/SysAreaRestController.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/web/SysAreaRestController.java index 1166b03..4f683e3 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/web/SysAreaRestController.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/area/web/SysAreaRestController.java @@ -22,7 +22,6 @@ import cn.hutool.core.io.IoUtil; import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.TreeNodeConfig; -import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ReflectUtil; 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.RequiresPermissionsCus; 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.entity.HasChildren; -import org.opsli.core.persistence.querybuilder.GenQueryBuilder; import org.opsli.core.persistence.querybuilder.QueryBuilder; import org.opsli.core.persistence.querybuilder.WebQueryBuilder; import org.opsli.core.utils.TreeBuildUtil; @@ -107,7 +105,7 @@ public class SysAreaRestController extends BaseRestController findTree(String parentId) { QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); List dataList = IService.findList(wrapper); // 获得BeanMapList diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/dict/service/impl/DictDetailServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/dict/service/impl/DictDetailServiceImpl.java index 6412e97..1174018 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/dict/service/impl/DictDetailServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/dict/service/impl/DictDetailServiceImpl.java @@ -25,7 +25,7 @@ import org.opsli.api.wrapper.system.dict.DictModel; import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.enums.DictType; 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.msg.CoreMsg; import org.opsli.core.persistence.querybuilder.GenQueryBuilder; @@ -170,7 +170,7 @@ public class DictDetailServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); List idList = Convert.toList(ids); - queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); + queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); List list = this.findList(queryWrapper); boolean ret = super.deleteAll(ids); @@ -208,7 +208,7 @@ public class DictDetailServiceImpl extends CrudServiceImpl list = this.findList(queryWrapper); @@ -244,7 +244,7 @@ public class DictDetailServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); queryWrapper.eq(key, parentId); @@ -273,8 +273,8 @@ public class DictDetailServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/entity/LoginForm.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/entity/LoginForm.java index 91bf860..254cd38 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/entity/LoginForm.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/entity/LoginForm.java @@ -19,10 +19,10 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.opsli.api.base.encrypt.BaseEncrypt; -import org.opsli.common.annotation.validation.ValidationArgs; -import org.opsli.common.annotation.validation.ValidationArgsLenMax; -import org.opsli.common.annotation.validation.ValidationArgsLenMin; -import org.opsli.common.enums.ValiArgsType; +import org.opsli.common.annotation.validator.Validator; +import org.opsli.common.annotation.validator.ValidatorLenMax; +import org.opsli.common.annotation.validator.ValidatorLenMin; +import org.opsli.common.enums.ValidatorType; /** * 登录表单 @@ -36,19 +36,19 @@ public class LoginForm extends BaseEncrypt { /** 用户名 */ @ApiModelProperty(value = "用户名") - @ValidationArgs({ValiArgsType.IS_NOT_NULL,ValiArgsType.IS_GENERAL}) - @ValidationArgsLenMax(50) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_GENERAL}) + @ValidatorLenMax(50) private String username; /** 密码 */ @ApiModelProperty(value = "密码") - @ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_SECURITY_PASSWORD}) - @ValidationArgsLenMin(6) + @Validator({ValidatorType.IS_NOT_NULL, ValidatorType.IS_SECURITY_PASSWORD}) + @ValidatorLenMin(6) private String password; /** 验证码 */ @ApiModelProperty(value = "验证码") - @ValidationArgsLenMax(30) + @ValidatorLenMax(30) private String captcha; /** UUID */ diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/web/LoginRestController.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/web/LoginRestController.java index 324ae28..d947d29 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/web/LoginRestController.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/web/LoginRestController.java @@ -29,7 +29,7 @@ import org.opsli.api.wrapper.system.user.UserModel; import org.opsli.common.annotation.ApiCryptoAsymmetric; import org.opsli.common.annotation.Limiter; 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.common.enums.AlertType; import org.opsli.common.enums.OptionsType; @@ -83,7 +83,7 @@ public class LoginRestController { } // 验证登录对象 - ValidationUtil.verify(form); + ValidatorUtil.verify(form); // 判断账号是否临时锁定 UserTokenUtil.verifyLockAccount(form.getUsername()); diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java index 4a577f4..da8dd0e 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/service/impl/MenuServiceImpl.java @@ -26,7 +26,7 @@ import org.opsli.common.constants.MenuConstants; import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.enums.DictType; 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.service.impl.CrudServiceImpl; import org.opsli.core.msg.CoreMsg; @@ -274,7 +274,7 @@ public class MenuServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); - queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); List menuList = super.findList(queryWrapper); for (SysMenu child : menuList) { // 删除菜单数据 @@ -299,9 +299,9 @@ public class MenuServiceImpl extends CrudServiceImpl 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()) - .groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); + .groupBy(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); return mapper.hasChildren(wrapper); } @@ -318,10 +318,10 @@ public class MenuServiceImpl extends CrudServiceImpl 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("type", "1") - .groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); + .groupBy(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); return mapper.hasChildren(wrapper); } diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/web/MenuRestController.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/web/MenuRestController.java index a478d5f..b3eb587 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/web/MenuRestController.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/menu/web/MenuRestController.java @@ -21,7 +21,6 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.TreeNodeConfig; -import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.util.ReflectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.constants.MenuConstants; import org.opsli.common.constants.MyBatisConstants; -import org.opsli.common.exception.ServiceException; -import org.opsli.common.utils.HumpUtil; +import org.opsli.common.utils.FieldUtil; import org.opsli.common.utils.WrapperUtil; import org.opsli.core.base.controller.BaseRestController; 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.utils.TreeBuildUtil; 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.service.IMenuService; import org.opsli.modulars.system.user.service.IUserService; @@ -184,13 +181,13 @@ public class MenuRestController extends BaseRestController queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); queryWrapper.eq( - HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); queryWrapper.eq("type", "1"); // 如果传入ID 则不包含自身 if(StringUtils.isNotEmpty(id)){ queryWrapper.notIn( - HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), id); + FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID), id); } @@ -231,7 +228,7 @@ public class MenuRestController extends BaseRestController queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); - queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); // 获得菜单 List menuList = IService.findList(queryWrapper); diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/options/service/impl/SysOptionsServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/options/service/impl/SysOptionsServiceImpl.java index f4ceb44..b63be7b 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/options/service/impl/SysOptionsServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/options/service/impl/SysOptionsServiceImpl.java @@ -30,7 +30,7 @@ import org.opsli.common.exception.ServiceException; import org.opsli.core.base.service.impl.CrudServiceImpl; import org.opsli.core.msg.CoreMsg; 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.options.entity.SysOptions; import org.opsli.modulars.system.options.mapper.SysOptionsMapper; @@ -64,7 +64,7 @@ public class SysOptionsServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); - queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); List entityList = super.findList(queryWrapper); for (SysOrg sysOrg : entityList) { sysOrg.setTenantId(tenantId); @@ -192,7 +190,7 @@ public class SysOrgServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); - queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + queryWrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); List entityList = super.findList(queryWrapper); for (SysOrg sysOrg : entityList) { super.delete(sysOrg.getId()); @@ -240,9 +238,9 @@ public class SysOrgServiceImpl extends CrudServiceImpl 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()) - .groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); + .groupBy(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID)); return mapper.hasChildren(wrapper); } diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/web/SysOrgRestController.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/web/SysOrgRestController.java index b2502b4..0d6fc66 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/web/SysOrgRestController.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/org/web/SysOrgRestController.java @@ -19,16 +19,13 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.TreeNodeConfig; -import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.util.ReflectUtil; 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.Sets; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.opsli.api.base.result.ResultVo; 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.RequiresPermissionsCus; 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.core.base.controller.BaseRestController; import org.opsli.core.base.entity.HasChildren; @@ -89,7 +86,7 @@ public class SysOrgRestController extends BaseRestController queryBuilder = new GenQueryBuilder<>(); QueryWrapper wrapper = queryBuilder.build(); - wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); // 获得用户 对应菜单 List dataList = IService.findList(wrapper); @@ -127,7 +124,7 @@ public class SysOrgRestController extends BaseRestController queryBuilder = new GenQueryBuilder<>(); QueryWrapper wrapper = queryBuilder.build(); - wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); // 获得用户 对应菜单 List dataList = IService.findList(wrapper); @@ -160,7 +157,7 @@ public class SysOrgRestController extends BaseRestController queryBuilder = new GenQueryBuilder<>(); QueryWrapper wrapper = queryBuilder.build(); - wrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); + wrapper.eq(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); // 获得用户 对应菜单 List dataList = IService.findList(wrapper); diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/service/impl/TenantServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/service/impl/TenantServiceImpl.java index 592fe46..9f93076 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/service/impl/TenantServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/tenant/service/impl/TenantServiceImpl.java @@ -27,7 +27,7 @@ import org.opsli.api.wrapper.system.user.UserModel; import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.enums.DictType; 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.msg.CoreMsg; import org.opsli.core.utils.TenantUtil; @@ -93,7 +93,7 @@ public class TenantServiceImpl extends CrudServiceImpl updateWrapper = new UpdateWrapper<>(); updateWrapper.set("enable", enable) .eq( - HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), tenantId); + FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID), tenantId); if(this.update(updateWrapper)){ // 清除缓存 this.clearCache(Collections.singletonList(tenantId)); @@ -350,7 +350,7 @@ public class TenantServiceImpl extends CrudServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT), + queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT), tenantIdList ); int count = iUserService.count(queryWrapper); diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/impl/UserServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/impl/UserServiceImpl.java index 6363abb..cd93d43 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/impl/UserServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/impl/UserServiceImpl.java @@ -34,7 +34,7 @@ import org.opsli.common.constants.MyBatisConstants; import org.opsli.common.enums.DictType; import org.opsli.common.exception.ServiceException; 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.WrapperUtil; import org.opsli.core.base.service.impl.CrudServiceImpl; @@ -157,7 +157,7 @@ public class UserServiceImpl extends CrudServiceImpl roleQueryWrapper = new QueryWrapper<>(); roleQueryWrapper.eq("role_code", defRole); roleQueryWrapper.eq( - HumpUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC), + FieldUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC), DictType.NO_YES_NO.getValue()); SysRole sysRole = iRoleService.getOne(roleQueryWrapper); if(sysRole != null){ @@ -255,7 +255,7 @@ public class UserServiceImpl extends CrudServiceImpl updateWrapper = new UpdateWrapper<>(); updateWrapper.set("enable", enable) .eq( - HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), userId + FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID), userId ); if(this.update(updateWrapper)){ // 刷新用户缓存 @@ -352,7 +352,7 @@ public class UserServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); - queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); + queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); List modelList = super.transformTs2Ms( this.findList(queryWrapper) ); @@ -399,7 +399,7 @@ public class UserServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); - queryWrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); + queryWrapper.in(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID),idList); List modelList = super.transformTs2Ms( this.findList(queryWrapper) ); @@ -415,12 +415,12 @@ public class UserServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper queryWrapper = queryBuilder.build(); queryWrapper.eq(key, username); queryWrapper.eq( - HumpUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC) + FieldUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC) , "0"); SysUser user = this.getOne(queryWrapper); return super.transformT2M(user); @@ -700,7 +700,7 @@ public class UserServiceImpl extends CrudServiceImpl orgQueryWrapper = new QueryWrapper<>(); orgQueryWrapper.in( - HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), + FieldUtil.humpToUnderline(MyBatisConstants.FIELD_ID), orgIds); List orgList = iSysOrgService.findList(orgQueryWrapper); if(CollUtil.isNotEmpty(orgList)){