支持多层级租户,租户父子关系依托与组织机构的父子关系
This commit is contained in:
32
sql/dm/用户租户关系表.sql
Normal file
32
sql/dm/用户租户关系表.sql
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
-- 用户-租户关系表
|
||||||
|
create table "RUOYI-VUE-PRO".SYSTEM_USER_TENANT
|
||||||
|
(
|
||||||
|
ID BIGINT not null,
|
||||||
|
USER_ID BIGINT not null,
|
||||||
|
TENANT_ID BIGINT not null,
|
||||||
|
CREATOR VARCHAR(256) default '',
|
||||||
|
CREATE_TIME TIMESTAMP default CURRENT_TIMESTAMP not null,
|
||||||
|
UPDATER VARCHAR(256) default '',
|
||||||
|
UPDATE_TIME TIMESTAMP default CURRENT_TIMESTAMP not null,
|
||||||
|
DELETED TINYINT default 0 not null
|
||||||
|
);
|
||||||
|
|
||||||
|
comment on table "RUOYI-VUE-PRO".SYSTEM_USER_TENANT is '用户-租户关系表';
|
||||||
|
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.ID is '主键ID';
|
||||||
|
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.USER_ID is '用户ID';
|
||||||
|
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.TENANT_ID is '租户ID';
|
||||||
|
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.CREATOR is '创建者';
|
||||||
|
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.CREATE_TIME is '创建时间';
|
||||||
|
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.UPDATER is '更新者';
|
||||||
|
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.UPDATE_TIME is '更新时间';
|
||||||
|
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_TENANT.DELETED is '是否删除';
|
||||||
|
|
||||||
|
create unique index "RUOYI-VUE-PRO".IDX_SYSTEM_USER_TENANT_ID
|
||||||
|
on "RUOYI-VUE-PRO".SYSTEM_USER_TENANT (ID);
|
||||||
|
|
||||||
|
create unique index "RUOYI-VUE-PRO".IDX_SYSTEM_USER_TENANT_UNIQUE
|
||||||
|
on "RUOYI-VUE-PRO".SYSTEM_USER_TENANT (USER_ID, TENANT_ID);
|
||||||
|
|
||||||
|
alter table "RUOYI-VUE-PRO".SYSTEM_USER_TENANT
|
||||||
|
add constraint PK_SYSTEM_USER_TENANT_ID
|
||||||
|
primary key (ID);
|
||||||
6
sql/dm/组织机构添加是否租户字段.sql
Normal file
6
sql/dm/组织机构添加是否租户字段.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
alter table "RUOYI-VUE-PRO".SYSTEM_DEPT
|
||||||
|
add IS_TENANT TINYINT default false not null;
|
||||||
|
|
||||||
|
comment
|
||||||
|
on column "RUOYI-VUE-PRO".SYSTEM_DEPT.IS_TENANT is '组织机构是否为租户';
|
||||||
|
|
||||||
@@ -30,4 +30,7 @@ create unique index "RUOYI-VUE-PRO".IDX_ROLE_MENU_EXCLUSION_ID
|
|||||||
|
|
||||||
alter table "RUOYI-VUE-PRO".SYSTEM_ROLE_MENU_EXCLUSION
|
alter table "RUOYI-VUE-PRO".SYSTEM_ROLE_MENU_EXCLUSION
|
||||||
add constraint PK_ROLE_MENU_EXCLUSION_ID
|
add constraint PK_ROLE_MENU_EXCLUSION_ID
|
||||||
primary key (ID);
|
primary key (ID);
|
||||||
|
|
||||||
|
alter table "RUOYI-VUE-PRO".SYSTEM_ROLE
|
||||||
|
add PARENT_ID BIGINT default 0 not null;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ spring:
|
|||||||
|
|
||||||
# rocketmq 配置项,对应 RocketMQProperties 配置类
|
# rocketmq 配置项,对应 RocketMQProperties 配置类
|
||||||
rocketmq:
|
rocketmq:
|
||||||
name-server: 127.0.0.1:9876 # RocketMQ Namesrv
|
name-server: 172.16.46.63:30876 # RocketMQ Namesrv
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
# RabbitMQ 配置项,对应 RabbitProperties 配置类
|
# RabbitMQ 配置项,对应 RabbitProperties 配置类
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class ${table.className}DO extends BaseDO {
|
|||||||
#end
|
#end
|
||||||
*/
|
*/
|
||||||
#if (${column.primaryKey})##处理主键
|
#if (${column.primaryKey})##处理主键
|
||||||
@TableId#if (${column.javaType} == 'String')(type = IdType.INPUT)#end
|
@TableId#if (${column.javaType} == 'String')(type = IdType.INPUT)#else(type = IdType.ASSIGN_ID)#end
|
||||||
#end
|
#end
|
||||||
#if ($voType == 20)
|
#if ($voType == 20)
|
||||||
## 1. 处理 Swagger 注解
|
## 1. 处理 Swagger 注解
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode DEPT_PARENT_ERROR = new ErrorCode(1_002_004_004, "不能设置自己为父部门");
|
ErrorCode DEPT_PARENT_ERROR = new ErrorCode(1_002_004_004, "不能设置自己为父部门");
|
||||||
ErrorCode DEPT_NOT_ENABLE = new ErrorCode(1_002_004_006, "部门({})不处于开启状态,不允许选择");
|
ErrorCode DEPT_NOT_ENABLE = new ErrorCode(1_002_004_006, "部门({})不处于开启状态,不允许选择");
|
||||||
ErrorCode DEPT_PARENT_IS_CHILD = new ErrorCode(1_002_004_007, "不能设置自己的子部门为父部门");
|
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 ==========
|
// ========== 岗位模块 1-002-005-000 ==========
|
||||||
ErrorCode POST_NOT_FOUND = new ErrorCode(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 ==========
|
// ========== 站内信发送 1-002-028-000 ==========
|
||||||
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(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, "用户-租户关系不存在");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
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.controller.admin.auth.vo.*;
|
||||||
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
|
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
||||||
@@ -65,6 +66,7 @@ public class AuthController {
|
|||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
@Operation(summary = "使用账号密码登录")
|
@Operation(summary = "使用账号密码登录")
|
||||||
|
@TenantIgnore
|
||||||
public CommonResult<AuthLoginRespVO> login(@RequestBody @Valid AuthLoginReqVO reqVO) {
|
public CommonResult<AuthLoginRespVO> login(@RequestBody @Valid AuthLoginReqVO reqVO) {
|
||||||
return success(authService.login(reqVO));
|
return success(authService.login(reqVO));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
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.DeptListReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
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.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenbowen
|
||||||
|
*/
|
||||||
@Tag(name = "管理后台 - 部门")
|
@Tag(name = "管理后台 - 部门")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dept")
|
@RequestMapping("/system/dept")
|
||||||
@@ -42,6 +46,7 @@ public class DeptController {
|
|||||||
@PutMapping("update")
|
@PutMapping("update")
|
||||||
@Operation(summary = "更新部门")
|
@Operation(summary = "更新部门")
|
||||||
@PreAuthorize("@ss.hasPermission('system:dept:update')")
|
@PreAuthorize("@ss.hasPermission('system:dept:update')")
|
||||||
|
@TenantIgnore
|
||||||
public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptSaveReqVO updateReqVO) {
|
||||||
deptService.updateDept(updateReqVO);
|
deptService.updateDept(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenbowen
|
||||||
|
*/
|
||||||
@Schema(description = "管理后台 - 部门信息 Response VO")
|
@Schema(description = "管理后台 - 部门信息 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class DeptRespVO {
|
public class DeptRespVO {
|
||||||
@@ -36,4 +39,10 @@ public class DeptRespVO {
|
|||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "组织机构是否租户", example = "true")
|
||||||
|
private Boolean isTenant = false;
|
||||||
|
|
||||||
|
@Schema(description = "租户编号", example = "1024")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenbowen
|
||||||
|
*/
|
||||||
@Schema(description = "管理后台 - 部门创建/修改 Request VO")
|
@Schema(description = "管理后台 - 部门创建/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class DeptSaveReqVO {
|
public class DeptSaveReqVO {
|
||||||
@@ -45,4 +48,10 @@ public class DeptSaveReqVO {
|
|||||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "组织机构是否租户", example = "true")
|
||||||
|
private Boolean isTenant = false;
|
||||||
|
|
||||||
|
@Schema(description = "租户编号", example = "1024")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user