pub struct DepartmentScope {
pub field: &'static str,
pub include_sub_depts: Vec<i64>,
}Expand description
部门范围规则 — 自动追加 dept_id IN (...) 或 dept_id = ? 条件
对应 Spring Security @DepartmentScope / MyBatis-Plus dept_id in (...)。
§示例
use sz_orm_query::data_permission::{DepartmentScope, PermissionRule, PermissionContext};
let rule = DepartmentScope::new("dept_id");
let ctx = PermissionContext::new().with_dept_id(3);
let clause = rule.apply(&ctx).unwrap().unwrap();
assert_eq!(clause, "dept_id = 3");Fields§
§field: &'static str部门字段名(默认 “dept_id”)
include_sub_depts: Vec<i64>子部门 ID 列表(如部门树展开后所有子孙部门)
Implementations§
Source§impl DepartmentScope
impl DepartmentScope
Sourcepub fn new(field: &'static str) -> DepartmentScope
pub fn new(field: &'static str) -> DepartmentScope
创建部门范围规则
Sourcepub fn default_field() -> DepartmentScope
pub fn default_field() -> DepartmentScope
使用默认字段名 “dept_id”
Sourcepub fn with_sub_depts(self, depts: Vec<i64>) -> DepartmentScope
pub fn with_sub_depts(self, depts: Vec<i64>) -> DepartmentScope
包含子部门
Trait Implementations§
Source§impl PermissionRule for DepartmentScope
impl PermissionRule for DepartmentScope
Auto Trait Implementations§
impl Freeze for DepartmentScope
impl RefUnwindSafe for DepartmentScope
impl Send for DepartmentScope
impl Sync for DepartmentScope
impl Unpin for DepartmentScope
impl UnsafeUnpin for DepartmentScope
impl UnwindSafe for DepartmentScope
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
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