perf: 优化基础验证

pull/9/head
Carina 3 years ago
parent 346fdfdcd9
commit cccb7e37dc

@ -59,10 +59,10 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl<GenTableColumnMap
}
// 唯一验证
Integer count = this.uniqueVerificationByFieldName(model);
if(count != null && count > 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<GenTableColumnMap
ValidatorUtil.verify(model);
// 唯一验证
Integer count = this.uniqueVerificationByFieldName(model);
if(count != null && count > 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<GenTableColumnMap
}
// 唯一验证
Integer count = this.uniqueVerificationByFieldName(model);
if(count != null && count > 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<GenTableColumnMap
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByFieldName(GenTableColumnModel model){
public boolean uniqueVerificationByFieldName(GenTableColumnModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<GenTableColumn> wrapper = new QueryWrapper<>();
@ -194,7 +194,7 @@ public class GenTableColumnServiceImpl extends CrudServiceImpl<GenTableColumnMap
wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId());
}
return super.count(wrapper);
return super.count(wrapper) == 0;
}
}

@ -71,8 +71,8 @@ public class GenTableServiceImpl extends CrudServiceImpl<GenTableMapper, GenTabl
}
// 唯一验证
Integer count = this.uniqueVerificationByTableName(model);
if(count != null && count > 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<GenTableMapper, GenTabl
}
// 唯一验证
Integer count = this.uniqueVerificationByTableName(model);
if(count != null && count > 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<GenTableMapper, GenTabl
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByTableName(GenTableModel model){
public boolean uniqueVerificationByTableName(GenTableModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<GenTable> wrapper = new QueryWrapper<>();
@ -275,7 +275,7 @@ public class GenTableServiceImpl extends CrudServiceImpl<GenTableMapper, GenTabl
wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId());
}
return super.count(wrapper);
return super.count(wrapper) == 0;
}
}

@ -71,8 +71,8 @@ public class GenTemplateServiceImpl extends CrudServiceImpl<GenTemplateMapper, G
}
// 唯一验证
Integer count = this.uniqueVerificationByTemplateName(model);
if(count != null && count > 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<GenTemplateMapper, G
}
// 唯一验证
Integer count = this.uniqueVerificationByTemplateName(model);
if(count != null && count > 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<GenTemplateMapper, G
GenTemplateModel genTemplateModel = this.get(model.getId());
model.setId(null);
// 唯一验证
Integer count = this.uniqueVerificationByTemplateName(
boolean verificationByTemplateName = this.uniqueVerificationByTemplateName(
WrapperUtil.transformInstance(model, GenTemplateAndDetailModel.class));
if(count != null && count > 0){
if(!verificationByTemplateName){
// 重复
throw new GeneratorException(GeneratorMsg.EXCEPTION_TEMPLATE_NAME_REPEAT);
}
@ -224,9 +225,9 @@ public class GenTemplateServiceImpl extends CrudServiceImpl<GenTemplateMapper, G
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByTemplateName(GenTemplateAndDetailModel model){
public boolean uniqueVerificationByTemplateName(GenTemplateAndDetailModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<GenTemplate> wrapper = new QueryWrapper<>();
@ -238,7 +239,7 @@ public class GenTemplateServiceImpl extends CrudServiceImpl<GenTemplateMapper, G
wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId());
}
return super.count(wrapper);
return super.count(wrapper) == 0;
}
// ====================

@ -46,7 +46,7 @@ public enum SystemMsg implements BaseMsg {
/**
*
*/
EXCEPTION_ROLE_UNIQUE(20200,"角色编号重复,该角色已存在"),
EXCEPTION_ROLE_UNIQUE(20200,"角色编号或名称重复,该角色已存在"),
EXCEPTION_ROLE_ID_NOT_NULL(20201,"角色Id不可为空"),
EXCEPTION_ROLE_PERMS_ERROR(20202,"角色权限设置失败"),

@ -70,8 +70,8 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
}
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 0){
boolean verificationByCode = this.uniqueVerificationByCode(model);
if(!verificationByCode){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_AREA_UNIQUE);
}
@ -92,8 +92,8 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
}
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 0){
boolean verificationByCode = this.uniqueVerificationByCode(model);
if(!verificationByCode){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_AREA_UNIQUE);
}
@ -149,22 +149,21 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByCode(SysAreaModel model){
public boolean uniqueVerificationByCode(SysAreaModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysArea> 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;
}

@ -67,8 +67,8 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys
public DictDetailModel insert(DictDetailModel model) {
// 唯一验证
Integer count = this.uniqueVerificationByNameOrValue(model);
if(count != null && count > 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<DictDetailMapper, Sys
public DictDetailModel update(DictDetailModel model) {
// 唯一验证
Integer count = this.uniqueVerificationByNameOrValue(model);
if(count != null && count > 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<DictDetailMapper, Sys
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByNameOrValue(DictDetailModel model){
public boolean uniqueVerificationByNameOrValue(DictDetailModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysDictDetail> 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<DictDetailMapper, Sys
wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId());
}
return super.count(wrapper);
return super.count(wrapper) == 0;
}
// ================

@ -57,8 +57,8 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
}
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 0){
boolean verificationByCode = this.uniqueVerificationByCode(model);
if(!verificationByCode){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_DICT_UNIQUE);
}
@ -74,8 +74,8 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
}
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 0){
boolean verificationByCode = this.uniqueVerificationByCode(model);
if(!verificationByCode){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_DICT_UNIQUE);
}
@ -165,9 +165,9 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByCode(DictModel model){
public boolean uniqueVerificationByCode(DictModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysDict> wrapper = new QueryWrapper<>();
@ -180,7 +180,7 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId());
}
return super.count(wrapper);
return super.count(wrapper) == 0;
}
}

