ai-engineering-init 1.3.3 → 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 +4 -1
- package/.claude/settings.json +3 -3
- package/.claude/skills/add-skill/SKILL.md +252 -116
- 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 -325
- package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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 +252 -116
- 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 -325
- package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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/rules/skill-activation.mdc +2 -0
- package/.cursor/skills/add-skill/SKILL.md +252 -116
- 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 -325
- package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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/AGENTS.md +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# 扩展自定义数据权限类型 - 完整指南
|
|
2
|
+
|
|
3
|
+
## 步骤 1:修改 DataScopeType 枚举
|
|
4
|
+
|
|
5
|
+
位置:`ruoyi-common-mybatis/.../enums/DataScopeType.java`
|
|
6
|
+
|
|
7
|
+
```java
|
|
8
|
+
public enum DataScopeType {
|
|
9
|
+
|
|
10
|
+
// ... 现有类型 ...
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 按区域过滤(自定义类型示例)
|
|
14
|
+
*/
|
|
15
|
+
REGION("7", "按区域", "#{#regionName} IN ( #{@sdss.getUserRegions( #user.userId )} )"),
|
|
16
|
+
;
|
|
17
|
+
|
|
18
|
+
// ... 其他代码 ...
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 步骤 2:在 ISysDataScopeService 中添加方法
|
|
23
|
+
|
|
24
|
+
```java
|
|
25
|
+
// 接口
|
|
26
|
+
public interface ISysDataScopeService {
|
|
27
|
+
// ... 现有方法 ...
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 获取用户关联的区域ID列表
|
|
31
|
+
*/
|
|
32
|
+
String getUserRegions(Long userId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 实现
|
|
36
|
+
@Service("sdss")
|
|
37
|
+
public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
@Cacheable(cacheNames = CacheNames.SYS_USER_REGIONS, key = "#userId")
|
|
41
|
+
public String getUserRegions(Long userId) {
|
|
42
|
+
List<Long> regionIds = userRegionMapper.selectRegionIdsByUserId(userId);
|
|
43
|
+
if (CollUtil.isEmpty(regionIds)) {
|
|
44
|
+
return "-1"; // 返回 -1 表示无权限
|
|
45
|
+
}
|
|
46
|
+
return StringUtils.join(regionIds, ",");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 步骤 3:使用新权限类型
|
|
52
|
+
|
|
53
|
+
```java
|
|
54
|
+
@DataPermission({
|
|
55
|
+
@DataColumn(key = "regionName", value = "region_id")
|
|
56
|
+
})
|
|
57
|
+
@Override
|
|
58
|
+
public List<Store> listByRegion(StoreBo bo) {
|
|
59
|
+
return list(buildQueryWrapper(bo));
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 添加自定义变量
|
|
64
|
+
|
|
65
|
+
通过 `DataPermissionHelper` 设置自定义变量供 SpEL 表达式使用。
|
|
66
|
+
|
|
67
|
+
```java
|
|
68
|
+
@Service
|
|
69
|
+
@RequiredArgsConstructor
|
|
70
|
+
public class OrderServiceImpl implements IOrderService {
|
|
71
|
+
|
|
72
|
+
private final OrderMapper baseMapper;
|
|
73
|
+
|
|
74
|
+
@Override
|
|
75
|
+
public TableDataInfo<OrderVo> pageByShop(Long shopId, OrderBo bo, PageQuery pageQuery) {
|
|
76
|
+
// 设置自定义变量(请求结束后 SaStorage 自动清理,无需手动移除)
|
|
77
|
+
DataPermissionHelper.setVariable("shopId", shopId);
|
|
78
|
+
return pageWithPermission(bo, pageQuery);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@DataPermission({
|
|
82
|
+
@DataColumn(key = "shopId", value = "shop_id")
|
|
83
|
+
})
|
|
84
|
+
private TableDataInfo<OrderVo> pageWithPermission(OrderBo bo, PageQuery pageQuery) {
|
|
85
|
+
LambdaQueryWrapper<Order> lqw = buildQueryWrapper(bo);
|
|
86
|
+
Page<OrderVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
87
|
+
return TableDataInfo.build(result);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
@@ -393,161 +393,15 @@ COMMENT='用户表' -- ✅ 表注释
|
|
|
393
393
|
|
|
394
394
|
---
|
|
395
395
|
|
|
396
|
-
##
|
|
397
|
-
|
|
398
|
-
### 不同项目数据库设计对比
|
|
399
|
-
|
|
400
|
-
| 项目特征 | RuoYi-Vue-Plus | leniu-tengyun-core |
|
|
401
|
-
|---------|----------------|-------------------|
|
|
402
|
-
| **主键类型** | 雪花 ID (Long) | 雪花 ID (Long) |
|
|
403
|
-
| **逻辑删除** | `del_flag BIGINT` | `del_flag TINYINT` |
|
|
404
|
-
| **审计字段** | `create_by`, `create_time` | `crby`, `crtime` |
|
|
405
|
-
| **表前缀** | `sys_`, `test_`, `flow_` | 按业务命名 |
|
|
406
|
-
|
|
407
|
-
### 通用数据库原则
|
|
408
|
-
|
|
409
|
-
1. **主键使用雪花 ID**:不使用 AUTO_INCREMENT
|
|
410
|
-
2. **必须包含审计字段**:创建人、创建时间、更新人、更新时间
|
|
411
|
-
3. **逻辑删除字段**:`del_flag` 或类似字段
|
|
412
|
-
4. **字段命名使用蛇形**:`user_name` 而非 `userName`
|
|
413
|
-
5. **索引命名规范**:`pk_`, `uk_`, `idx_` 前缀
|
|
414
|
-
6. **COMMENT 使用中文**:所有字段和表注释
|
|
415
|
-
|
|
416
|
-
### 参考 java*skill
|
|
417
|
-
|
|
418
|
-
更详细的规范请参考 `java-database` 技能。
|
|
419
|
-
|
|
420
|
-
---
|
|
421
|
-
|
|
422
|
-
## leniu-tengyun-core 数据库设计
|
|
423
|
-
|
|
424
|
-
### ⚠️ 双库架构(重要差异)
|
|
425
|
-
|
|
426
|
-
leniu-tengyun-core 采用**双库架构**进行租户隔离,与 RuoYi-Vue-Plus 的单库 tenant_id 方式完全不同:
|
|
427
|
-
|
|
428
|
-
| 特性 | RuoYi-Vue-Plus | leniu-tengyun-core |
|
|
429
|
-
|------|----------------|-------------------|
|
|
430
|
-
| **隔离方式** | 单库 + tenant_id 字段 | 双库(商户库 + 系统库) |
|
|
431
|
-
| **租户字段** | Entity 包含 tenant_id | **Entity 不包含 tenant_id** |
|
|
432
|
-
| **路由机制** | SQL 自动拼接 tenant_id | 请求头决定访问哪个库 |
|
|
433
|
-
|
|
434
|
-
**双库架构说明**:
|
|
435
|
-
- **系统库**:前端请求头**不携带**商户ID时,自动请求系统库
|
|
436
|
-
- **商户库**:前端请求头**携带**商户ID时,自动请求商户库
|
|
437
|
-
- **租户上下文**:通过 `TenantContextHolder.getTenantId()` 获取,而非 Entity 字段
|
|
438
|
-
|
|
439
|
-
### 审计字段命名差异
|
|
440
|
-
|
|
441
|
-
| 字段用途 | RuoYi-Vue-Plus | leniu-tengyun-core |
|
|
442
|
-
|---------|----------------|-------------------|
|
|
443
|
-
| **创建人** | `create_by` | `crby` |
|
|
444
|
-
| **创建时间** | `create_time` | `crtime` |
|
|
445
|
-
| **更新人** | `update_by` | `upby` / `modby` |
|
|
446
|
-
| **更新时间** | `update_time` | `uptime` / `modtime` |
|
|
447
|
-
| **创建部门** | `create_dept` | 无 |
|
|
448
|
-
| **租户ID** | `tenant_id` (字段) | **无字段**(双库隔离) |
|
|
449
|
-
| **删除标志** | `del_flag BIGINT` | `del_flag TINYINT/INTEGER` |
|
|
450
|
-
|
|
451
|
-
### Entity 类示例
|
|
452
|
-
|
|
453
|
-
```java
|
|
454
|
-
// leniu-tengyun-core 风格
|
|
455
|
-
// ⚠️ 注意:不需要 tenant_id 字段!租户隔离通过双库架构实现
|
|
456
|
-
@Data
|
|
457
|
-
@TableName("leave_info")
|
|
458
|
-
@ApiModel("请假信息")
|
|
459
|
-
@EqualsAndHashCode(callSuper = false)
|
|
460
|
-
public class LeaveInfo extends Model<LeaveInfo> {
|
|
461
|
-
|
|
462
|
-
@TableId(value = "id") // 默认雪花ID
|
|
463
|
-
private Long id;
|
|
464
|
-
|
|
465
|
-
// ❌ 不需要 tenant_id 字段!
|
|
466
|
-
// @TableField("tenant_id")
|
|
467
|
-
// private Long tenantId;
|
|
468
|
-
|
|
469
|
-
@TableField("leave_type")
|
|
470
|
-
private String leaveType;
|
|
471
|
-
|
|
472
|
-
@TableField("start_time")
|
|
473
|
-
private LocalDateTime startTime;
|
|
474
|
-
|
|
475
|
-
@TableField("end_time")
|
|
476
|
-
private LocalDateTime endTime;
|
|
477
|
-
|
|
478
|
-
@TableField("reason")
|
|
479
|
-
private String reason;
|
|
480
|
-
|
|
481
|
-
@TableField("status")
|
|
482
|
-
private Integer status;
|
|
483
|
-
|
|
484
|
-
@TableLogic
|
|
485
|
-
@TableField("del_flag")
|
|
486
|
-
private Integer delFlag; // 1=删除, 2=正常 (DelFlagEnum)
|
|
487
|
-
|
|
488
|
-
@TableField(value = "crby", fill = FieldFill.INSERT)
|
|
489
|
-
private String crby; // 创建人
|
|
490
|
-
|
|
491
|
-
@TableField(value = "crtime", fill = FieldFill.INSERT)
|
|
492
|
-
private LocalDateTime crtime; // 创建时间
|
|
493
|
-
|
|
494
|
-
@TableField(value = "upby", fill = FieldFill.UPDATE)
|
|
495
|
-
private String upby; // 更新人
|
|
496
|
-
|
|
497
|
-
@TableField(value = "uptime", fill = FieldFill.UPDATE)
|
|
498
|
-
private LocalDateTime uptime; // 更新时间
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// 获取租户ID的方式(从上下文获取,而非Entity字段)
|
|
502
|
-
Long tenantId = TenantContextHolder.getTenantId();
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
### 建表 SQL 对比
|
|
506
|
-
|
|
507
|
-
```sql
|
|
508
|
-
-- RuoYi-Vue-Plus 风格(单库 + tenant_id)
|
|
509
|
-
CREATE TABLE `sys_order` (
|
|
510
|
-
`id` BIGINT(20) NOT NULL COMMENT '主键ID',
|
|
511
|
-
`tenant_id` VARCHAR(20) DEFAULT '000000' COMMENT '租户ID',
|
|
512
|
-
`order_no` VARCHAR(50) NOT NULL COMMENT '订单号',
|
|
513
|
-
`status` CHAR(1) DEFAULT '0' COMMENT '状态',
|
|
514
|
-
`create_dept` BIGINT(20) DEFAULT NULL COMMENT '创建部门',
|
|
515
|
-
`create_by` BIGINT(20) DEFAULT NULL COMMENT '创建人',
|
|
516
|
-
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
517
|
-
`update_by` BIGINT(20) DEFAULT NULL COMMENT '更新人',
|
|
518
|
-
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
519
|
-
`del_flag` BIGINT(20) DEFAULT 0 COMMENT '删除标志',
|
|
520
|
-
PRIMARY KEY (`id`)
|
|
521
|
-
) ENGINE=InnoDB COMMENT='订单表';
|
|
522
|
-
|
|
523
|
-
-- leniu-tengyun-core 风格(双库架构,不需要 tenant_id)
|
|
524
|
-
CREATE TABLE `leave_info` (
|
|
525
|
-
`id` BIGINT(20) NOT NULL COMMENT '主键ID',
|
|
526
|
-
-- ❌ 不需要 tenant_id 字段!双库架构自动隔离
|
|
527
|
-
`leave_type` VARCHAR(20) NOT NULL COMMENT '请假类型',
|
|
528
|
-
`start_time` DATETIME NOT NULL COMMENT '开始时间',
|
|
529
|
-
`end_time` DATETIME NOT NULL COMMENT '结束时间',
|
|
530
|
-
`reason` VARCHAR(500) DEFAULT NULL COMMENT '请假原因',
|
|
531
|
-
`status` INT DEFAULT 0 COMMENT '状态',
|
|
532
|
-
`crby` VARCHAR(64) DEFAULT NULL COMMENT '创建人',
|
|
533
|
-
`crtime` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
534
|
-
`upby` VARCHAR(64) DEFAULT NULL COMMENT '更新人',
|
|
535
|
-
`uptime` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
536
|
-
`del_flag` TINYINT DEFAULT 2 COMMENT '删除标志(1删除 2正常)',
|
|
537
|
-
PRIMARY KEY (`id`),
|
|
538
|
-
INDEX `idx_crtime` (`crtime`)
|
|
539
|
-
) ENGINE=InnoDB COMMENT='请假信息表';
|
|
540
|
-
```
|
|
396
|
+
## 参考实现
|
|
541
397
|
|
|
542
|
-
|
|
398
|
+
查看已有的完整实现:
|
|
543
399
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
| **架构** | 单库多租户 | 双库(系统库 + 商户库) |
|
|
547
|
-
| **路由依据** | Entity 中的 tenant_id | 请求头中的商户ID |
|
|
548
|
-
| **Entity 字段** | 需要 tenant_id | 不需要 tenant_id |
|
|
549
|
-
| **获取租户** | `LoginHelper.getTenantId()` | `TenantContextHolder.getTenantId()` |
|
|
550
|
-
| **跨租户查询** | `TenantHelper.dynamic()` | `Executors.readInSystem()` |
|
|
400
|
+
- **Entity 参考**: `org.dromara.demo.domain.TestDemo`
|
|
401
|
+
- **表结构参考**: `script/sql/ry_vue_5.X.sql` 中的 test_demo 表
|
|
551
402
|
|
|
552
|
-
|
|
403
|
+
**特别注意**:
|
|
404
|
+
- ✅ 软删除字段类型是 `Long delFlag`(不是 CHAR(1))
|
|
405
|
+
- ✅ MyBatis-Plus 自动将 Java `delFlag` 映射到数据库 `del_flag`
|
|
406
|
+
- ✅ `@TableLogic` 注解自动处理查询和删除操作
|
|
553
407
|
|
|
@@ -359,3 +359,13 @@ public void batchOperation() {
|
|
|
359
359
|
| `log.error("失败: " + e.getMessage())` | `log.error("失败: {}", e.getMessage(), e)` |
|
|
360
360
|
| `@Transactional` | `@Transactional(rollbackFor = Exception.class)` |
|
|
361
361
|
| `throw new ServiceException("DB error")` | `throw new ServiceException("数据保存失败,请重试")` |
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## 相关技能
|
|
366
|
+
|
|
367
|
+
| 需要了解 | 激活 Skill |
|
|
368
|
+
|---------|-----------|
|
|
369
|
+
| Java 异常规范 | `java-exception` |
|
|
370
|
+
| Service 层规范 | `java-service` |
|
|
371
|
+
| Controller 层规范 | `java-controller` |
|