feat(system): 增加租户创建权限并优化租户相关功能
- 修改代理商租户类型创建权限,允许创建代理商、商户和达人类型 - 在 SysTenant 模型中添加 parentIds 字段,用于存储所有父级 ID - 在 SysTenantPackageServiceImpl 中添加对租户类型筛选的支持- 优化 SysTenantServiceImpl 中的租户创建逻辑,设置正确的 parentIds - 在 SysTenantVo 和 TenantDTO 中添加 parentIds 字段的定义
This commit is contained in:
parent
e54ff633d8
commit
e74226d2d4
@ -36,7 +36,7 @@ public enum TenantType {
|
||||
allow = true;
|
||||
} else if (currentTenantType == TenantType.AGENT.type) {
|
||||
// 代理商只能创建商铺或达人
|
||||
allow = newTenantType == TenantType.MERCHANT.type || newTenantType == TenantType.REFERENCE.type;
|
||||
allow = newTenantType == TenantType.AGENT.type || newTenantType == TenantType.MERCHANT.type || newTenantType == TenantType.REFERENCE.type;
|
||||
}
|
||||
return allow;
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public class SysTenant extends BaseEntity {
|
||||
@Schema(description = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "所有父级id")
|
||||
private String parentIds;
|
||||
|
||||
@Schema(description = "企业名称")
|
||||
private String companyName;
|
||||
|
||||
|
@ -11,8 +11,6 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class TenantDTO {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
@TableId(value = "id")
|
||||
@ -21,6 +19,9 @@ public class TenantDTO {
|
||||
@Schema(description = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "所有父级id")
|
||||
private String parentIds;
|
||||
|
||||
@Schema(description = "企业名称")
|
||||
private String companyName;
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package org.dromara.system.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -14,7 +11,6 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -37,6 +33,9 @@ public class SysTenantVo implements Serializable {
|
||||
@Schema(description = "租户编号")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "所有父级id")
|
||||
private String parentIds;
|
||||
|
||||
@Schema(description = "企业名称")
|
||||
private String companyName;
|
||||
|
||||
|
@ -75,6 +75,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
||||
private LambdaQueryWrapper<SysTenantPackage> buildQueryWrapper(SysTenantPackageBo bo) {
|
||||
LambdaQueryWrapper<SysTenantPackage> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getPackageName()), SysTenantPackage::getPackageName, bo.getPackageName());
|
||||
lqw.like(bo.getTenantType() != null, SysTenantPackage::getTenantType, bo.getTenantType());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysTenantPackage::getStatus, bo.getStatus());
|
||||
lqw.orderByAsc(SysTenantPackage::getPackageId);
|
||||
return lqw;
|
||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -136,8 +137,8 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
SysTenant tenant = new SysTenant();
|
||||
|
||||
String currentTenantId = LoginHelper.getTenantId();
|
||||
SysTenantVo sysTenantVo = this.queryByTenantId(currentTenantId);
|
||||
Assert.isTrue(TenantType.allowCreateByType(sysTenantVo.getType(), bo.getType()), () -> new ServiceException("您无权限创建此类型的租户"));
|
||||
SysTenantVo currentTenant = this.queryByTenantId(currentTenantId);
|
||||
Assert.isTrue(TenantType.allowCreateByType(currentTenant.getType(), bo.getType()), () -> new ServiceException("您无权限创建此类型的租户"));
|
||||
|
||||
// 生成租户ID
|
||||
List<String> tenantIds = baseMapper.selectObjs(
|
||||
@ -156,6 +157,8 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
}
|
||||
// 设置sys_tenant表字段
|
||||
tenant.setTenantId(tenantId);
|
||||
String parentIds = StrUtil.isBlank(currentTenant.getParentIds()) ? String.valueOf(currentTenant.getId()) : StrBuilder.create(currentTenant.getParentIds()).append(",").append(currentTenant.getId()).toString();
|
||||
tenant.setParentIds(parentIds);
|
||||
tenant.setCompanyName(StrUtil.isBlank(bo.getCompanyName()) ? tenantName : bo.getCompanyName());
|
||||
tenant.setLicenseNumber(bo.getLicenseNumber());
|
||||
tenant.setAddress(bo.getAddress());
|
||||
|
Loading…
x
Reference in New Issue
Block a user