feat(tenant): 更新租户类型枚举注释及名称
将 TenantType 枚举中的“达人”修改为“团长”,并同步更新注释描述。 refactor(exception): 统一系统异常返回信息全局异常处理器中,针对 ServletException、RuntimeException 和 Exception 的处理方法返回统一的错误提示:“系统异常,请联系管理员”。 refactor(tenant):优化租户用户名存在性校验逻辑
This commit is contained in:
parent
e8685c3eba
commit
fa81755e25
@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 租户类型枚举 2->商家,3->代理,4->平台,5->达人
|
||||
* 租户类型枚举 2->商家,3->代理,4->平台,5->团长
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@ -13,7 +13,7 @@ public enum TenantType {
|
||||
MERCHANT(2, "商家"),
|
||||
AGENT(3, "代理"),
|
||||
PLATFORM(4, "平台"),
|
||||
REFERENCE(5, "达人");
|
||||
REFERENCE(5, "团长");
|
||||
|
||||
private final int type;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class GlobalExceptionHandler {
|
||||
public R<Void> handleServletException(ServletException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
return R.fail(e.getMessage());
|
||||
return R.fail("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +137,7 @@ public class GlobalExceptionHandler {
|
||||
public R<Void> handleRuntimeException(RuntimeException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
return R.fail(e.getMessage());
|
||||
return R.fail("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,7 +147,7 @@ public class GlobalExceptionHandler {
|
||||
public R<Void> handleException(Exception e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return R.fail(e.getMessage());
|
||||
return R.fail("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,6 +74,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
private final SysDictTypeMapper dictTypeMapper;
|
||||
private final SysDictDataMapper dictDataMapper;
|
||||
private final SysConfigMapper configMapper;
|
||||
private final SysUserMapper sysUserMapper;
|
||||
|
||||
/**
|
||||
* 查询租户
|
||||
@ -224,15 +225,10 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
// 检查用户名是否已存在
|
||||
String username = bo.getUsername();
|
||||
if (StringUtils.isNotBlank(username)) {
|
||||
LambdaQueryWrapper<SysTenantExtend> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysTenantExtend::getUsername, username);
|
||||
Long count = tenantExtendMapper.selectCount(queryWrapper);
|
||||
|
||||
if (count > 0) {
|
||||
throw new ServiceException("用户名已存在,请更换其他用户名");
|
||||
}else{
|
||||
tenantExtend.setUsername(username);
|
||||
}
|
||||
Long count1 = tenantExtendMapper.selectCount(Wrappers.lambdaQuery(SysTenantExtend.class).eq(SysTenantExtend::getUsername, username));
|
||||
Long count2 = sysUserMapper.selectCount(Wrappers.lambdaQuery(SysUser.class).eq(SysUser::getUserName, username));
|
||||
Assert.isTrue(count1 == 0 && count2 == 0, () -> new ServiceException("用户名已存在,请更换其他用户名"));
|
||||
tenantExtend.setUsername(username);
|
||||
}
|
||||
tenantExtend.setPassword(bo.getPassword());
|
||||
tenantExtend.setPackageId(bo.getPackageId());
|
||||
|
Loading…
x
Reference in New Issue
Block a user