1. 补全后端的其余模块
2. 新增用户管理多部门的逻辑
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -22,11 +22,11 @@
|
||||
<module>yudao-module-report</module>
|
||||
<!-- <module>yudao-module-mp</module>-->
|
||||
<!-- <module>yudao-module-mall</module>-->
|
||||
<!-- <module>yudao-module-crm</module>-->
|
||||
<!-- <module>yudao-module-erp</module>-->
|
||||
<module>yudao-module-crm</module>
|
||||
<module>yudao-module-erp</module>
|
||||
<module>yudao-module-ai</module>
|
||||
<module>yudao-module-template</module>
|
||||
<!-- <module>yudao-module-iot</module>-->
|
||||
<!-- <module>yudao-module-iot</module>-->
|
||||
</modules>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
|
||||
42
sql/dm/新增用户与组织关系表并迁移.sql
Normal file
42
sql/dm/新增用户与组织关系表并迁移.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
create table "RUOYI-VUE-PRO".SYSTEM_USER_DEPT (
|
||||
ID BIGINT primary key, -- 自增主键
|
||||
USER_ID BIGINT not null,
|
||||
DEPT_ID BIGINT not null,
|
||||
TENANT_ID BIGINT default 0 not null,
|
||||
REMARK VARCHAR(2000),
|
||||
CREATOR VARCHAR(256) default '',
|
||||
CREATE_TIME TIMESTAMP default CURRENT_TIMESTAMP not null,
|
||||
UPDATER VARCHAR(256) default '',
|
||||
DELETED TINYINT default 0 not null,
|
||||
UPDATE_TIME TIMESTAMP default CURRENT_TIMESTAMP not null
|
||||
);
|
||||
|
||||
comment on table "RUOYI-VUE-PRO".SYSTEM_USER_DEPT is '用户与部门关系表';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.ID is '主键ID';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.USER_ID is '用户ID';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.DEPT_ID is '部门ID';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.TENANT_ID is '租户编号';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.REMARK is '备注';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.CREATOR is '创建者';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.CREATE_TIME is '创建时间';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.UPDATER is '更新者';
|
||||
comment on column "RUOYI-VUE-PRO".SYSTEM_USER_DEPT.UPDATE_TIME is '更新时间';
|
||||
|
||||
-- 1. 将原有用户表中的 DEPT_ID 字段数据迁移到关系表(ID 自增,无需指定)
|
||||
insert into "RUOYI-VUE-PRO".SYSTEM_USER_DEPT (
|
||||
USER_ID, DEPT_ID, TENANT_ID, REMARK, CREATOR, CREATE_TIME, UPDATER, UPDATE_TIME
|
||||
)
|
||||
select
|
||||
ID as USER_ID,
|
||||
DEPT_ID,
|
||||
TENANT_ID,
|
||||
null as REMARK,
|
||||
CREATOR,
|
||||
CREATE_TIME,
|
||||
UPDATER,
|
||||
UPDATE_TIME
|
||||
from "RUOYI-VUE-PRO".SYSTEM_USERS
|
||||
where DEPT_ID is not null;
|
||||
|
||||
-- 移除用户表中的 DEPT_ID 字段
|
||||
alter table "RUOYI-VUE-PRO".SYSTEM_USERS drop column DEPT_ID;
|
||||
8
sql/dm/新增组织机构类型字段.sql
Normal file
8
sql/dm/新增组织机构类型字段.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
alter table "RUOYI-VUE-PRO".SYSTEM_DEPT
|
||||
add IS_COMPANY BIT default 0 not null;
|
||||
comment
|
||||
on column "RUOYI-VUE-PRO".SYSTEM_DEPT.IS_COMPANY is '是否公司';
|
||||
alter table "RUOYI-VUE-PRO".SYSTEM_DEPT
|
||||
add IS_GROUP BIT default 0 not null;
|
||||
comment
|
||||
on column "RUOYI-VUE-PRO".SYSTEM_DEPT.IS_GROUP is '是否集团';
|
||||
@@ -31,6 +31,7 @@
|
||||
<module>yudao-spring-boot-starter-biz-tenant</module>
|
||||
<module>yudao-spring-boot-starter-biz-data-permission</module>
|
||||
<module>yudao-spring-boot-starter-biz-ip</module>
|
||||
<module>yudao-spring-boot-starter-biz-business</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>yudao-framework</artifactId>
|
||||
|
||||
@@ -19,10 +19,14 @@ public class DeptDataPermissionRespDTO {
|
||||
@Schema(description = "可查看的部门编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 3]")
|
||||
private Set<Long> deptIds;
|
||||
|
||||
@Schema(description = "可查看的公司编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 3]")
|
||||
private Long companyId;
|
||||
|
||||
public DeptDataPermissionRespDTO() {
|
||||
this.all = false;
|
||||
this.self = false;
|
||||
this.deptIds = new HashSet<>();
|
||||
this.companyId = 0L;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.iocoder.cloud</groupId>
|
||||
<artifactId>yudao-framework</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>yudao-spring-boot-starter-biz-business</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.cloud</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.cloud</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.cloud</groupId>
|
||||
<artifactId>yudao-module-system-api</artifactId>
|
||||
<version>2.6.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.framework.business.core.db;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
/**
|
||||
* @author chenbowen
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BusinessBaseDO extends TenantBaseDO {
|
||||
|
||||
/** 公司编号 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long companyId;
|
||||
/** 公司名称 */
|
||||
@TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.VARCHAR)
|
||||
private String companyName;
|
||||
/** 部门编号 */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long deptId;
|
||||
/** 部门名称 */
|
||||
@TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.VARCHAR)
|
||||
private String deptName;
|
||||
/** 任务编号 */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.VARCHAR)
|
||||
private Long taskId;
|
||||
/** 岗位编号 */
|
||||
@TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.VARCHAR)
|
||||
private Long postId;
|
||||
|
||||
/**
|
||||
* 清除 creator、createTime、updateTime、updater 等字段,避免前端直接传递这些字段,导致被更新
|
||||
*/
|
||||
@Override
|
||||
public void clean() {
|
||||
super.clean();
|
||||
this.companyId = null;
|
||||
this.companyName = null;
|
||||
this.deptId = null;
|
||||
this.deptName = null;
|
||||
this.taskId = null;
|
||||
this.postId = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.framework.business.core.util;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 用户与部门一对多改动,此处统一处理用户与部门关系
|
||||
* @author chenbowen
|
||||
*/
|
||||
public class DeptUtil {
|
||||
/**
|
||||
* 从用户信息中获取唯一 deptId (现阶段取第一个,后续如有特殊规则统一调整此处即可)
|
||||
*/
|
||||
public static Long getDeptId(AdminUserRespDTO adminUserRespDTO) {
|
||||
List<Long> deptIds = Optional.ofNullable(adminUserRespDTO.getDeptIds()).orElse(new ArrayList<>());
|
||||
return deptIds.stream().findFirst().orElse(0L);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@ import cn.iocoder.yudao.framework.tenant.core.redis.TenantRedisCacheManager;
|
||||
import cn.iocoder.yudao.framework.tenant.core.security.TenantSecurityWebFilter;
|
||||
import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
|
||||
import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkServiceImpl;
|
||||
import cn.iocoder.yudao.framework.tenant.core.web.DeptVisitContextInterceptor;
|
||||
import cn.iocoder.yudao.framework.tenant.core.web.CompanyVisitContextInterceptor;
|
||||
import cn.iocoder.yudao.framework.tenant.core.web.TenantContextWebFilter;
|
||||
import cn.iocoder.yudao.framework.tenant.core.web.TenantVisitContextInterceptor;
|
||||
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
||||
@@ -135,8 +135,8 @@ public class YudaoTenantAutoConfiguration {
|
||||
return new TenantVisitContextInterceptor(tenantProperties, securityFrameworkService);
|
||||
}
|
||||
@Bean
|
||||
public DeptVisitContextInterceptor deptVisitContextInterceptor(SecurityFrameworkService securityFrameworkService) {
|
||||
return new DeptVisitContextInterceptor(securityFrameworkService);
|
||||
public CompanyVisitContextInterceptor deptVisitContextInterceptor(SecurityFrameworkService securityFrameworkService) {
|
||||
return new CompanyVisitContextInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -153,11 +153,11 @@ public class YudaoTenantAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer deptWebMvcConfigurer(TenantProperties tenantProperties, DeptVisitContextInterceptor deptVisitContextInterceptor) {
|
||||
public WebMvcConfigurer deptWebMvcConfigurer(TenantProperties tenantProperties, CompanyVisitContextInterceptor companyVisitContextInterceptor) {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(deptVisitContextInterceptor)
|
||||
registry.addInterceptor(companyVisitContextInterceptor)
|
||||
.excludePathPatterns(tenantProperties.getIgnoreVisitUrls().toArray(new String[0]));
|
||||
}
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user