refactor(tenant): 优化租户管理表字段设计

This commit is contained in:
2025-07-27 14:11:58 +08:00
parent f350ee1567
commit 819be0688d
9 changed files with 76 additions and 56 deletions

View File

@@ -49,7 +49,7 @@ public class TenantDO extends BaseDO {
private String code;
/**
* 绑定域名
* 域名
*/
private String domain;
@@ -69,10 +69,15 @@ public class TenantDO extends BaseDO {
private DisEnableStatusEnum status;
/**
* 租户管理员
* 管理员用户
*/
private Long adminUser;
/**
* 管理员用户名
*/
private String adminUsername;
/**
* 套餐 ID
*/

View File

@@ -54,11 +54,11 @@ public class TenantReq implements Serializable {
private String name;
/**
* 绑定域名
* 域名
*/
@Schema(description = "绑定域名", example = "https://T0sL6RWv0vFh.continew.top/")
@Length(max = 255, message = "绑定域名长度不能超过 {max} 个字符")
@Pattern(regexp = RegexConstants.HTTP_HOST, message = "绑定域名格式不正确")
@Schema(description = "域名", example = "https://T0sL6RWv0vFh.continew.top/")
@Length(max = 255, message = "域名长度不能超过 {max} 个字符")
@Pattern(regexp = RegexConstants.HTTP_HOST, message = "域名格式不正确")
private String domain;
/**
@@ -89,19 +89,19 @@ public class TenantReq implements Serializable {
private Long packageId;
/**
* 用户名
* 管理员用户名
*/
@Schema(description = "用户名", example = "zhangsan")
@NotBlank(message = "用户名不能为空", groups = CrudValidationGroup.Create.class)
@Pattern(regexp = RegexConstants.USERNAME, message = "用户名长度为 4-64 个字符,支持大小写字母、数字、下划线,以字母开头")
private String username;
@Schema(description = "管理员用户名", example = "zhangsan")
@NotBlank(message = "管理员用户名不能为空", groups = CrudValidationGroup.Create.class)
@Pattern(regexp = RegexConstants.USERNAME, message = "管理员用户名长度为 4-64 个字符,支持大小写字母、数字、下划线,以字母开头")
private String adminUsername;
/**
* 密码(加密)
* 管理员密码(加密)
*/
@Schema(description = "密码(加密)", example = "E7c72TH+LDxKTwavjM99W1MdI9Lljh79aPKiv3XB9MXcplhm7qJ1BJCj28yaflbdVbfc366klMtjLIWQGqb0qw==")
@NotBlank(message = "密码不能为空", groups = CrudValidationGroup.Create.class)
private String password;
@Schema(description = "管理员密码(加密)", example = "E7c72TH+LDxKTwavjM99W1MdI9Lljh79aPKiv3XB9MXcplhm7qJ1BJCj28yaflbdVbfc366klMtjLIWQGqb0qw==")
@NotBlank(message = "管理员密码不能为空", groups = CrudValidationGroup.Create.class)
private String adminPassword;
/**
* 编码

View File

@@ -61,10 +61,10 @@ public class TenantResp extends BaseDetailResp {
private String code;
/**
* 绑定域名
* 域名
*/
@Schema(description = "绑定域名", example = "https://T0sL6RWv0vFh.continew.top/")
@ExcelProperty(value = "绑定域名", order = 4)
@Schema(description = "域名", example = "T0sL6RWv0vFh.continew.top")
@ExcelProperty(value = "域名", order = 4)
private String domain;
/**
@@ -88,11 +88,23 @@ public class TenantResp extends BaseDetailResp {
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class, order = 8)
private DisEnableStatusEnum status;
/**
* 管理员用户
*/
@Schema(description = "管理员用户", example = "2")
private Long adminUser;
/**
* 管理员用户名
*/
@Schema(description = "管理员用户名", example = "admin")
@ExcelProperty(value = "管理员用户名", order = 9)
private String adminUsername;
/**
* 套餐 ID
*/
@Schema(description = "套餐 ID", example = "1")
@ExcelProperty(value = "套餐 ID", order = 9)
@AssembleMethod(props = @Mapping(src = "name", ref = "packageName"), targetType = PackageService.class, method = @ContainerMethod(bindMethod = "get", resultType = PackageResp.class))
private Long packageId;

View File

@@ -36,9 +36,9 @@ import java.util.List;
public interface TenantService extends BaseService<TenantResp, TenantDetailResp, TenantQuery, TenantReq>, IService<TenantDO> {
/**
* 根据绑定域名查询
* 根据域名查询
*
* @param domain 绑定域名
* @param domain 域名
* @return ID
*/
Long getIdByDomain(String domain);

View File

@@ -197,16 +197,16 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, TenantDO, T
}
/**
* 检查绑定域名是否重复
* 检查域名是否重复
*
* @param domain 绑定域名
* @param domain 域名
* @param id ID
*/
private void checkDomainRepeat(String domain, Long id) {
CheckUtils.throwIf(baseMapper.lambdaQuery()
.eq(TenantDO::getDomain, domain)
.ne(id != null, TenantDO::getId, id)
.exists(), "绑定域名为 [{}] 的租户已存在", domain);
.exists(), "域名为 [{}] 的租户已存在", domain);
}
/**