ai-engineering-init 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/hooks/skill-forced-eval.js +2 -0
- package/.claude/settings.json +3 -3
- package/.claude/skills/add-skill/SKILL.md +79 -32
- package/.claude/skills/api-development/SKILL.md +83 -377
- package/.claude/skills/architecture-design/SKILL.md +138 -632
- package/.claude/skills/backend-annotations/SKILL.md +134 -506
- package/.claude/skills/banana-image/SKILL.md +10 -3
- package/.claude/skills/brainstorm/SKILL.md +103 -535
- package/.claude/skills/bug-detective/SKILL.md +147 -1097
- package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
- package/.claude/skills/code-patterns/SKILL.md +116 -426
- package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.claude/skills/crud-development/SKILL.md +64 -304
- package/.claude/skills/data-permission/SKILL.md +105 -412
- package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.claude/skills/file-oss-management/SKILL.md +106 -714
- package/.claude/skills/file-oss-management/references/entities.md +105 -0
- package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
- package/.claude/skills/leniu-api-development/SKILL.md +142 -626
- package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
- package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
- package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
- package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
- package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
- package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
- package/.claude/skills/leniu-java-export/SKILL.md +94 -379
- package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
- package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.claude/skills/leniu-report-customization/SKILL.md +111 -365
- package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
- package/.claude/skills/mysql-debug/SKILL.md +364 -0
- package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
- package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
- package/.claude/skills/openspec-explore/SKILL.md +10 -1
- package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
- package/.claude/skills/openspec-new-change/SKILL.md +9 -1
- package/.claude/skills/openspec-onboard/SKILL.md +15 -130
- package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
- package/.claude/skills/performance-doctor/SKILL.md +110 -434
- package/.claude/skills/redis-cache/SKILL.md +89 -595
- package/.claude/skills/redis-cache/references/listeners.md +23 -0
- package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
- package/.claude/skills/security-guard/SKILL.md +137 -532
- package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
- package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.claude/skills/sms-mail/SKILL.md +116 -574
- package/.claude/skills/sms-mail/references/mail-config.md +88 -0
- package/.claude/skills/sms-mail/references/sms-config.md +74 -0
- package/.claude/skills/social-login/SKILL.md +112 -514
- package/.claude/skills/social-login/references/provider-configs.md +118 -0
- package/.claude/skills/tenant-management/SKILL.md +129 -444
- package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.claude/skills/test-development/SKILL.md +86 -540
- package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
- package/.claude/skills/utils-toolkit/SKILL.md +52 -305
- package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.claude/skills/websocket-sse/SKILL.md +105 -550
- package/.claude/skills/workflow-engine/SKILL.md +147 -502
- package/.codex/skills/add-skill/SKILL.md +79 -32
- package/.codex/skills/api-development/SKILL.md +172 -599
- package/.codex/skills/architecture-design/SKILL.md +138 -504
- package/.codex/skills/backend-annotations/SKILL.md +134 -496
- package/.codex/skills/banana-image/SKILL.md +10 -3
- package/.codex/skills/brainstorm/SKILL.md +103 -535
- package/.codex/skills/bug-detective/SKILL.md +147 -1097
- package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
- package/.codex/skills/code-patterns/SKILL.md +120 -282
- package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.codex/skills/crud-development/SKILL.md +64 -292
- package/.codex/skills/data-permission/SKILL.md +108 -407
- package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.codex/skills/database-ops/SKILL.md +8 -154
- package/.codex/skills/error-handler/SKILL.md +10 -0
- package/.codex/skills/file-oss-management/SKILL.md +106 -714
- package/.codex/skills/file-oss-management/references/entities.md +105 -0
- package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
- package/.codex/skills/git-workflow/SKILL.md +27 -5
- package/.codex/skills/leniu-api-development/SKILL.md +142 -626
- package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
- package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
- package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
- package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
- package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
- package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
- package/.codex/skills/leniu-java-export/SKILL.md +94 -379
- package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
- package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.codex/skills/leniu-report-customization/SKILL.md +111 -365
- package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
- package/.codex/skills/mysql-debug/SKILL.md +364 -0
- package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
- package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
- package/.codex/skills/openspec-explore/SKILL.md +10 -1
- package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
- package/.codex/skills/openspec-new-change/SKILL.md +9 -1
- package/.codex/skills/openspec-onboard/SKILL.md +15 -130
- package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
- package/.codex/skills/performance-doctor/SKILL.md +110 -434
- package/.codex/skills/project-navigator/SKILL.md +20 -1
- package/.codex/skills/redis-cache/SKILL.md +93 -589
- package/.codex/skills/redis-cache/references/listeners.md +23 -0
- package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
- package/.codex/skills/security-guard/SKILL.md +141 -527
- package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
- package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.codex/skills/sms-mail/SKILL.md +116 -574
- package/.codex/skills/sms-mail/references/mail-config.md +88 -0
- package/.codex/skills/sms-mail/references/sms-config.md +74 -0
- package/.codex/skills/social-login/SKILL.md +112 -514
- package/.codex/skills/social-login/references/provider-configs.md +118 -0
- package/.codex/skills/store-pc/SKILL.md +258 -383
- package/.codex/skills/tenant-management/SKILL.md +129 -444
- package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.codex/skills/test-development/SKILL.md +86 -540
- package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
- package/.codex/skills/ui-pc/SKILL.md +350 -387
- package/.codex/skills/utils-toolkit/SKILL.md +52 -283
- package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.codex/skills/websocket-sse/SKILL.md +105 -550
- package/.codex/skills/workflow-engine/SKILL.md +147 -502
- package/.cursor/hooks.json +3 -3
- package/.cursor/skills/add-skill/SKILL.md +79 -32
- package/.cursor/skills/api-development/SKILL.md +83 -377
- package/.cursor/skills/architecture-design/SKILL.md +138 -632
- package/.cursor/skills/backend-annotations/SKILL.md +134 -506
- package/.cursor/skills/banana-image/SKILL.md +10 -3
- package/.cursor/skills/brainstorm/SKILL.md +103 -535
- package/.cursor/skills/bug-detective/SKILL.md +147 -1097
- package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
- package/.cursor/skills/code-patterns/SKILL.md +116 -426
- package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.cursor/skills/crud-development/SKILL.md +64 -304
- package/.cursor/skills/data-permission/SKILL.md +105 -412
- package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.cursor/skills/file-oss-management/SKILL.md +106 -714
- package/.cursor/skills/file-oss-management/references/entities.md +105 -0
- package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
- package/.cursor/skills/git-workflow/SKILL.md +27 -5
- package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
- package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
- package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
- package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
- package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
- package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
- package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
- package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
- package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
- package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.cursor/skills/leniu-report-customization/SKILL.md +111 -365
- package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
- package/.cursor/skills/mysql-debug/SKILL.md +364 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
- package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-explore/SKILL.md +10 -1
- package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
- package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
- package/.cursor/skills/performance-doctor/SKILL.md +110 -434
- package/.cursor/skills/redis-cache/SKILL.md +89 -595
- package/.cursor/skills/redis-cache/references/listeners.md +23 -0
- package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
- package/.cursor/skills/security-guard/SKILL.md +137 -532
- package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
- package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.cursor/skills/sms-mail/SKILL.md +116 -574
- package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
- package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
- package/.cursor/skills/social-login/SKILL.md +112 -514
- package/.cursor/skills/social-login/references/provider-configs.md +118 -0
- package/.cursor/skills/tenant-management/SKILL.md +129 -444
- package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.cursor/skills/test-development/SKILL.md +86 -540
- package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
- package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
- package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.cursor/skills/websocket-sse/SKILL.md +105 -550
- package/.cursor/skills/workflow-engine/SKILL.md +147 -502
- package/package.json +1 -1
|
@@ -17,58 +17,24 @@ description: |
|
|
|
17
17
|
|
|
18
18
|
# 数据权限开发指南
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
> 通过 MyBatis 拦截器自动注入 WHERE 条件,实现行级数据过滤。
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
## 1. 六种权限类型
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
| 类型 | 字典值 | SQL 效果 |
|
|
25
|
+
|------|--------|---------|
|
|
26
|
+
| 全部数据 | 1 | 不拼接条件 |
|
|
27
|
+
| 自定义权限 | 2 | `dept_id IN (角色关联的部门ID)` |
|
|
28
|
+
| 本部门 | 3 | `dept_id = 100` |
|
|
29
|
+
| 本部门及以下 | 4 | `dept_id IN (100,101,102)` |
|
|
30
|
+
| 仅本人 | 5 | `create_by = 1` |
|
|
31
|
+
| 部门及以下或本人 | 6 | `dept_id IN (...) OR create_by = 1` |
|
|
27
32
|
|
|
28
33
|
---
|
|
29
34
|
|
|
30
|
-
##
|
|
35
|
+
## 2. 快速上手
|
|
31
36
|
|
|
32
|
-
### 1
|
|
33
|
-
|
|
34
|
-
| 类型 | 字典值 | 说明 | SQL 效果 |
|
|
35
|
-
|------|--------|------|---------|
|
|
36
|
-
| **全部数据** | 1 | 无过滤条件 | 不拼接任何条件 |
|
|
37
|
-
| **自定义权限** | 2 | 按角色关联的部门 | `dept_id IN (1,2,3)` |
|
|
38
|
-
| **本部门** | 3 | 只看本部门 | `dept_id = 100` |
|
|
39
|
-
| **本部门及以下** | 4 | 本部门 + 子部门 | `dept_id IN (100,101,102)` |
|
|
40
|
-
| **仅本人** | 5 | 只看自己创建的 | `create_by = 1` |
|
|
41
|
-
| **部门及以下或本人** | 6 | 混合模式 | `dept_id IN (...) OR create_by = 1` |
|
|
42
|
-
|
|
43
|
-
### 1.2 技术架构
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
请求 → Controller → Service (@DataPermission) → Mapper
|
|
47
|
-
↓
|
|
48
|
-
PlusDataPermissionInterceptor 拦截
|
|
49
|
-
↓
|
|
50
|
-
PlusDataPermissionHandler 解析 SpEL
|
|
51
|
-
↓
|
|
52
|
-
拼接 WHERE 条件 → 执行 SQL
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### 1.3 核心类位置
|
|
56
|
-
|
|
57
|
-
| 类 | 路径 | 职责 |
|
|
58
|
-
|---|------|------|
|
|
59
|
-
| `@DataPermission` | `ruoyi-common/ruoyi-common-mybatis/.../annotation/` | 权限注解 |
|
|
60
|
-
| `@DataColumn` | `ruoyi-common/ruoyi-common-mybatis/.../annotation/` | 列配置注解 |
|
|
61
|
-
| `DataScopeType` | `ruoyi-common/ruoyi-common-mybatis/.../enums/` | 权限类型枚举 |
|
|
62
|
-
| `PlusDataPermissionInterceptor` | `ruoyi-common/ruoyi-common-mybatis/.../interceptor/` | SQL 拦截器 |
|
|
63
|
-
| `PlusDataPermissionHandler` | `ruoyi-common/ruoyi-common-mybatis/.../handler/` | 权限处理器 |
|
|
64
|
-
| `DataPermissionHelper` | `ruoyi-common/ruoyi-common-mybatis/.../helper/` | 权限助手类 |
|
|
65
|
-
| `ISysDataScopeService` | `ruoyi-modules/ruoyi-system/.../service/` | 权限数据服务 |
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## 2. 快速上手(3 分钟添加权限)
|
|
70
|
-
|
|
71
|
-
### 步骤 1:在 Service 方法上添加注解
|
|
37
|
+
### 步骤 1:Service 方法加注解
|
|
72
38
|
|
|
73
39
|
```java
|
|
74
40
|
import org.dromara.common.mybatis.annotation.DataPermission;
|
|
@@ -78,11 +44,8 @@ import org.dromara.common.mybatis.annotation.DataColumn;
|
|
|
78
44
|
@RequiredArgsConstructor
|
|
79
45
|
public class OrderServiceImpl implements IOrderService {
|
|
80
46
|
|
|
81
|
-
private final OrderMapper baseMapper;
|
|
47
|
+
private final OrderMapper baseMapper;
|
|
82
48
|
|
|
83
|
-
/**
|
|
84
|
-
* 分页查询(带数据权限)
|
|
85
|
-
*/
|
|
86
49
|
@DataPermission({
|
|
87
50
|
@DataColumn(key = "deptName", value = "create_dept"),
|
|
88
51
|
@DataColumn(key = "userName", value = "create_by")
|
|
@@ -101,491 +64,229 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
101
64
|
```sql
|
|
102
65
|
CREATE TABLE m_order (
|
|
103
66
|
id BIGINT(20) NOT NULL COMMENT '主键ID',
|
|
104
|
-
--
|
|
105
|
-
|
|
106
|
-
--
|
|
107
|
-
create_dept BIGINT(20) DEFAULT NULL COMMENT '创建部门',
|
|
108
|
-
create_by BIGINT(20) DEFAULT NULL COMMENT '创建人',
|
|
109
|
-
|
|
110
|
-
-- 其他审计字段
|
|
67
|
+
-- 业务字段 ...
|
|
68
|
+
create_dept BIGINT(20) DEFAULT NULL COMMENT '创建部门', -- 必须
|
|
69
|
+
create_by BIGINT(20) DEFAULT NULL COMMENT '创建人', -- 必须
|
|
111
70
|
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
112
71
|
PRIMARY KEY (id)
|
|
113
72
|
);
|
|
114
73
|
```
|
|
115
74
|
|
|
116
|
-
### 步骤 3
|
|
117
|
-
|
|
118
|
-
在系统管理 → 角色管理中,为角色配置数据权限范围(全部/本部门/本部门及以下/仅本人/自定义)。
|
|
75
|
+
### 步骤 3:角色管理中配置数据权限范围
|
|
119
76
|
|
|
120
77
|
---
|
|
121
78
|
|
|
122
|
-
## 3.
|
|
79
|
+
## 3. 使用场景
|
|
123
80
|
|
|
124
|
-
###
|
|
125
|
-
|
|
126
|
-
最常见的场景,用户只能看到本部门及以下的数据。
|
|
81
|
+
### 按部门过滤(最常见)
|
|
127
82
|
|
|
128
83
|
```java
|
|
129
|
-
/**
|
|
130
|
-
* 按部门过滤
|
|
131
|
-
*
|
|
132
|
-
* 权限效果:
|
|
133
|
-
* - 全部数据:无过滤
|
|
134
|
-
* - 本部门:WHERE create_dept = 100
|
|
135
|
-
* - 本部门及以下:WHERE create_dept IN (100, 101, 102)
|
|
136
|
-
* - 自定义:WHERE create_dept IN (角色关联的部门ID)
|
|
137
|
-
*/
|
|
138
84
|
@DataPermission({
|
|
139
85
|
@DataColumn(key = "deptName", value = "create_dept")
|
|
140
86
|
})
|
|
141
|
-
@Override
|
|
142
87
|
public List<Order> listWithPermission(OrderBo bo) {
|
|
143
88
|
return list(buildQueryWrapper(bo));
|
|
144
89
|
}
|
|
145
90
|
```
|
|
146
91
|
|
|
147
|
-
###
|
|
148
|
-
|
|
149
|
-
用户只能看到自己创建的数据。
|
|
92
|
+
### 按创建人过滤
|
|
150
93
|
|
|
151
94
|
```java
|
|
152
|
-
/**
|
|
153
|
-
* 按创建人过滤
|
|
154
|
-
*
|
|
155
|
-
* 权限效果:
|
|
156
|
-
* - 仅本人:WHERE create_by = 1(当前用户ID)
|
|
157
|
-
*/
|
|
158
95
|
@DataPermission({
|
|
159
96
|
@DataColumn(key = "userName", value = "create_by")
|
|
160
97
|
})
|
|
161
|
-
@Override
|
|
162
98
|
public List<Task> listMyTasks(TaskBo bo) {
|
|
163
99
|
return list(buildQueryWrapper(bo));
|
|
164
100
|
}
|
|
165
101
|
```
|
|
166
102
|
|
|
167
|
-
###
|
|
168
|
-
|
|
169
|
-
同时支持按部门和按创建人过滤,根据角色配置自动选择。
|
|
103
|
+
### 部门 + 创建人混合
|
|
170
104
|
|
|
171
105
|
```java
|
|
172
|
-
/**
|
|
173
|
-
* 部门 + 创建人混合
|
|
174
|
-
*
|
|
175
|
-
* 权限效果:
|
|
176
|
-
* - 本部门:WHERE create_dept = 100
|
|
177
|
-
* - 仅本人:WHERE create_by = 1
|
|
178
|
-
* - 部门及以下或本人:WHERE create_dept IN (...) OR create_by = 1
|
|
179
|
-
*/
|
|
180
106
|
@DataPermission({
|
|
181
107
|
@DataColumn(key = "deptName", value = "create_dept"),
|
|
182
108
|
@DataColumn(key = "userName", value = "create_by")
|
|
183
109
|
})
|
|
184
|
-
@Override
|
|
185
110
|
public TableDataInfo<ProjectVo> pageWithPermission(ProjectBo bo, PageQuery pageQuery) {
|
|
186
|
-
|
|
187
|
-
Page<ProjectVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
188
|
-
return TableDataInfo.build(result);
|
|
111
|
+
// ...
|
|
189
112
|
}
|
|
190
113
|
```
|
|
191
114
|
|
|
192
|
-
###
|
|
193
|
-
|
|
194
|
-
当 SQL 涉及多表关联时,需要使用正确的表别名。
|
|
115
|
+
### 多表关联(使用表别名)
|
|
195
116
|
|
|
196
117
|
```java
|
|
197
|
-
|
|
198
|
-
* 多表关联查询
|
|
199
|
-
*
|
|
200
|
-
* SQL 示例:
|
|
201
|
-
* SELECT u.*, d.dept_name
|
|
202
|
-
* FROM sys_user u
|
|
203
|
-
* LEFT JOIN sys_dept d ON u.dept_id = d.dept_id
|
|
204
|
-
*
|
|
205
|
-
* 注意:value 中使用表别名 u.dept_id
|
|
206
|
-
*/
|
|
118
|
+
// SQL: SELECT u.*, d.dept_name FROM sys_user u LEFT JOIN sys_dept d ON ...
|
|
207
119
|
@DataPermission({
|
|
208
120
|
@DataColumn(key = "deptName", value = "u.dept_id"),
|
|
209
121
|
@DataColumn(key = "userName", value = "u.user_id")
|
|
210
122
|
})
|
|
211
|
-
@Override
|
|
212
|
-
public TableDataInfo<SysUserVo> pageWithPermission(SysUserBo bo, PageQuery pageQuery) {
|
|
213
|
-
// ...
|
|
214
|
-
}
|
|
215
123
|
```
|
|
216
124
|
|
|
217
|
-
###
|
|
218
|
-
|
|
219
|
-
某些场景需要查询全量数据(如统计、初始化)。
|
|
125
|
+
### 临时忽略数据权限
|
|
220
126
|
|
|
221
127
|
```java
|
|
222
128
|
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
|
223
129
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
@Autowired
|
|
228
|
-
private IOrderService orderService;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* 统计总数(需要全量数据)
|
|
232
|
-
*/
|
|
233
|
-
@Override
|
|
234
|
-
public Long countTotal() {
|
|
235
|
-
// 忽略数据权限,查询所有数据
|
|
236
|
-
return DataPermissionHelper.ignore(() -> {
|
|
237
|
-
return orderService.count();
|
|
238
|
-
});
|
|
239
|
-
}
|
|
130
|
+
// 忽略数据权限,查全量
|
|
131
|
+
Long total = DataPermissionHelper.ignore(() -> orderService.count());
|
|
240
132
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
DataPermissionHelper.ignore(() -> {
|
|
247
|
-
List<Config> configs = configService.list();
|
|
248
|
-
// 处理缓存...
|
|
249
|
-
return null;
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
133
|
+
// 无返回值
|
|
134
|
+
DataPermissionHelper.ignore(() -> {
|
|
135
|
+
List<Config> configs = configService.list();
|
|
136
|
+
return null;
|
|
137
|
+
});
|
|
253
138
|
```
|
|
254
139
|
|
|
255
|
-
###
|
|
256
|
-
|
|
257
|
-
拥有特定权限的角色可以跳过数据过滤。
|
|
140
|
+
### 指定权限标识跳过过滤
|
|
258
141
|
|
|
259
142
|
```java
|
|
260
|
-
|
|
261
|
-
* 拥有 order:all 权限的角色可以查看所有订单
|
|
262
|
-
*/
|
|
143
|
+
// 拥有 order:all 权限的角色不过滤
|
|
263
144
|
@DataPermission({
|
|
264
145
|
@DataColumn(key = "deptName", value = "create_dept", permission = "order:all")
|
|
265
146
|
})
|
|
266
|
-
@Override
|
|
267
|
-
public List<Order> listAllOrders(OrderBo bo) {
|
|
268
|
-
return list(buildQueryWrapper(bo));
|
|
269
|
-
}
|
|
270
147
|
```
|
|
271
148
|
|
|
272
149
|
---
|
|
273
150
|
|
|
274
|
-
## 4.
|
|
151
|
+
## 4. Mapper XML 中使用
|
|
275
152
|
|
|
276
|
-
|
|
153
|
+
```java
|
|
154
|
+
// Mapper 接口
|
|
155
|
+
@DataPermission({
|
|
156
|
+
@DataColumn(key = "deptName", value = "o.create_dept")
|
|
157
|
+
})
|
|
158
|
+
List<OrderVo> selectOrderReport(@Param("bo") OrderBo bo);
|
|
159
|
+
```
|
|
277
160
|
|
|
278
|
-
|
|
161
|
+
```xml
|
|
162
|
+
<select id="selectOrderReport" resultType="OrderVo">
|
|
163
|
+
SELECT o.*, u.user_name
|
|
164
|
+
FROM m_order o
|
|
165
|
+
LEFT JOIN sys_user u ON o.create_by = u.user_id
|
|
166
|
+
WHERE o.status = #{bo.status}
|
|
167
|
+
<!-- 数据权限自动追加到这里 -->
|
|
168
|
+
</select>
|
|
169
|
+
```
|
|
279
170
|
|
|
280
|
-
|
|
281
|
-
// 位置:ruoyi-common-mybatis/.../enums/DataScopeType.java
|
|
171
|
+
---
|
|
282
172
|
|
|
283
|
-
|
|
173
|
+
## 5. 扩展自定义权限类型
|
|
284
174
|
|
|
285
|
-
|
|
175
|
+
> 详细步骤见 `references/custom-data-scope.md`
|
|
286
176
|
|
|
287
|
-
|
|
288
|
-
* 按区域过滤(自定义类型示例)
|
|
289
|
-
*/
|
|
290
|
-
REGION("7", "按区域", "#{#regionName} IN ( #{@sdss.getUserRegions( #user.userId )} )"),
|
|
291
|
-
;
|
|
177
|
+
**步骤 1**:修改 `DataScopeType` 枚举
|
|
292
178
|
|
|
293
|
-
|
|
294
|
-
}
|
|
179
|
+
```java
|
|
180
|
+
REGION("7", "按区域", "#{#regionName} IN ( #{@sdss.getUserRegions( #user.userId )} )"),
|
|
295
181
|
```
|
|
296
182
|
|
|
297
|
-
**步骤 2**:在 `ISysDataScopeService`
|
|
183
|
+
**步骤 2**:在 `ISysDataScopeService` 添加方法
|
|
298
184
|
|
|
299
185
|
```java
|
|
300
|
-
// 接口
|
|
301
|
-
public interface ISysDataScopeService {
|
|
302
|
-
// ... 现有方法 ...
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* 获取用户关联的区域ID列表
|
|
306
|
-
*/
|
|
307
|
-
String getUserRegions(Long userId);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// 实现
|
|
311
186
|
@Service("sdss")
|
|
312
187
|
public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
|
313
|
-
|
|
314
188
|
@Override
|
|
315
189
|
@Cacheable(cacheNames = CacheNames.SYS_USER_REGIONS, key = "#userId")
|
|
316
190
|
public String getUserRegions(Long userId) {
|
|
317
191
|
List<Long> regionIds = userRegionMapper.selectRegionIdsByUserId(userId);
|
|
318
|
-
|
|
319
|
-
return "-1"; // 返回 -1 表示无权限
|
|
320
|
-
}
|
|
321
|
-
return StringUtils.join(regionIds, ",");
|
|
192
|
+
return CollUtil.isEmpty(regionIds) ? "-1" : StringUtils.join(regionIds, ",");
|
|
322
193
|
}
|
|
323
194
|
}
|
|
324
195
|
```
|
|
325
196
|
|
|
326
|
-
**步骤 3
|
|
197
|
+
**步骤 3**:使用
|
|
327
198
|
|
|
328
199
|
```java
|
|
329
200
|
@DataPermission({
|
|
330
201
|
@DataColumn(key = "regionName", value = "region_id")
|
|
331
202
|
})
|
|
332
|
-
@Override
|
|
333
|
-
public List<Store> listByRegion(StoreBo bo) {
|
|
334
|
-
return list(buildQueryWrapper(bo));
|
|
335
|
-
}
|
|
336
203
|
```
|
|
337
204
|
|
|
338
|
-
###
|
|
339
|
-
|
|
340
|
-
通过 `DataPermissionHelper` 设置自定义变量供 SpEL 表达式使用。
|
|
205
|
+
### 自定义变量
|
|
341
206
|
|
|
342
207
|
```java
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
public class OrderServiceImpl implements IOrderService {
|
|
346
|
-
|
|
347
|
-
private final OrderMapper baseMapper; // ✅ 直接注入 Mapper(NO DAO!)
|
|
348
|
-
|
|
349
|
-
@Override
|
|
350
|
-
public TableDataInfo<OrderVo> pageByShop(Long shopId, OrderBo bo, PageQuery pageQuery) {
|
|
351
|
-
// 设置自定义变量(请求结束后 SaStorage 自动清理,无需手动移除)
|
|
352
|
-
DataPermissionHelper.setVariable("shopId", shopId);
|
|
353
|
-
return pageWithPermission(bo, pageQuery);
|
|
354
|
-
}
|
|
208
|
+
// 设置自定义变量(请求结束后自动清理)
|
|
209
|
+
DataPermissionHelper.setVariable("shopId", shopId);
|
|
355
210
|
|
|
356
|
-
|
|
357
|
-
@
|
|
358
|
-
|
|
359
|
-
})
|
|
360
|
-
private TableDataInfo<OrderVo> pageWithPermission(OrderBo bo, PageQuery pageQuery) {
|
|
361
|
-
LambdaQueryWrapper<Order> lqw = buildQueryWrapper(bo);
|
|
362
|
-
Page<OrderVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
363
|
-
return TableDataInfo.build(result);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
211
|
+
@DataPermission({
|
|
212
|
+
@DataColumn(key = "shopId", value = "shop_id")
|
|
213
|
+
})
|
|
366
214
|
```
|
|
367
215
|
|
|
368
216
|
---
|
|
369
217
|
|
|
370
|
-
##
|
|
218
|
+
## 6. 多角色权限计算
|
|
371
219
|
|
|
372
|
-
|
|
220
|
+
- **SELECT 查询**:多角色权限用 `OR` 连接(并集)
|
|
221
|
+
- **UPDATE/DELETE**:多角色权限用 `AND` 连接(交集)
|
|
222
|
+
- 可通过 `joinStr` 参数自定义:
|
|
373
223
|
|
|
374
224
|
```java
|
|
375
|
-
|
|
376
|
-
@
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
@Override
|
|
380
|
-
public String getDeptAndChild(Long deptId) {
|
|
381
|
-
// ❌ 禁止!deptService.list() 如果带 @DataPermission 会死循环
|
|
382
|
-
List<SysDept> depts = deptService.list(wrapper);
|
|
383
|
-
|
|
384
|
-
// ✅ 正确:直接使用 Mapper 或忽略权限
|
|
385
|
-
List<SysDept> depts = deptMapper.selectList(wrapper);
|
|
386
|
-
// 或
|
|
387
|
-
List<SysDept> depts = DataPermissionHelper.ignore(() -> deptService.list(wrapper));
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// ❌ 禁止 2:表别名不匹配
|
|
392
|
-
@DataPermission({
|
|
393
|
-
@DataColumn(key = "deptName", value = "user.dept_id") // ❌ 别名是 user
|
|
394
|
-
})
|
|
395
|
-
// 但 SQL 是:SELECT * FROM sys_user u ... // 别名是 u
|
|
396
|
-
|
|
397
|
-
// ✅ 正确
|
|
398
|
-
@DataPermission({
|
|
399
|
-
@DataColumn(key = "deptName", value = "u.dept_id") // ✅ 与 SQL 别名一致
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
// ❌ 禁止 3:在 Controller 层使用 @DataPermission
|
|
403
|
-
@RestController
|
|
404
|
-
public class OrderController {
|
|
405
|
-
@DataPermission({...}) // ❌ 无效!必须在 Service/Mapper 层
|
|
406
|
-
@GetMapping("/list")
|
|
407
|
-
public R<List<OrderVo>> list() { }
|
|
408
|
-
}
|
|
225
|
+
@DataPermission(value = {
|
|
226
|
+
@DataColumn(key = "deptName", value = "create_dept")
|
|
227
|
+
}, joinStr = "AND")
|
|
409
228
|
```
|
|
410
229
|
|
|
411
|
-
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 7. 禁止项
|
|
412
233
|
|
|
413
234
|
```java
|
|
414
|
-
//
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
// ...
|
|
235
|
+
// ❌ 在 ISysDataScopeService 内调用带权限的方法(死循环)
|
|
236
|
+
public String getDeptAndChild(Long deptId) {
|
|
237
|
+
deptService.list(wrapper); // 如果带 @DataPermission 会死循环
|
|
238
|
+
// ✅ 直接用 Mapper 或 DataPermissionHelper.ignore()
|
|
239
|
+
deptMapper.selectList(wrapper);
|
|
420
240
|
}
|
|
421
241
|
|
|
422
|
-
//
|
|
423
|
-
@
|
|
424
|
-
@
|
|
425
|
-
public class OrderServiceImpl implements IOrderService {
|
|
426
|
-
|
|
427
|
-
private final OrderMapper baseMapper; // ✅ 直接注入 Mapper
|
|
242
|
+
// ❌ 表别名不匹配
|
|
243
|
+
@DataColumn(key = "deptName", value = "user.dept_id") // SQL 别名是 u
|
|
244
|
+
// ✅ @DataColumn(key = "deptName", value = "u.dept_id")
|
|
428
245
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
public TableDataInfo<OrderVo> pageWithPermission(...) { }
|
|
432
|
-
}
|
|
246
|
+
// ❌ 在 Controller 层使用 @DataPermission(无效!)
|
|
247
|
+
// ✅ 必须在 Service 实现类或 Mapper 接口上
|
|
433
248
|
|
|
434
|
-
// ✅
|
|
435
|
-
//
|
|
436
|
-
@DataPermission({
|
|
437
|
-
@DataColumn(key = "deptName", value = "o.create_dept"), // ✅ 订单表别名 o
|
|
438
|
-
@DataColumn(key = "userName", value = "o.create_by") // ✅ 使用 o.create_by
|
|
439
|
-
})
|
|
249
|
+
// ✅ Entity 必须继承 TenantEntity(包含 create_dept、create_by)
|
|
250
|
+
// ✅ 多表查询时使用正确的表别名
|
|
440
251
|
```
|
|
441
252
|
|
|
442
253
|
---
|
|
443
254
|
|
|
444
|
-
##
|
|
445
|
-
|
|
446
|
-
### 6.1 数据权限不生效
|
|
255
|
+
## 8. 问题排查
|
|
447
256
|
|
|
448
257
|
| 检查项 | 可能原因 | 解决方案 |
|
|
449
258
|
|--------|---------|---------|
|
|
450
|
-
|
|
|
451
|
-
|
|
|
452
|
-
|
|
|
453
|
-
|
|
|
454
|
-
|
|
|
259
|
+
| 超级管理员? | 超管自动跳过权限 | 用普通用户测试 |
|
|
260
|
+
| 角色数据范围? | 范围为"全部数据" | 修改角色数据权限 |
|
|
261
|
+
| 注解位置? | 不在 Service/Mapper 层 | 移动到 Service 实现类 |
|
|
262
|
+
| 表别名? | value 别名与 SQL 不一致 | 检查修正别名 |
|
|
263
|
+
| Unknown column? | 表别名不存在 | 检查 value 中的别名 |
|
|
264
|
+
| dept_id IN ()? | 权限服务返回空 | 检查 ISysDataScopeService |
|
|
455
265
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
| 错误现象 | 可能原因 | 解决方案 |
|
|
459
|
-
|---------|---------|---------|
|
|
460
|
-
| `Unknown column` | 表别名不存在 | 检查 value 中的表别名 |
|
|
461
|
-
| `dept_id IN ()` | 权限服务返回空 | 检查 ISysDataScopeService 实现 |
|
|
462
|
-
| 条件重复拼接 | 多次调用带权限的方法 | 检查调用链 |
|
|
463
|
-
|
|
464
|
-
### 6.3 调试技巧
|
|
266
|
+
**调试**:开启 SQL 日志查看拼接结果
|
|
465
267
|
|
|
466
268
|
```yaml
|
|
467
|
-
# application.yml - 开启 SQL 日志查看拼接结果
|
|
468
269
|
mybatis-plus:
|
|
469
270
|
configuration:
|
|
470
271
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
|
471
272
|
```
|
|
472
273
|
|
|
473
|
-
```java
|
|
474
|
-
// 代码中打印当前用户权限信息
|
|
475
|
-
LoginUser user = LoginHelper.getLoginUser();
|
|
476
|
-
log.info("当前用户: {}, 部门: {}, 角色: {}",
|
|
477
|
-
user.getUserId(),
|
|
478
|
-
user.getDeptId(),
|
|
479
|
-
user.getRoles().stream()
|
|
480
|
-
.map(r -> r.getRoleName() + "(" + r.getDataScope() + ")")
|
|
481
|
-
.collect(Collectors.joining(",")));
|
|
482
|
-
```
|
|
483
|
-
|
|
484
274
|
---
|
|
485
275
|
|
|
486
|
-
##
|
|
276
|
+
## 9. 核心类位置
|
|
487
277
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
// 方法 2:调用不带 @DataPermission 的 Service 方法
|
|
497
|
-
public List<Order> listAll() {
|
|
498
|
-
return orderService.list(); // 这个方法没有 @DataPermission
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// 方法 3:使用 permission 参数
|
|
502
|
-
@DataPermission({
|
|
503
|
-
@DataColumn(key = "deptName", value = "create_dept", permission = "order:all")
|
|
504
|
-
})
|
|
505
|
-
// 拥有 order:all 权限的角色不过滤
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
### Q2:多角色用户权限如何计算?
|
|
509
|
-
|
|
510
|
-
- **SELECT 查询**:多个角色的权限用 `OR` 连接(权限并集)
|
|
511
|
-
- **UPDATE/DELETE**:多个角色的权限用 `AND` 连接(权限交集)
|
|
512
|
-
- 可通过 `joinStr` 参数自定义
|
|
513
|
-
|
|
514
|
-
```java
|
|
515
|
-
@DataPermission(value = {
|
|
516
|
-
@DataColumn(key = "deptName", value = "create_dept")
|
|
517
|
-
}, joinStr = "AND") // 强制使用 AND 连接
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
### Q3:如何只对特定方法启用数据权限?
|
|
521
|
-
|
|
522
|
-
```java
|
|
523
|
-
@Service
|
|
524
|
-
@RequiredArgsConstructor
|
|
525
|
-
public class OrderServiceImpl implements IOrderService {
|
|
526
|
-
|
|
527
|
-
private final OrderMapper baseMapper; // ✅ 直接注入 Mapper
|
|
528
|
-
|
|
529
|
-
// 不带权限的普通查询
|
|
530
|
-
@Override
|
|
531
|
-
public List<Order> list(LambdaQueryWrapper<Order> wrapper) {
|
|
532
|
-
return baseMapper.selectList(wrapper);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// 带权限的查询(命名区分)
|
|
536
|
-
@DataPermission({
|
|
537
|
-
@DataColumn(key = "deptName", value = "create_dept")
|
|
538
|
-
})
|
|
539
|
-
@Override
|
|
540
|
-
public List<Order> listWithPermission(LambdaQueryWrapper<Order> wrapper) {
|
|
541
|
-
return baseMapper.selectList(wrapper);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
### Q4:如何在 Mapper XML 中使用数据权限?
|
|
547
|
-
|
|
548
|
-
```java
|
|
549
|
-
// Mapper 接口
|
|
550
|
-
@DataPermission({
|
|
551
|
-
@DataColumn(key = "deptName", value = "o.create_dept")
|
|
552
|
-
})
|
|
553
|
-
List<OrderVo> selectOrderReport(@Param("bo") OrderBo bo);
|
|
554
|
-
```
|
|
555
|
-
|
|
556
|
-
```xml
|
|
557
|
-
<!-- Mapper XML -->
|
|
558
|
-
<select id="selectOrderReport" resultType="OrderVo">
|
|
559
|
-
SELECT o.*, u.user_name
|
|
560
|
-
FROM m_order o
|
|
561
|
-
LEFT JOIN sys_user u ON o.create_by = u.user_id
|
|
562
|
-
WHERE o.status = #{bo.status}
|
|
563
|
-
<!-- 数据权限会自动追加到这里 -->
|
|
564
|
-
</select>
|
|
565
|
-
```
|
|
278
|
+
| 类 | 路径 |
|
|
279
|
+
|---|------|
|
|
280
|
+
| `@DataPermission` | `ruoyi-common/ruoyi-common-mybatis/.../annotation/DataPermission.java` |
|
|
281
|
+
| `@DataColumn` | `ruoyi-common/ruoyi-common-mybatis/.../annotation/DataColumn.java` |
|
|
282
|
+
| `DataScopeType` | `ruoyi-common/ruoyi-common-mybatis/.../enums/DataScopeType.java` |
|
|
283
|
+
| `DataPermissionHelper` | `ruoyi-common/ruoyi-common-mybatis/.../helper/DataPermissionHelper.java` |
|
|
284
|
+
| `PlusDataPermissionHandler` | `ruoyi-common/ruoyi-common-mybatis/.../handler/PlusDataPermissionHandler.java` |
|
|
285
|
+
| 使用示例 | `ruoyi-modules/ruoyi-system/.../impl/SysUserServiceImpl.java` |
|
|
566
286
|
|
|
567
287
|
---
|
|
568
288
|
|
|
569
|
-
##
|
|
570
|
-
|
|
571
|
-
### 核心文件
|
|
572
|
-
|
|
573
|
-
| 文件 | 路径 |
|
|
574
|
-
|------|------|
|
|
575
|
-
| @DataPermission | `ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/annotation/DataPermission.java` |
|
|
576
|
-
| @DataColumn | `ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/annotation/DataColumn.java` |
|
|
577
|
-
| DataScopeType | `ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/enums/DataScopeType.java` |
|
|
578
|
-
| PlusDataPermissionInterceptor | `ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/interceptor/PlusDataPermissionInterceptor.java` |
|
|
579
|
-
| PlusDataPermissionHandler | `ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/handler/PlusDataPermissionHandler.java` |
|
|
580
|
-
| DataPermissionHelper | `ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/helper/DataPermissionHelper.java` |
|
|
581
|
-
| ISysDataScopeService | `ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysDataScopeService.java` |
|
|
582
|
-
|
|
583
|
-
### 使用示例
|
|
584
|
-
|
|
585
|
-
| 文件 | 路径 |
|
|
586
|
-
|------|------|
|
|
587
|
-
| SysUserServiceImpl | `ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysUserServiceImpl.java` |
|
|
588
|
-
| SysRoleServiceImpl | `ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysRoleServiceImpl.java` |
|
|
589
|
-
| SysDeptMapper | `ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/mapper/SysDeptMapper.java` |
|
|
289
|
+
## 多项目适配说明
|
|
590
290
|
|
|
591
|
-
|
|
291
|
+
- 如果需要 leniu-tengyun-core 项目的数据权限开发规范,请使用 `leniu-data-permission` skill
|
|
292
|
+
- leniu-tengyun-core 使用物理库隔离架构,与 RuoYi-Vue-Plus 的逻辑隔离方式不同
|