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 default_field() -> Self
pub fn default_field() -> Self
使用默认字段名 “dept_id”
Sourcepub fn with_sub_depts(self, depts: Vec<i64>) -> Self
pub fn with_sub_depts(self, depts: Vec<i64>) -> Self
包含子部门
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