pub struct DataScopeRule {
pub mode: DataScopeMode,
pub dept_field: Option<String>,
pub creator_field: Option<String>,
pub custom_generator: Option<String>,
pub target_table: String,
pub priority: u32,
}Expand description
数据范围规则
每条规则绑定一张表,声明该表的数据范围模式和字段映射。
规则按 priority 降序排列,首个匹配的规则生效。
Fields§
§mode: DataScopeMode数据范围模式
dept_field: Option<String>部门字段名(DEPT / DEPT_AND_SUB 模式必填,如 "dept_id")
creator_field: Option<String>创建者字段名(SELF 模式必填,如 "creator_id")
custom_generator: Option<String>自定义条件生成器名称(CUSTOM 模式必填)
target_table: String目标表名(如 "order")
priority: u32优先级(数值越大优先级越高,同表多规则时取最高优先级)
Implementations§
Source§impl DataScopeRule
impl DataScopeRule
Sourcepub fn new(target_table: impl Into<String>, mode: DataScopeMode) -> Self
pub fn new(target_table: impl Into<String>, mode: DataScopeMode) -> Self
创建一条新规则
Sourcepub fn with_dept_field(self, field: impl Into<String>) -> Self
pub fn with_dept_field(self, field: impl Into<String>) -> Self
设置部门字段名
Sourcepub fn with_creator_field(self, field: impl Into<String>) -> Self
pub fn with_creator_field(self, field: impl Into<String>) -> Self
设置创建者字段名
Sourcepub fn with_custom_generator(self, name: impl Into<String>) -> Self
pub fn with_custom_generator(self, name: impl Into<String>) -> Self
设置自定义生成器名称
Sourcepub fn with_priority(self, priority: u32) -> Self
pub fn with_priority(self, priority: u32) -> Self
设置优先级
Trait Implementations§
Source§impl Clone for DataScopeRule
impl Clone for DataScopeRule
Source§fn clone(&self) -> DataScopeRule
fn clone(&self) -> DataScopeRule
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DataScopeRule
impl RefUnwindSafe for DataScopeRule
impl Send for DataScopeRule
impl Sync for DataScopeRule
impl Unpin for DataScopeRule
impl UnsafeUnpin for DataScopeRule
impl UnwindSafe for DataScopeRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more