@ -334,19 +334,18 @@ public class MenuServiceImpl extends CrudServiceImpl<MenuMapper, SysMenu, MenuMo
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByPermissions(MenuModel model){
public boolean uniqueVerificationByPermissions(MenuModel model){
if(model == null){
return null;
return false;
}
if(!MenuConstants.BUTTON.equals(model.getType())){
return null;
return true;
}
QueryWrapper<SysMenu> 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<MenuMapper, SysMenu, MenuMo
wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId());
}
return super.count(wrapper);
return super.count(wrapper) == 0;
}
/**

@ -67,8 +67,8 @@ public class SysOptionsServiceImpl extends CrudServiceImpl<SysOptionsMapper, Sys
ValidatorUtil.verify(model);
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 0){
boolean verificationByCode = this.uniqueVerificationByCode(model);
if(!verificationByCode){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_OPTIONS_UNIQUE);
}
@ -113,8 +113,8 @@ public class SysOptionsServiceImpl extends CrudServiceImpl<SysOptionsMapper, Sys
}
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 0){
boolean verificationByCode = this.uniqueVerificationByCode(model);
if(!verificationByCode){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_OPTIONS_UNIQUE);
}
@ -249,9 +249,9 @@ public class SysOptionsServiceImpl extends CrudServiceImpl<SysOptionsMapper, Sys
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByCode(OptionsModel model){
public boolean uniqueVerificationByCode(OptionsModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysOptions> wrapper = new QueryWrapper<>();
wrapper.eq("option_code", model.getOptionCode());
@ -261,7 +261,7 @@ public class SysOptionsServiceImpl extends CrudServiceImpl<SysOptionsMapper, Sys
wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId());
}
return super.count(wrapper);
return super.count(wrapper) == 0;
}
/**

@ -73,8 +73,8 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
model.setParentIds(null);
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 0){
boolean verificationByCode = this.uniqueVerificationByCode(model);
if(!verificationByCode){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_ORG_UNIQUE);
}
@ -114,8 +114,8 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
model.setParentIds(null);
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 0){
boolean verificationByCode = this.uniqueVerificationByCode(model);
if(!verificationByCode){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_ORG_UNIQUE);
}
@ -267,13 +267,12 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByCode(SysOrgModel model){
public boolean uniqueVerificationByCode(SysOrgModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysOrg> 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<SysOrgMapper, SysOrg, Sys
// 租户检测
wrapper = new QueryTenantHandler().handler(super.entityClazz, wrapper);
return super.count(wrapper);
return super.count(wrapper) == 0;
}

@ -92,8 +92,7 @@ public class SysOrgRestController extends BaseRestController<SysOrg, SysOrgModel
QueryBuilder<SysOrg> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysOrg> wrapper = queryBuilder.build();
UserModel currUser = UserUtil.getUser();
List<UserOrgRefModel> orgListByUserId = OrgUtil.getOrgListByUserId(currUser.getId());
List<UserOrgRefModel> orgListByUserId = OrgUtil.getOrgByCurrUser();
if(!CollUtil.isEmpty(orgListByUserId)){
List<String> parentIdList = Lists.newArrayListWithCapacity(orgListByUserId.size());

@ -72,8 +72,9 @@ public class RoleServiceImpl extends CrudServiceImpl<RoleMapper, SysRole, RoleMo
}
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 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<RoleMapper, SysRole, RoleMo
}
// 唯一验证
Integer count = this.uniqueVerificationByCode(model);
if(count != null && count > 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<RoleMapper, SysRole, RoleMo
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByCode(RoleModel model){
public boolean uniqueVerificationByCode(RoleModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysRole> 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<SysRole> 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;
}
}

@ -113,8 +113,8 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
model.setEnable(DictType.NO_YES_NO.getValue());
// 唯一验证
Integer count = this.uniqueVerificationByName(model);
if(count != null && count > 0){
boolean verificationByName = this.uniqueVerificationByName(model);
if(!verificationByName){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_TENANT_UNIQUE);
}
@ -132,8 +132,8 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
model.setEnable(null);
// 唯一验证
Integer count = this.uniqueVerificationByName(model);
if(count != null && count > 0){
boolean verificationByName = this.uniqueVerificationByName(model);
if(!verificationByName){
// 重复
throw new ServiceException(SystemMsg.EXCEPTION_TENANT_UNIQUE);
}
@ -321,9 +321,9 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByName(TenantModel model){
public boolean uniqueVerificationByName(TenantModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysTenant> wrapper = new QueryWrapper<>();
@ -336,7 +336,7 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
wrapper.notIn(MyBatisConstants.FIELD_ID, model.getId());
}
return super.count(wrapper);
return super.count(wrapper) == 0;
}
/**

@ -99,15 +99,15 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
}
}
// 唯一验证
Integer count = this.uniqueVerificationByName(model);
if(count != null && count > 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<UserMapper, SysUser, UserMo
}
// 唯一验证 - 用户名
Integer count = this.uniqueVerificationByName(model);
if(count != null && count > 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<UserMapper, SysUser, UserMo
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByNo(UserModel model){
public boolean uniqueVerificationByNo(UserModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysUser> 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<UserMapper, SysUser, UserMo
}
// 租户检测
wrapper = new QueryTenantHandler().handler(super.entityClazz, wrapper);
// 数据处理责任链
wrapper = new QueryTenantHandler(
new QueryOrgHandler()
).handler(entityClazz, wrapper);
return super.count(wrapper);
return super.count(wrapper) == 0;
}
/**
@ -775,22 +777,21 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
* @return Integer
*/
@Transactional(readOnly = true)
public Integer uniqueVerificationByName(UserModel model){
public boolean uniqueVerificationByName(UserModel model){
if(model == null){
return null;
return false;
}
QueryWrapper<SysUser> 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;
}
// ==================

Loading…
Cancel
Save