支持多层级租户,租户父子关系依托与组织机构的父子关系

This commit is contained in:
陈博文
2025-06-20 08:50:06 +08:00
parent 64806dc406
commit 88e19e79e6
33 changed files with 808 additions and 306 deletions

View File

@@ -58,6 +58,8 @@ public interface ErrorCodeConstants {
ErrorCode DEPT_PARENT_ERROR = new ErrorCode(1_002_004_004, "不能设置自己为父部门");
ErrorCode DEPT_NOT_ENABLE = new ErrorCode(1_002_004_006, "部门({})不处于开启状态,不允许选择");
ErrorCode DEPT_PARENT_IS_CHILD = new ErrorCode(1_002_004_007, "不能设置自己的子部门为父部门");
ErrorCode DEPT_TENANT_RELATION_EXISTS = new ErrorCode(1_002_004_008, "当前租户已经关联组织机构");
// ========== 岗位模块 1-002-005-000 ==========
ErrorCode POST_NOT_FOUND = new ErrorCode(1_002_005_000, "当前岗位不存在");
@@ -171,4 +173,6 @@ public interface ErrorCodeConstants {
// ========== 站内信发送 1-002-028-000 ==========
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
// ========== 用户-租户关系 ==========
ErrorCode USER_TENANT_NOT_EXISTS = new ErrorCode(1_002_028_000, "用户-租户关系不存在");
}

View File

@@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*;
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
@@ -65,6 +66,7 @@ public class AuthController {
@PostMapping("/login")
@PermitAll
@Operation(summary = "使用账号密码登录")
@TenantIgnore
public CommonResult<AuthLoginRespVO> login(@RequestBody @Valid AuthLoginReqVO reqVO) {
return success(authService.login(reqVO));
}

View File

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.dept;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
@@ -12,16 +13,19 @@ import cn.iocoder.yudao.module.system.service.dept.DeptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* @author chenbowen
*/
@Tag(name = "管理后台 - 部门")
@RestController
@RequestMapping("/system/dept")
@@ -42,6 +46,7 @@ public class DeptController {
@PutMapping("update")
@Operation(summary = "更新部门")
@PreAuthorize("@ss.hasPermission('system:dept:update')")
@TenantIgnore
public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptSaveReqVO updateReqVO) {
deptService.updateDept(updateReqVO);
return success(true);

View File

@@ -5,6 +5,9 @@ import lombok.Data;
import java.time.LocalDateTime;
/**
* @author chenbowen
*/
@Schema(description = "管理后台 - 部门信息 Response VO")
@Data
public class DeptRespVO {
@@ -36,4 +39,10 @@ public class DeptRespVO {
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
private LocalDateTime createTime;
@Schema(description = "组织机构是否租户", example = "true")
private Boolean isTenant = false;
@Schema(description = "租户编号", example = "1024")
private Long tenantId;
}

View File

@@ -9,6 +9,9 @@ import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
/**
* @author chenbowen
*/
@Schema(description = "管理后台 - 部门创建/修改 Request VO")
@Data
public class DeptSaveReqVO {
@@ -45,4 +48,10 @@ public class DeptSaveReqVO {
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
@Schema(description = "组织机构是否租户", example = "true")
private Boolean isTenant = false;
@Schema(description = "租户编号", example = "1024")
private Long tenantId;
}

View File

@@ -5,6 +5,9 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author chenbowen
*/
@Schema(description = "管理后台 - 部门精简信息 Response VO")
@Data
@NoArgsConstructor

View File

@@ -43,7 +43,7 @@ public class RoleSaveReqVO {
private Integer status;
@Schema(description = "角色类型", example = "1 内置角色2 标准角色3 租户自定义角色")
private String type;
private Integer type;
@Schema(description = "父级角色Id", example = "-1 系统角色0 顶级角色")
private Long parentId;

View File

@@ -10,6 +10,9 @@ import lombok.Data;
import java.time.LocalDateTime;
/**
* @author chenbowen
*/
@Schema(description = "管理后台 - 租户 Response VO")
@Data
@ExcelIgnoreUnannotated

View File

@@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.controller.admin.usertenant.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 用户-租户关系分页 Request VO")
@Data
public class UserTenantPageReqVO extends PageParam {
@Schema(description = "用户ID", example = "32426")
private Long userId;
@Schema(description = "租户ID", example = "30027")
private Long tenantId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

Some files were not shown because too many files have changed in this diff Show More