feat:登陆用户的部门数据权限接口增加角色参数;获取当前用户可访问的顶级部门列表不校验数据权限
This commit is contained in:
@@ -40,4 +40,11 @@ public interface PermissionCommonApi {
|
||||
@Parameter(name = "userId", description = "用户编号", example = "2", required = true)
|
||||
CommonResult<DeptDataPermissionRespDTO> getDeptDataPermission(@RequestParam("userId") Long userId);
|
||||
|
||||
@GetMapping(PREFIX + "/get-dept-data-permission-with-roleCodes")
|
||||
@Operation(summary = "获得登陆用户的部门数据权限")
|
||||
@Parameters({
|
||||
@Parameter(name = "userId", description = "用户编号", example = "2", required = true),
|
||||
@Parameter(name = "roleCodes", description = "角色编码", example = "2", required = true)
|
||||
})
|
||||
CommonResult<DeptDataPermissionRespDTO> getDeptDataPermissionWithRoleCodes(@RequestParam("userId") Long userId, @RequestParam("roleCodes") String roleCodes);
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.zt.plat.framework.tenant.core.context;
|
||||
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门上下文 Holder,使用 {@link TransmittableThreadLocal} 支持在线程池/异步场景下的上下文传递。
|
||||
*
|
||||
@@ -15,6 +17,8 @@ public class DeptContextHolder {
|
||||
private static final ThreadLocal<Long> COMPANY_ID = new TransmittableThreadLocal<>();
|
||||
/** 是否忽略部门数据权限 */
|
||||
private static final ThreadLocal<Boolean> IGNORE = new TransmittableThreadLocal<>();
|
||||
/** 角色编码列表 */
|
||||
private static final ThreadLocal<List<String>> ROLE_CODE_LIST = new TransmittableThreadLocal<>();
|
||||
|
||||
public static Long getDeptId() {
|
||||
return DEPT_ID.get();
|
||||
@@ -32,6 +36,12 @@ public class DeptContextHolder {
|
||||
COMPANY_ID.set(companyId);
|
||||
}
|
||||
|
||||
public static void setContext(Long deptId, Long companyId, List<String> roleCodeList) {
|
||||
DEPT_ID.set(deptId);
|
||||
COMPANY_ID.set(companyId);
|
||||
ROLE_CODE_LIST.set(roleCodeList);
|
||||
}
|
||||
|
||||
public static void setDeptId(Long deptId) {
|
||||
DEPT_ID.set(deptId);
|
||||
}
|
||||
@@ -53,9 +63,20 @@ public class DeptContextHolder {
|
||||
return Boolean.TRUE.equals(IGNORE.get());
|
||||
}
|
||||
|
||||
public static void setRoleCodeList(List<String> roleCodeList) {
|
||||
ROLE_CODE_LIST.set(roleCodeList);
|
||||
}
|
||||
public static List<String> getRoleCodeList() {
|
||||
return ROLE_CODE_LIST.get();
|
||||
}
|
||||
public static void clearRoleCodeList(){
|
||||
ROLE_CODE_LIST.remove();
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
DEPT_ID.remove();
|
||||
COMPANY_ID.remove();
|
||||
IGNORE.remove();
|
||||
ROLE_CODE_LIST.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user