style: 优化校验相关方法命名
1.check 作为开头的方法名称,不设置返回值,对于 check 不通过的情况以异常的形式抛出(提升代码可读性,无需考虑是 check 通过了返回 true,还是 check 失败的情况下返回 true) 2.返回布尔值的方法,名称以 is 作为起始
This commit is contained in:
parent
51f552892c
commit
f25de2d7f8
@ -84,7 +84,7 @@ public class LogInterceptor implements HandlerInterceptor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response,
|
public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response,
|
||||||
@NonNull Object handler) {
|
@NonNull Object handler) {
|
||||||
if (checkIsNeedRecord(handler, request)) {
|
if (this.isNeedRecord(handler, request)) {
|
||||||
// 记录时间
|
// 记录时间
|
||||||
this.logCreateTime();
|
this.logCreateTime();
|
||||||
}
|
}
|
||||||
@ -336,15 +336,15 @@ public class LogInterceptor implements HandlerInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否要记录系统日志
|
* 是否要记录系统日志
|
||||||
*
|
*
|
||||||
* @param handler
|
* @param handler
|
||||||
* 处理器
|
* 处理器
|
||||||
* @param request
|
* @param request
|
||||||
* 请求对象
|
* 请求对象
|
||||||
* @return true 需要记录,false 不需要记录
|
* @return true 需要记录;false 不需要记录
|
||||||
*/
|
*/
|
||||||
private boolean checkIsNeedRecord(Object handler, HttpServletRequest request) {
|
private boolean isNeedRecord(Object handler, HttpServletRequest request) {
|
||||||
// 1、未启用时,不需要记录系统日志
|
// 1、未启用时,不需要记录系统日志
|
||||||
if (!(handler instanceof HandlerMethod) || Boolean.FALSE.equals(operationLogProperties.getEnabled())) {
|
if (!(handler instanceof HandlerMethod) || Boolean.FALSE.equals(operationLogProperties.getEnabled())) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -72,7 +72,7 @@ public class OnlineUserServiceImpl implements OnlineUserService {
|
|||||||
}
|
}
|
||||||
// 检查是否符合查询条件
|
// 检查是否符合查询条件
|
||||||
LoginUser loginUser = LoginHelper.getLoginUser(token);
|
LoginUser loginUser = LoginHelper.getLoginUser(token);
|
||||||
if (this.checkQuery(query, loginUser)) {
|
if (this.isMatchQuery(query, loginUser)) {
|
||||||
loginUserList.add(loginUser);
|
loginUserList.add(loginUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ public class OnlineUserServiceImpl implements OnlineUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否符合查询条件
|
* 是否符合查询条件
|
||||||
*
|
*
|
||||||
* @param query
|
* @param query
|
||||||
* 查询条件
|
* 查询条件
|
||||||
@ -103,7 +103,7 @@ public class OnlineUserServiceImpl implements OnlineUserService {
|
|||||||
* 登录用户信息
|
* 登录用户信息
|
||||||
* @return 是否符合查询条件
|
* @return 是否符合查询条件
|
||||||
*/
|
*/
|
||||||
private boolean checkQuery(OnlineUserQuery query, LoginUser loginUser) {
|
private boolean isMatchQuery(OnlineUserQuery query, LoginUser loginUser) {
|
||||||
boolean flag1 = true;
|
boolean flag1 = true;
|
||||||
String nickname = query.getNickname();
|
String nickname = query.getNickname();
|
||||||
if (StrUtil.isNotBlank(nickname)) {
|
if (StrUtil.isNotBlank(nickname)) {
|
||||||
|
@ -65,7 +65,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long add(DeptRequest request) {
|
public Long add(DeptRequest request) {
|
||||||
String name = request.getName();
|
String name = request.getName();
|
||||||
boolean isExists = this.checkNameExists(name, request.getParentId(), null);
|
boolean isExists = this.isNameExists(name, request.getParentId(), null);
|
||||||
CheckUtils.throwIf(isExists, "新增失败,[{}] 已存在", name);
|
CheckUtils.throwIf(isExists, "新增失败,[{}] 已存在", name);
|
||||||
request.setAncestors(this.getAncestors(request.getParentId()));
|
request.setAncestors(this.getAncestors(request.getParentId()));
|
||||||
request.setStatus(DisEnableStatusEnum.DISABLE);
|
request.setStatus(DisEnableStatusEnum.DISABLE);
|
||||||
@ -76,7 +76,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(DeptRequest request, Long id) {
|
public void update(DeptRequest request, Long id) {
|
||||||
String name = request.getName();
|
String name = request.getName();
|
||||||
boolean isExists = this.checkNameExists(name, request.getParentId(), id);
|
boolean isExists = this.isNameExists(name, request.getParentId(), id);
|
||||||
CheckUtils.throwIf(isExists, "修改失败,[{}] 已存在", name);
|
CheckUtils.throwIf(isExists, "修改失败,[{}] 已存在", name);
|
||||||
DeptDO oldDept = super.getById(id);
|
DeptDO oldDept = super.getById(id);
|
||||||
String oldName = oldDept.getName();
|
String oldName = oldDept.getName();
|
||||||
@ -137,7 +137,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查名称是否存在
|
* 名称是否存在
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* 名称
|
* 名称
|
||||||
@ -147,7 +147,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkNameExists(String name, Long parentId, Long id) {
|
private boolean isNameExists(String name, Long parentId, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(DeptDO::getName, name).eq(DeptDO::getParentId, parentId)
|
return baseMapper.lambdaQuery().eq(DeptDO::getName, name).eq(DeptDO::getParentId, parentId)
|
||||||
.ne(null != id, DeptDO::getId, id).exists();
|
.ne(null != id, DeptDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class DictItemServiceImpl
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long add(DictItemRequest request) {
|
public Long add(DictItemRequest request) {
|
||||||
String value = request.getValue();
|
String value = request.getValue();
|
||||||
CheckUtils.throwIf(this.checkValueExists(value, null, request.getDictId()), "新增失败,字典值 [{}] 已存在", value);
|
CheckUtils.throwIf(this.isValueExists(value, null, request.getDictId()), "新增失败,字典值 [{}] 已存在", value);
|
||||||
return super.add(request);
|
return super.add(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class DictItemServiceImpl
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(DictItemRequest request, Long id) {
|
public void update(DictItemRequest request, Long id) {
|
||||||
String value = request.getValue();
|
String value = request.getValue();
|
||||||
CheckUtils.throwIf(this.checkValueExists(value, id, request.getDictId()), "修改失败,字典值 [{}] 已存在", value);
|
CheckUtils.throwIf(this.isValueExists(value, id, request.getDictId()), "修改失败,字典值 [{}] 已存在", value);
|
||||||
super.update(request, id);
|
super.update(request, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public class DictItemServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查字典值是否存在
|
* 字典值是否存在
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* 字典值
|
* 字典值
|
||||||
@ -102,7 +102,7 @@ public class DictItemServiceImpl
|
|||||||
* 字典 ID
|
* 字典 ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkValueExists(String value, Long id, Long dictId) {
|
private boolean isValueExists(String value, Long id, Long dictId) {
|
||||||
return baseMapper.lambdaQuery().eq(DictItemDO::getValue, value).eq(DictItemDO::getDictId, dictId)
|
return baseMapper.lambdaQuery().eq(DictItemDO::getValue, value).eq(DictItemDO::getDictId, dictId)
|
||||||
.ne(null != id, DictItemDO::getId, id).exists();
|
.ne(null != id, DictItemDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,9 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long add(DictRequest request) {
|
public Long add(DictRequest request) {
|
||||||
String name = request.getName();
|
String name = request.getName();
|
||||||
CheckUtils.throwIf(this.checkNameExists(name, null), "新增失败,[{}] 已存在", name);
|
CheckUtils.throwIf(this.isNameExists(name, null), "新增失败,[{}] 已存在", name);
|
||||||
String code = request.getCode();
|
String code = request.getCode();
|
||||||
CheckUtils.throwIf(this.checkCodeExists(code, null), "新增失败,[{}] 已存在", code);
|
CheckUtils.throwIf(this.isCodeExists(code, null), "新增失败,[{}] 已存在", code);
|
||||||
return super.add(request);
|
return super.add(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,9 +66,9 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(DictRequest request, Long id) {
|
public void update(DictRequest request, Long id) {
|
||||||
String name = request.getName();
|
String name = request.getName();
|
||||||
CheckUtils.throwIf(this.checkNameExists(name, id), "修改失败,[{}] 已存在", name);
|
CheckUtils.throwIf(this.isNameExists(name, id), "修改失败,[{}] 已存在", name);
|
||||||
String code = request.getCode();
|
String code = request.getCode();
|
||||||
CheckUtils.throwIf(this.checkCodeExists(code, id), "修改失败,[{}] 已存在", code);
|
CheckUtils.throwIf(this.isCodeExists(code, id), "修改失败,[{}] 已存在", code);
|
||||||
DictDO oldDict = super.getById(id);
|
DictDO oldDict = super.getById(id);
|
||||||
if (oldDict.getIsSystem()) {
|
if (oldDict.getIsSystem()) {
|
||||||
CheckUtils.throwIfNotEqual(request.getCode(), oldDict.getCode(), "[{}] 是系统内置字典,不允许修改字典编码",
|
CheckUtils.throwIfNotEqual(request.getCode(), oldDict.getCode(), "[{}] 是系统内置字典,不允许修改字典编码",
|
||||||
@ -105,7 +105,7 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictVO,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查名称是否存在
|
* 名称是否存在
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* 名称
|
* 名称
|
||||||
@ -113,12 +113,12 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkNameExists(String name, Long id) {
|
private boolean isNameExists(String name, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(DictDO::getName, name).ne(null != id, DictDO::getId, id).exists();
|
return baseMapper.lambdaQuery().eq(DictDO::getName, name).ne(null != id, DictDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查编码是否存在
|
* 编码是否存在
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* 编码
|
* 编码
|
||||||
@ -126,7 +126,7 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkCodeExists(String code, Long id) {
|
private boolean isCodeExists(String code, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(DictDO::getCode, code).ne(null != id, DictDO::getId, id).exists();
|
return baseMapper.lambdaQuery().eq(DictDO::getCode, code).ne(null != id, DictDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -56,8 +56,7 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long add(MenuRequest request) {
|
public Long add(MenuRequest request) {
|
||||||
String title = request.getTitle();
|
String title = request.getTitle();
|
||||||
boolean isExists = this.checkNameExists(title, request.getParentId(), null);
|
CheckUtils.throwIf(this.isNameExists(title, request.getParentId(), null), "新增失败,[{}] 已存在", title);
|
||||||
CheckUtils.throwIf(isExists, "新增失败,[{}] 已存在", title);
|
|
||||||
request.setStatus(DisEnableStatusEnum.ENABLE);
|
request.setStatus(DisEnableStatusEnum.ENABLE);
|
||||||
return super.add(request);
|
return super.add(request);
|
||||||
}
|
}
|
||||||
@ -67,8 +66,7 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(MenuRequest request, Long id) {
|
public void update(MenuRequest request, Long id) {
|
||||||
String title = request.getTitle();
|
String title = request.getTitle();
|
||||||
boolean isExists = this.checkNameExists(title, request.getParentId(), id);
|
CheckUtils.throwIf(this.isNameExists(title, request.getParentId(), id), "修改失败,[{}] 已存在", title);
|
||||||
CheckUtils.throwIf(isExists, "修改失败,[{}] 已存在", title);
|
|
||||||
super.update(request, id);
|
super.update(request, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +101,7 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuVO,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查名称是否存在
|
* 名称是否存在
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* 名称
|
* 名称
|
||||||
@ -113,7 +111,7 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkNameExists(String name, Long parentId, Long id) {
|
private boolean isNameExists(String name, Long parentId, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(MenuDO::getTitle, name).eq(MenuDO::getParentId, parentId)
|
return baseMapper.lambdaQuery().eq(MenuDO::getTitle, name).eq(MenuDO::getParentId, parentId)
|
||||||
.ne(null != id, MenuDO::getId, id).exists();
|
.ne(null != id, MenuDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,9 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long add(RoleRequest request) {
|
public Long add(RoleRequest request) {
|
||||||
String name = request.getName();
|
String name = request.getName();
|
||||||
CheckUtils.throwIf(this.checkNameExists(name, null), "新增失败,[{}] 已存在", name);
|
CheckUtils.throwIf(this.isNameExists(name, null), "新增失败,[{}] 已存在", name);
|
||||||
String code = request.getCode();
|
String code = request.getCode();
|
||||||
CheckUtils.throwIf(this.checkCodeExists(code, null), "新增失败,[{}] 已存在", code);
|
CheckUtils.throwIf(this.isCodeExists(code, null), "新增失败,[{}] 已存在", code);
|
||||||
// 新增信息
|
// 新增信息
|
||||||
request.setStatus(DisEnableStatusEnum.ENABLE);
|
request.setStatus(DisEnableStatusEnum.ENABLE);
|
||||||
Long roleId = super.add(request);
|
Long roleId = super.add(request);
|
||||||
@ -86,9 +86,9 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(RoleRequest request, Long id) {
|
public void update(RoleRequest request, Long id) {
|
||||||
String name = request.getName();
|
String name = request.getName();
|
||||||
CheckUtils.throwIf(this.checkNameExists(name, id), "修改失败,[{}] 已存在", name);
|
CheckUtils.throwIf(this.isNameExists(name, id), "修改失败,[{}] 已存在", name);
|
||||||
String code = request.getCode();
|
String code = request.getCode();
|
||||||
CheckUtils.throwIf(this.checkCodeExists(code, id), "修改失败,[{}] 已存在", code);
|
CheckUtils.throwIf(this.isCodeExists(code, id), "修改失败,[{}] 已存在", code);
|
||||||
RoleDO oldRole = super.getById(id);
|
RoleDO oldRole = super.getById(id);
|
||||||
DataScopeEnum oldDataScope = oldRole.getDataScope();
|
DataScopeEnum oldDataScope = oldRole.getDataScope();
|
||||||
String oldCode = oldRole.getCode();
|
String oldCode = oldRole.getCode();
|
||||||
@ -184,7 +184,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查名称是否存在
|
* 名称是否存在
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* 名称
|
* 名称
|
||||||
@ -192,12 +192,12 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkNameExists(String name, Long id) {
|
private boolean isNameExists(String name, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(RoleDO::getName, name).ne(null != id, RoleDO::getId, id).exists();
|
return baseMapper.lambdaQuery().eq(RoleDO::getName, name).ne(null != id, RoleDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查编码是否存在
|
* 编码是否存在
|
||||||
*
|
*
|
||||||
* @param code
|
* @param code
|
||||||
* 编码
|
* 编码
|
||||||
@ -205,7 +205,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkCodeExists(String code, Long id) {
|
private boolean isCodeExists(String code, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(RoleDO::getCode, code).ne(null != id, RoleDO::getId, id).exists();
|
return baseMapper.lambdaQuery().eq(RoleDO::getCode, code).ne(null != id, RoleDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,11 +91,11 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long add(UserRequest request) {
|
public Long add(UserRequest request) {
|
||||||
String username = request.getUsername();
|
String username = request.getUsername();
|
||||||
CheckUtils.throwIf(this.checkNameExists(username, null), "新增失败,[{}] 已存在", username);
|
CheckUtils.throwIf(this.isNameExists(username, null), "新增失败,[{}] 已存在", username);
|
||||||
String email = request.getEmail();
|
String email = request.getEmail();
|
||||||
CheckUtils.throwIf(StrUtil.isNotBlank(email) && this.checkEmailExists(email, null), "新增失败,[{}] 已存在", email);
|
CheckUtils.throwIf(StrUtil.isNotBlank(email) && this.isEmailExists(email, null), "新增失败,[{}] 已存在", email);
|
||||||
String phone = request.getPhone();
|
String phone = request.getPhone();
|
||||||
CheckUtils.throwIf(StrUtil.isNotBlank(phone) && this.checkPhoneExists(phone, null), "新增失败,[{}] 已存在", phone);
|
CheckUtils.throwIf(StrUtil.isNotBlank(phone) && this.isPhoneExists(phone, null), "新增失败,[{}] 已存在", phone);
|
||||||
// 新增信息
|
// 新增信息
|
||||||
request.setStatus(DisEnableStatusEnum.ENABLE);
|
request.setStatus(DisEnableStatusEnum.ENABLE);
|
||||||
Long userId = super.add(request);
|
Long userId = super.add(request);
|
||||||
@ -111,11 +111,11 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(UserRequest request, Long id) {
|
public void update(UserRequest request, Long id) {
|
||||||
String username = request.getUsername();
|
String username = request.getUsername();
|
||||||
CheckUtils.throwIf(this.checkNameExists(username, id), "修改失败,[{}] 已存在", username);
|
CheckUtils.throwIf(this.isNameExists(username, id), "修改失败,[{}] 已存在", username);
|
||||||
String email = request.getEmail();
|
String email = request.getEmail();
|
||||||
CheckUtils.throwIf(StrUtil.isNotBlank(email) && this.checkEmailExists(email, id), "修改失败,[{}] 已存在", email);
|
CheckUtils.throwIf(StrUtil.isNotBlank(email) && this.isEmailExists(email, id), "修改失败,[{}] 已存在", email);
|
||||||
String phone = request.getPhone();
|
String phone = request.getPhone();
|
||||||
CheckUtils.throwIf(StrUtil.isNotBlank(phone) && this.checkPhoneExists(phone, id), "修改失败,[{}] 已存在", phone);
|
CheckUtils.throwIf(StrUtil.isNotBlank(phone) && this.isPhoneExists(phone, id), "修改失败,[{}] 已存在", phone);
|
||||||
DisEnableStatusEnum newStatus = request.getStatus();
|
DisEnableStatusEnum newStatus = request.getStatus();
|
||||||
CheckUtils.throwIf(
|
CheckUtils.throwIf(
|
||||||
DisEnableStatusEnum.DISABLE.equals(newStatus) && ObjectUtil.equal(id, LoginHelper.getUserId()),
|
DisEnableStatusEnum.DISABLE.equals(newStatus) && ObjectUtil.equal(id, LoginHelper.getUserId()),
|
||||||
@ -261,7 +261,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查名称是否存在
|
* 名称是否存在
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* 名称
|
* 名称
|
||||||
@ -269,12 +269,12 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkNameExists(String name, Long id) {
|
private boolean isNameExists(String name, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(UserDO::getUsername, name).ne(null != id, UserDO::getId, id).exists();
|
return baseMapper.lambdaQuery().eq(UserDO::getUsername, name).ne(null != id, UserDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查邮箱是否存在
|
* 邮箱是否存在
|
||||||
*
|
*
|
||||||
* @param email
|
* @param email
|
||||||
* 邮箱
|
* 邮箱
|
||||||
@ -282,12 +282,12 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkEmailExists(String email, Long id) {
|
private boolean isEmailExists(String email, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(UserDO::getEmail, email).ne(null != id, UserDO::getId, id).exists();
|
return baseMapper.lambdaQuery().eq(UserDO::getEmail, email).ne(null != id, UserDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查手机号码是否存在
|
* 手机号码是否存在
|
||||||
*
|
*
|
||||||
* @param phone
|
* @param phone
|
||||||
* 手机号码
|
* 手机号码
|
||||||
@ -295,7 +295,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
|||||||
* ID
|
* ID
|
||||||
* @return 是否存在
|
* @return 是否存在
|
||||||
*/
|
*/
|
||||||
private boolean checkPhoneExists(String phone, Long id) {
|
private boolean isPhoneExists(String phone, Long id) {
|
||||||
return baseMapper.lambdaQuery().eq(UserDO::getPhone, phone).ne(null != id, UserDO::getId, id).exists();
|
return baseMapper.lambdaQuery().eq(UserDO::getPhone, phone).ne(null != id, UserDO::getId, id).exists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user