【8.1.1】【db】更新数据范围的holder和配置

pull/60/head
fengshuonan 2024-02-29 10:31:04 +08:00
parent e47abb2ef5
commit 2a11fc0574
2 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,52 @@
package cn.stylefeng.roses.kernel.db.mp.datascope.config;
import cn.stylefeng.roses.kernel.rule.enums.permission.DataScopeTypeEnum;
import lombok.Data;
import java.util.List;
/**
*
*
* @author fengshuonan
* @since 2024-02-29 10:04
*/
@Data
public class DataScopeConfig {
/**
*
*/
private DataScopeTypeEnum dataScopeType;
/**
* id
*/
private Long userId;
/**
* id
*/
private Long userDeptId;
/**
* id
*/
private Long userCompanyId;
/**
* ID DEFINE 使
*/
private List<Long> specificOrgIds;
/**
*
*/
private String orgIdFieldName = "org_id";
/**
*
*/
private String userIdFieldName = "user_id";
}

View File

@ -0,0 +1,45 @@
package cn.stylefeng.roses.kernel.db.mp.datascope.holder;
import cn.stylefeng.roses.kernel.db.mp.datascope.config.DataScopeConfig;
/**
* 使
*
* @author fengshuonan
* @since 2024-02-29 10:16
*/
public class DataScopeHolder {
private static final ThreadLocal<DataScopeConfig> DATA_SCOPE_CONFIG_HOLDER = new ThreadLocal<>();
/**
*
*
* @author fengshuonan
* @since 2024-02-29 10:17
*/
public static void set(DataScopeConfig tenantId) {
DATA_SCOPE_CONFIG_HOLDER.set(tenantId);
}
/**
*
*
* @author fengshuonan
* @since 2024-02-29 10:17
*/
public static DataScopeConfig get() {
return DATA_SCOPE_CONFIG_HOLDER.get();
}
/**
*
*
* @author fengshuonan
* @since 2024-02-29 10:17
*/
public static void remove() {
DATA_SCOPE_CONFIG_HOLDER.remove();
}
}