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 b3d881c1..c3775011 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 @@ -59,10 +59,10 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl 0){ + boolean verificationByFieldName = this.uniqueVerificationByFieldName(model); + if(!verificationByFieldName){ // 重复 - throw new GeneratorException(GeneratorMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); + throw new GeneratorException(GeneratorMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); } return super.insert(model); @@ -87,8 +87,8 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl 0){ + boolean verificationByFieldName = this.uniqueVerificationByFieldName(model); + if(!verificationByFieldName){ // 重复 throw new GeneratorException(GeneratorMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); } @@ -120,8 +120,8 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl 0){ + boolean verificationByFieldName = this.uniqueVerificationByFieldName(model); + if(!verificationByFieldName){ // 重复 throw new GeneratorException(GeneratorMsg.EXCEPTION_TABLE_COLUMN_FIELD_NAME_REPEAT); } @@ -179,9 +179,9 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); @@ -194,7 +194,7 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl 0){ + boolean verificationByTableName = this.uniqueVerificationByTableName(model); + if(!verificationByTableName){ // 重复 throw new GeneratorException(GeneratorMsg.EXCEPTION_TABLE_NAME_REPEAT); } @@ -97,8 +97,8 @@ public class GenTableServiceImpl extends CrudServiceImpl 0){ + boolean verificationByTableName = this.uniqueVerificationByTableName(model); + if(!verificationByTableName){ // 重复 throw new GeneratorException(GeneratorMsg.EXCEPTION_TABLE_NAME_REPEAT); } @@ -261,9 +261,9 @@ public class GenTableServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); @@ -275,7 +275,7 @@ public class GenTableServiceImpl extends CrudServiceImpl 0){ + boolean verificationByTemplateName = this.uniqueVerificationByTemplateName(model); + if(!verificationByTemplateName){ // 重复 throw new GeneratorException(GeneratorMsg.EXCEPTION_TEMPLATE_NAME_REPEAT); } @@ -103,8 +103,8 @@ public class GenTemplateServiceImpl extends CrudServiceImpl 0){ + boolean verificationByTemplateName = this.uniqueVerificationByTemplateName(model); + if(!verificationByTemplateName){ // 重复 throw new GeneratorException(GeneratorMsg.EXCEPTION_TEMPLATE_NAME_REPEAT); } @@ -144,10 +144,11 @@ public class GenTemplateServiceImpl extends CrudServiceImpl 0){ + if(!verificationByTemplateName){ // 重复 throw new GeneratorException(GeneratorMsg.EXCEPTION_TEMPLATE_NAME_REPEAT); } @@ -224,9 +225,9 @@ public class GenTemplateServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); @@ -238,7 +239,7 @@ public class GenTemplateServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + if(!verificationByCode){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_AREA_UNIQUE); } @@ -92,8 +92,8 @@ public class SysAreaServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + if(!verificationByCode){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_AREA_UNIQUE); } @@ -149,22 +149,21 @@ public class SysAreaServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); // code 唯一 - wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) - .eq("area_code", model.getAreaCode()); + wrapper.eq("area_code", model.getAreaCode()); // 重复校验排除自身 if(StringUtils.isNotEmpty(model.getId())){ wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId()); } - return super.count(wrapper); + return super.count(wrapper) == 0; } 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 11740180..93b603f1 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 @@ -67,8 +67,8 @@ public class DictDetailServiceImpl extends CrudServiceImpl 0){ + boolean verificationByNameOrValue = this.uniqueVerificationByNameOrValue(model); + if(!verificationByNameOrValue){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_DICT_DETAIL_UNIQUE); } @@ -97,8 +97,8 @@ public class DictDetailServiceImpl extends CrudServiceImpl 0){ + boolean verificationByNameOrValue = this.uniqueVerificationByNameOrValue(model); + if(!verificationByNameOrValue){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_DICT_DETAIL_UNIQUE); } @@ -293,15 +293,14 @@ public class DictDetailServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); // name 唯一 - wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) - .eq("type_code", model.getTypeCode()); + wrapper.eq("type_code", model.getTypeCode()); // 名称 或者 Val 重复 wrapper.and(wra -> @@ -313,7 +312,7 @@ public class DictDetailServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + if(!verificationByCode){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_DICT_UNIQUE); } @@ -74,8 +74,8 @@ public class DictServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + if(!verificationByCode){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_DICT_UNIQUE); } @@ -165,9 +165,9 @@ public class DictServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); @@ -180,7 +180,7 @@ public class DictServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); // code 唯一 - wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) - .eq("permissions", model.getPermissions()) + wrapper.eq("permissions", model.getPermissions()) .eq("type", MenuConstants.BUTTON); // 重复校验排除自身 @@ -354,7 +353,7 @@ public class MenuServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + if(!verificationByCode){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_OPTIONS_UNIQUE); } @@ -113,8 +113,8 @@ public class SysOptionsServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + if(!verificationByCode){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_OPTIONS_UNIQUE); } @@ -249,9 +249,9 @@ public class SysOptionsServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("option_code", model.getOptionCode()); @@ -261,7 +261,7 @@ public class SysOptionsServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + if(!verificationByCode){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_ORG_UNIQUE); } @@ -114,8 +114,8 @@ public class SysOrgServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + if(!verificationByCode){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_ORG_UNIQUE); } @@ -267,13 +267,12 @@ public class SysOrgServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); - wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) - .eq("org_code", model.getOrgCode()); + wrapper.eq("org_code", model.getOrgCode()); // 重复校验排除自身 if(StringUtils.isNotEmpty(model.getId())){ @@ -283,7 +282,7 @@ public class SysOrgServiceImpl extends CrudServiceImpl queryBuilder = new GenQueryBuilder<>(); QueryWrapper wrapper = queryBuilder.build(); - UserModel currUser = UserUtil.getUser(); - List orgListByUserId = OrgUtil.getOrgListByUserId(currUser.getId()); + List orgListByUserId = OrgUtil.getOrgByCurrUser(); if(!CollUtil.isEmpty(orgListByUserId)){ List parentIdList = Lists.newArrayListWithCapacity(orgListByUserId.size()); diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/role/service/impl/RoleServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/role/service/impl/RoleServiceImpl.java index fc5fffd1..4eb1a5af 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/role/service/impl/RoleServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/role/service/impl/RoleServiceImpl.java @@ -72,8 +72,9 @@ public class RoleServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + boolean verificationByName = this.uniqueVerificationByName(model); + if(!verificationByCode || !verificationByName){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_ROLE_UNIQUE); } @@ -97,8 +98,9 @@ public class RoleServiceImpl extends CrudServiceImpl 0){ + boolean verificationByCode = this.uniqueVerificationByCode(model); + boolean verificationByName = this.uniqueVerificationByName(model); + if(!verificationByCode || !verificationByName){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_ROLE_UNIQUE); } @@ -176,30 +178,61 @@ public class RoleServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); // code 唯一 - wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) - .eq("role_code", model.getRoleCode()); + wrapper.eq("role_code", model.getRoleCode()); // 重复校验排除自身 if(StringUtils.isNotEmpty(model.getId())){ wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId()); } + // 租户检测 // 数据处理责任链 wrapper = new QueryTenantHandler( new QueryOrgHandler() ).handler(entityClazz, wrapper); - return super.count(wrapper); + return super.count(wrapper) == 0; } + /** + * 唯一验证 + * @param model model + * @return Integer + */ + @Transactional(readOnly = true) + public boolean uniqueVerificationByName(RoleModel model){ + if(model == null){ + return false; + } + QueryWrapper wrapper = new QueryWrapper<>(); + + // code 唯一 + wrapper.eq("role_name", model.getRoleName()); + + // 重复校验排除自身 + if(StringUtils.isNotEmpty(model.getId())){ + wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId()); + } + + // 租户检测 + // 数据处理责任链 + wrapper = new QueryTenantHandler( + new QueryOrgHandler() + ).handler(entityClazz, wrapper); + + return super.count(wrapper) == 0; + } + + + } 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 9f93076b..924ab44f 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 @@ -113,8 +113,8 @@ public class TenantServiceImpl extends CrudServiceImpl 0){ + boolean verificationByName = this.uniqueVerificationByName(model); + if(!verificationByName){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_TENANT_UNIQUE); } @@ -132,8 +132,8 @@ public class TenantServiceImpl extends CrudServiceImpl 0){ + boolean verificationByName = this.uniqueVerificationByName(model); + if(!verificationByName){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_TENANT_UNIQUE); } @@ -321,9 +321,9 @@ public class TenantServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); @@ -336,7 +336,7 @@ public class TenantServiceImpl extends CrudServiceImpl 0){ + // 唯一验证 - 用户名 + boolean verificationByName = this.uniqueVerificationByName(model); + if(!verificationByName){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_USER_UNIQUE); } // 唯一验证 - 工号 - count = this.uniqueVerificationByNo(model); - if(count != null && count > 0){ + boolean verificationByNo = this.uniqueVerificationByNo(model); + if(!verificationByNo){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_USER_NO_UNIQUE); } @@ -190,14 +190,14 @@ public class UserServiceImpl extends CrudServiceImpl 0){ + boolean verificationByName = this.uniqueVerificationByName(model); + if(!verificationByName){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_USER_UNIQUE); } // 唯一验证 - 工号 - count = this.uniqueVerificationByNo(model); - if(count != null && count > 0){ + boolean verificationByNo = this.uniqueVerificationByNo(model); + if(!verificationByNo){ // 重复 throw new ServiceException(SystemMsg.EXCEPTION_USER_NO_UNIQUE); } @@ -748,15 +748,14 @@ public class UserServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); // no 唯一 - wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) - .eq("no", model.getNo()); + wrapper.eq("no", model.getNo()); // 重复校验排除自身 if(StringUtils.isNotEmpty(model.getId())){ @@ -764,9 +763,12 @@ public class UserServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); // name 唯一 - wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue()) - .eq("username", model.getUsername()); + wrapper.eq("username", model.getUsername()); // 重复校验排除自身 if(StringUtils.isNotEmpty(model.getId())){ wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId()); } - return super.count(wrapper); + return super.count(wrapper) == 0; } // ==================