修复租户名的重复问题 + 配合周建进行测试所提bug的后端修改
This commit is contained in:
parent
79228bd947
commit
83d2e79f96
@ -24,8 +24,11 @@ public class CodegenTablePageReqVO extends PageParam {
|
|||||||
@Schema(description = "表描述,模糊匹配", example = "芋道")
|
@Schema(description = "表描述,模糊匹配", example = "芋道")
|
||||||
private String tableComment;
|
private String tableComment;
|
||||||
|
|
||||||
|
@Schema(description = "实体,模糊匹配", example = "Yudao")
|
||||||
|
private String className;
|
||||||
|
|
||||||
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
|
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime[] createTime;
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,11 @@ public class ConfigBaseVO {
|
|||||||
@Size(max = 500, message = "参数键值长度不能超过500个字符")
|
@Size(max = 500, message = "参数键值长度不能超过500个字符")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
@Schema(description = "是否敏感", required = true, example = "true")
|
@Schema(description = "是否可见", required = true, example = "true")
|
||||||
@NotNull(message = "是否敏感不能为空")
|
@NotNull(message = "是否可见不能为空")
|
||||||
private Boolean visible;
|
private Boolean visible;
|
||||||
|
|
||||||
@Schema(description = "备注", example = "备注一下很帅气!")
|
@Schema(description = "备注", example = "备注一下很帅气!")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@ public class ConfigExcelVO {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ExcelProperty("参数键名")
|
@ExcelProperty("参数键名")
|
||||||
private String key;
|
private String configKey;
|
||||||
|
|
||||||
@ExcelProperty("参数分组")
|
@ExcelProperty("参数分类")
|
||||||
private String group;
|
private String category;
|
||||||
|
|
||||||
@ExcelProperty("参数名称")
|
@ExcelProperty("参数名称")
|
||||||
private String name;
|
private String name;
|
||||||
@ -33,9 +33,9 @@ public class ConfigExcelVO {
|
|||||||
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@ExcelProperty(value = "是否敏感", converter = DictConvert.class)
|
@ExcelProperty(value = "是否可见", converter = DictConvert.class)
|
||||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||||
private Boolean sensitive;
|
private Boolean visible;
|
||||||
|
|
||||||
@ExcelProperty("备注")
|
@ExcelProperty("备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
@ -21,6 +21,7 @@ public interface CodegenTableMapper extends BaseMapperX<CodegenTableDO> {
|
|||||||
return selectPage(pageReqVO, new LambdaQueryWrapperX<CodegenTableDO>()
|
return selectPage(pageReqVO, new LambdaQueryWrapperX<CodegenTableDO>()
|
||||||
.likeIfPresent(CodegenTableDO::getTableName, pageReqVO.getTableName())
|
.likeIfPresent(CodegenTableDO::getTableName, pageReqVO.getTableName())
|
||||||
.likeIfPresent(CodegenTableDO::getTableComment, pageReqVO.getTableComment())
|
.likeIfPresent(CodegenTableDO::getTableComment, pageReqVO.getTableComment())
|
||||||
|
.likeIfPresent(CodegenTableDO::getClassName, pageReqVO.getClassName())
|
||||||
.betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getCreateTime()));
|
.betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getCreateTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode TENANT_DISABLE = new ErrorCode(1002015001, "名字为【{}】的租户已被禁用");
|
ErrorCode TENANT_DISABLE = new ErrorCode(1002015001, "名字为【{}】的租户已被禁用");
|
||||||
ErrorCode TENANT_EXPIRE = new ErrorCode(1002015002, "名字为【{}】的租户已过期");
|
ErrorCode TENANT_EXPIRE = new ErrorCode(1002015002, "名字为【{}】的租户已过期");
|
||||||
ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1002015003, "系统租户不能进行修改、删除等操作!");
|
ErrorCode TENANT_CAN_NOT_UPDATE_SYSTEM = new ErrorCode(1002015003, "系统租户不能进行修改、删除等操作!");
|
||||||
|
ErrorCode TENANT_NAME_DUPLICATE = new ErrorCode(1002015004, "已经存在该名称的租户");
|
||||||
|
|
||||||
// ========== 租户套餐 1002016000 ==========
|
// ========== 租户套餐 1002016000 ==========
|
||||||
ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002016000, "租户套餐不存在");
|
ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002016000, "租户套餐不存在");
|
||||||
|
@ -97,6 +97,8 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createTenant(TenantCreateReqVO createReqVO) {
|
public Long createTenant(TenantCreateReqVO createReqVO) {
|
||||||
|
// 校验租户名称是否重复
|
||||||
|
validTenantNameDuplicate(createReqVO.getName(), null);
|
||||||
// 校验套餐被禁用
|
// 校验套餐被禁用
|
||||||
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId());
|
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(createReqVO.getPackageId());
|
||||||
|
|
||||||
@ -139,6 +141,8 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
public void updateTenant(TenantUpdateReqVO updateReqVO) {
|
public void updateTenant(TenantUpdateReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
TenantDO tenant = validateUpdateTenant(updateReqVO.getId());
|
||||||
|
// 校验租户名称是否重复
|
||||||
|
validTenantNameDuplicate(updateReqVO.getName(), updateReqVO.getId());
|
||||||
// 校验套餐被禁用
|
// 校验套餐被禁用
|
||||||
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
|
TenantPackageDO tenantPackage = tenantPackageService.validTenantPackage(updateReqVO.getPackageId());
|
||||||
|
|
||||||
@ -151,6 +155,20 @@ public class TenantServiceImpl implements TenantService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validTenantNameDuplicate(String name, Long id) {
|
||||||
|
TenantDO tenant = tenantMapper.selectByName(name);
|
||||||
|
if (tenant == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 如果 id 为空,说明不用比较是否为相同名字的租户
|
||||||
|
if (id == null) {
|
||||||
|
throw exception(TENANT_NAME_DUPLICATE, name);
|
||||||
|
}
|
||||||
|
if (!tenant.getId().equals(id)) {
|
||||||
|
throw exception(TENANT_NAME_DUPLICATE, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) {
|
public void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds) {
|
||||||
|
Loading…
Reference in New Issue
Block a user