@newpeak/barista-cli 0.1.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.
Files changed (82) hide show
  1. package/.eslintrc.json +23 -0
  2. package/.prettierrc +9 -0
  3. package/.sisyphus/notepads/liberica-employees/learnings.md +73 -0
  4. package/AGENTS.md +270 -0
  5. package/CONTRIBUTING.md +291 -0
  6. package/README.md +707 -0
  7. package/bin/barista +6 -0
  8. package/bin/barista.js +3 -0
  9. package/docs/ARCHITECTURE.md +184 -0
  10. package/docs/COMMANDS.md +352 -0
  11. package/docs/COMMAND_DESIGN_SPEC.md +811 -0
  12. package/docs/INTEGRATION_NOTES.md +270 -0
  13. package/docs/commands/REFERENCE.md +297 -0
  14. package/docs/commands/arabica/auth/index.md +296 -0
  15. package/docs/commands/liberica/auth/index.md +133 -0
  16. package/docs/commands/liberica/context/index.md +60 -0
  17. package/docs/commands/liberica/employees/create.md +185 -0
  18. package/docs/commands/liberica/employees/disable.md +138 -0
  19. package/docs/commands/liberica/employees/enable.md +137 -0
  20. package/docs/commands/liberica/employees/get.md +153 -0
  21. package/docs/commands/liberica/employees/list.md +168 -0
  22. package/docs/commands/liberica/employees/update.md +180 -0
  23. package/docs/commands/liberica/orgs/list.md +62 -0
  24. package/docs/commands/liberica/positions/list.md +61 -0
  25. package/docs/commands/liberica/roles/list.md +67 -0
  26. package/docs/commands/liberica/users/create.md +170 -0
  27. package/docs/commands/liberica/users/get.md +151 -0
  28. package/docs/commands/liberica/users/list.md +175 -0
  29. package/package.json +37 -0
  30. package/src/commands/arabica/auth/index.ts +277 -0
  31. package/src/commands/arabica/auth/login.ts +5 -0
  32. package/src/commands/arabica/auth/logout.ts +5 -0
  33. package/src/commands/arabica/auth/register.ts +5 -0
  34. package/src/commands/arabica/auth/status.ts +5 -0
  35. package/src/commands/arabica/index.ts +23 -0
  36. package/src/commands/auth.ts +107 -0
  37. package/src/commands/context.ts +60 -0
  38. package/src/commands/liberica/auth/index.ts +170 -0
  39. package/src/commands/liberica/context/index.ts +43 -0
  40. package/src/commands/liberica/employees/create.ts +275 -0
  41. package/src/commands/liberica/employees/delete.ts +122 -0
  42. package/src/commands/liberica/employees/disable.ts +97 -0
  43. package/src/commands/liberica/employees/enable.ts +97 -0
  44. package/src/commands/liberica/employees/get.ts +115 -0
  45. package/src/commands/liberica/employees/index.ts +23 -0
  46. package/src/commands/liberica/employees/list.ts +131 -0
  47. package/src/commands/liberica/employees/update.ts +157 -0
  48. package/src/commands/liberica/index.ts +36 -0
  49. package/src/commands/liberica/orgs/index.ts +35 -0
  50. package/src/commands/liberica/positions/index.ts +30 -0
  51. package/src/commands/liberica/roles/index.ts +59 -0
  52. package/src/commands/liberica/users/create.ts +132 -0
  53. package/src/commands/liberica/users/delete.ts +49 -0
  54. package/src/commands/liberica/users/disable.ts +41 -0
  55. package/src/commands/liberica/users/enable.ts +30 -0
  56. package/src/commands/liberica/users/get.ts +46 -0
  57. package/src/commands/liberica/users/index.ts +27 -0
  58. package/src/commands/liberica/users/list.ts +68 -0
  59. package/src/commands/liberica/users/me.ts +42 -0
  60. package/src/commands/liberica/users/reset-password.ts +42 -0
  61. package/src/commands/liberica/users/update.ts +48 -0
  62. package/src/core/api/client.ts +825 -0
  63. package/src/core/auth/token-manager.ts +183 -0
  64. package/src/core/config/manager.ts +164 -0
  65. package/src/index.ts +37 -0
  66. package/src/types/employee.ts +102 -0
  67. package/src/types/index.ts +75 -0
  68. package/src/types/org.ts +25 -0
  69. package/src/types/position.ts +24 -0
  70. package/src/types/user.ts +64 -0
  71. package/tests/unit/commands/arabica/auth.test.ts +230 -0
  72. package/tests/unit/commands/liberica/auth.test.ts +175 -0
  73. package/tests/unit/commands/liberica/context.test.ts +98 -0
  74. package/tests/unit/commands/liberica/employees/create.test.ts +463 -0
  75. package/tests/unit/commands/liberica/employees/disable.test.ts +82 -0
  76. package/tests/unit/commands/liberica/employees/enable.test.ts +82 -0
  77. package/tests/unit/commands/liberica/employees/get.test.ts +111 -0
  78. package/tests/unit/commands/liberica/employees/list.test.ts +294 -0
  79. package/tests/unit/commands/liberica/employees/update.test.ts +210 -0
  80. package/tests/unit/config.test.ts +141 -0
  81. package/tests/unit/types.test.ts +195 -0
  82. package/tsconfig.json +20 -0
@@ -0,0 +1,138 @@
1
+ # barista liberica employees disable
2
+
3
+ 禁用(停用)员工账号。
4
+
5
+ ## 2.1 命令元数据
6
+
7
+ | 字段 | 值 |
8
+ |------|-----|
9
+ | 完整命令 | `barista liberica employees disable <id>` |
10
+ | 功能描述 | 禁用(停用)员工账号 |
11
+ | HTTP方法 | POST |
12
+ | 是否需要认证 | ✅ 是 |
13
+ | 是否支持dry-run | ✅ 是 |
14
+
15
+ ## 2.2 后端接口引用
16
+
17
+ ### Controller位置
18
+ ```
19
+ coffee-liberica-end/
20
+ └── facade/liberica-facade-enterprise/
21
+ └── src/main/java/com/newpeak/liberica/facade/enterprise/controller/master/
22
+ └── EnterpriseEmployeeController.java
23
+ └── deActive(@PostResource(path = "/deActive", requiredPermission = true, requirePermissionCode = "DE_ACTIVE_EMPLOYEE"))
24
+ └── public ResponseData<String> deActive(
25
+ @RequestHeader("X-TENANT-ID") Long tenantId,
26
+ @RequestBody MasterEmployeeRequest request
27
+ )
28
+ ```
29
+
30
+ ### Request DTO位置
31
+ ```
32
+ coffee-liberica-end/
33
+ └── business/liberica-business-master/master-api/
34
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/request/
35
+ └── MasterEmployeeRequest.java
36
+ └── employeeId: Long
37
+ ```
38
+
39
+ ### Response DTO位置
40
+ ```
41
+ coffee-liberica-end/
42
+ └── business/liberica-business-master/master-api/
43
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/response/
44
+ └── MasterEmployeeResponse.java
45
+ └── 返回更新后的员工详情(同 create/update)
46
+ ```
47
+
48
+ ## 2.3 CLI参数设计
49
+
50
+ ### 命令结构
51
+ ```
52
+ barista liberica employees disable <id> [options]
53
+ ```
54
+
55
+ ### 位置参数
56
+ | 参数 | 类型 | 必填 | 说明 |
57
+ |------|------|------|------|
58
+ | id | number | ✅ | 员工ID (employeeId) |
59
+
60
+ ### 全局选项
61
+ | 选项 | 类型 | 说明 |
62
+ |------|------|------|
63
+ | `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
64
+ | `--tenant` | string | 租户代码 |
65
+ | `--dry-run` | boolean | 预览模式(不实际调用API) |
66
+ | `--json` | boolean | JSON输出 |
67
+
68
+ ### 命令选项
69
+ | 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
70
+ |------|--------|------|------|--------|------|
71
+ | --force | -f | boolean | ⬜ | false | 跳过确认提示 |
72
+
73
+ **说明**:
74
+ - `--dry-run` 预览禁用操作的影响(显示将禁用的员工信息)
75
+ - `--force` 直接执行,不显示确认提示(适用于脚本自动化)
76
+
77
+ ## 2.4 字段映射表
78
+
79
+ | CLI参数 | DTO字段 | 类型转换 | 验证规则 |
80
+ |---------|---------|----------|----------|
81
+ | <id> (位置参数) | employeeId | string→Long | @NotNull |
82
+
83
+ ## 2.5 错误码引用
84
+
85
+ ### ExceptionEnum位置
86
+ ```
87
+ coffee-liberica-end/
88
+ └── business/liberica-business-master/master-api/
89
+ └── src/main/java/com/newpeak/liberica/master/api/exception/enums/
90
+ └── EmployeeExceptionEnum.java
91
+ ├── MASTER_EMPLOYEE_NOT_EXISTED("01001150001", "查询结果不存在")
92
+ ├── DELETE_EMPLOYEE_ERROR("01001150002", "删除职员失败,该职员下有绑定数据")
93
+ └── MASTER_EMPLOYEE_NAME_VALIDATE_NOT_EXIST_ERROR("01001150009", "指定{}不存在")
94
+ ```
95
+
96
+ ### 已知错误码
97
+ | 错误码 | 错误消息 | 触发条件 |
98
+ |--------|----------|----------|
99
+ | 01001150001 | 查询结果不存在 | employeeId 不存在或不属于当前租户 |
100
+ | 01001150002 | 删除职员失败,该职员下有绑定数据 | 禁用时该员工存在绑定数据 |
101
+
102
+ ## 2.6 权限检查
103
+
104
+ | 检查项 | 位置 | 说明 |
105
+ |--------|------|------|
106
+ | PermissionConstants | `LibericaPermissionCodeConstants.DE_ACTIVE_EMPLOYEE` | Controller层 `@PostResource(requirePermissionCode = "DE_ACTIVE_EMPLOYEE")` |
107
+
108
+ ## 2.7 实现要点
109
+
110
+ 1. **幂等性**:deActive 操作是幂等的——对已禁用的员工再次调用效果相同(直接 set statusFlag=DISABLE)
111
+ 2. **幂等性原理**:后端直接 `LambdaUpdateWrapper.set(MasterEmployee::getStatusFlag, DISABLE)`,不检查当前状态
112
+ 3. **Dry-run模式**:预览显示将禁用的员工信息,但不实际发送请求
113
+ 4. **无强制选项**:--force 跳过确认提示,但不绕过后端权限检查
114
+ 5. **Error 01001150002**:如果禁用失败(存在绑定数据),显示后端错误消息
115
+
116
+ ## 2.8 示例用法
117
+
118
+ ```bash
119
+ # 禁用员工(交互确认)
120
+ barista liberica employees disable 12345
121
+
122
+ # 跳过确认直接禁用
123
+ barista liberica employees disable 12345 --force
124
+
125
+ # Dry-run 预览
126
+ barista liberica employees disable 12345 --dry-run
127
+
128
+ # JSON 输出
129
+ barista liberica employees disable 12345 --force --json
130
+
131
+ # 员工不存在
132
+ barista liberica employees disable 99999
133
+ # 输出: Error: 员工不存在 (01001150001)
134
+
135
+ # 员工有绑定数据
136
+ barista liberica employees disable 12345 --force
137
+ # 输出: Error: 删除职员失败,该职员下有绑定数据 (01001150002)
138
+ ```
@@ -0,0 +1,137 @@
1
+ # barista liberica employees enable
2
+
3
+ 启用(激活)员工账号。
4
+
5
+ ## 2.1 命令元数据
6
+
7
+ | 字段 | 值 |
8
+ |------|-----|
9
+ | 完整命令 | `barista liberica employees enable <id>` |
10
+ | 功能描述 | 启用(激活)员工账号 |
11
+ | HTTP方法 | POST |
12
+ | 是否需要认证 | ✅ 是 |
13
+ | 是否支持dry-run | ✅ 是 |
14
+
15
+ ## 2.2 后端接口引用
16
+
17
+ ### Controller位置
18
+ ```
19
+ coffee-liberica-end/
20
+ └── facade/liberica-facade-enterprise/
21
+ └── src/main/java/com/newpeak/liberica/facade/enterprise/controller/master/
22
+ └── EnterpriseEmployeeController.java
23
+ └── active(@PostResource(path = "/active", requiredPermission = true, requirePermissionCode = "ACTIVE_EMPLOYEE"))
24
+ └── public ResponseData<String> active(
25
+ @RequestHeader("X-TENANT-ID") Long tenantId,
26
+ @RequestBody MasterEmployeeRequest request
27
+ )
28
+ ```
29
+
30
+ ### Request DTO位置
31
+ ```
32
+ coffee-liberica-end/
33
+ └── business/liberica-business-master/master-api/
34
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/request/
35
+ └── MasterEmployeeRequest.java
36
+ └── employeeId: Long
37
+ ```
38
+
39
+ ### Response DTO位置
40
+ ```
41
+ coffee-liberica-end/
42
+ └── business/liberica-business-master/master-api/
43
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/response/
44
+ └── MasterEmployeeResponse.java
45
+ └── 返回更新后的员工详情(同 create/update)
46
+ ```
47
+
48
+ ## 2.3 CLI参数设计
49
+
50
+ ### 命令结构
51
+ ```
52
+ barista liberica employees enable <id> [options]
53
+ ```
54
+
55
+ ### 位置参数
56
+ | 参数 | 类型 | 必填 | 说明 |
57
+ |------|------|------|------|
58
+ | id | number | ✅ | 员工ID (employeeId) |
59
+
60
+ ### 全局选项
61
+ | 选项 | 类型 | 说明 |
62
+ |------|------|------|
63
+ | `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
64
+ | `--tenant` | string | 租户代码 |
65
+ | `--dry-run` | boolean | 预览模式(不实际调用API) |
66
+ | `--json` | boolean | JSON输出 |
67
+
68
+ ### 命令选项
69
+ | 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
70
+ |------|--------|------|------|--------|------|
71
+ | --force | -f | boolean | ⬜ | false | 跳过确认提示 |
72
+
73
+ **说明**:
74
+ - `--dry-run` 预览启用操作的影响(显示将启用的员工信息)
75
+ - `--force` 直接执行,不显示确认提示(适用于脚本自动化)
76
+
77
+ ## 2.4 字段映射表
78
+
79
+ | CLI参数 | DTO字段 | 类型转换 | 验证规则 |
80
+ |---------|---------|----------|----------|
81
+ | <id> (位置参数) | employeeId | string→Long | @NotNull |
82
+
83
+ ## 2.5 错误码引用
84
+
85
+ ### ExceptionEnum位置
86
+ ```
87
+ coffee-liberica-end/
88
+ └── business/liberica-business-master/master-api/
89
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/request/
90
+ └── MasterEmployeeRequest.java
91
+ ├── MASTER_EMPLOYEE_NOT_EXISTED("01001150001", "查询结果不存在")
92
+ └── MASTER_EMPLOYEE_NAME_VALIDATE_NOT_EXIST_ERROR("01001150009", "指定{}不存在")
93
+ ```
94
+
95
+ ### 已知错误码
96
+ | 错误码 | 错误消息 | 触发条件 |
97
+ |--------|----------|----------|
98
+ | 01001150001 | 查询结果不存在 | employeeId 不存在或不属于当前租户 |
99
+ | 01001150009 | 指定xxx不存在 | 指定关联的员工编码不存在 |
100
+
101
+ ## 2.6 权限检查
102
+
103
+ | 检查项 | 位置 | 说明 |
104
+ |--------|------|------|
105
+ | PermissionConstants | `LibericaPermissionCodeConstants.ACTIVE_EMPLOYEE` | Controller层 `@PostResource(requirePermissionCode = "ACTIVE_EMPLOYEE")` |
106
+
107
+ ## 2.7 实现要点
108
+
109
+ 1. **幂等性**:active 操作是幂等的——对已启用的员工再次调用效果相同(直接 set statusFlag=ENABLE)
110
+ 2. **幂等性原理**:后端直接 `LambdaUpdateWrapper.set(MasterEmployee::getStatusFlag, ENABLE)`,不检查当前状态
111
+ 3. **Dry-run模式**:预览显示将启用的员工信息,但不实际发送请求
112
+ 4. **无强制选项**:--force 跳过确认提示,但不绕过后端权限检查
113
+ 5. **与disable对称**:enable 与 disable 互为逆操作,使用相同的 employeeId 参数结构
114
+
115
+ ## 2.8 示例用法
116
+
117
+ ```bash
118
+ # 启用员工(交互确认)
119
+ barista liberica employees enable 12345
120
+
121
+ # 跳过确认直接启用
122
+ barista liberica employees enable 12345 --force
123
+
124
+ # Dry-run 预览
125
+ barista liberica employees enable 12345 --dry-run
126
+
127
+ # JSON 输出
128
+ barista liberica employees enable 12345 --force --json
129
+
130
+ # 员工不存在
131
+ barista liberica employees enable 99999
132
+ # 输出: Error: 员工不存在 (01001150001)
133
+
134
+ # 对已启用员工重复启用(幂等,无报错)
135
+ barista liberica employees enable 12345 --force
136
+ # 输出: ✓ 员工启用成功
137
+ ```
@@ -0,0 +1,153 @@
1
+ # barista liberica employees get
2
+
3
+ 获取单个员工详情。
4
+
5
+ ## 2.1 命令元数据
6
+
7
+ | 字段 | 值 |
8
+ |------|-----|
9
+ | 完整命令 | `barista liberica employees get <id>` |
10
+ | 功能描述 | 获取单个员工详情 |
11
+ | HTTP方法 | GET |
12
+ | 是否需要认证 | ✅ 是 |
13
+ | 是否支持dry-run | ⬜ 否 |
14
+
15
+ ## 2.2 后端接口引用
16
+
17
+ ### Controller位置
18
+ ```
19
+ coffee-liberica-end/
20
+ └── facade/liberica-facade-enterprise/
21
+ └── src/main/java/com/newpeak/liberica/facade/enterprise/controller/master/
22
+ └── EnterpriseEmployeeController.java
23
+ └── detail(@GetResource(path = "/detail"))
24
+ └── public ResponseData<MasterEmployeeResponse> detail(
25
+ @RequestHeader("X-TENANT-ID") Long tenantId,
26
+ @RequestParam("employeeId") Long employeeId
27
+ )
28
+ ```
29
+
30
+ ### Request DTO位置
31
+ ```
32
+ coffee-liberica-end/
33
+ └── business/liberica-business-master/master-api/
34
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/request/
35
+ └── MasterEmployeeRequest.java
36
+ └── employeeId: Long (@NotNull on detail)
37
+ ```
38
+
39
+ ### Response DTO位置
40
+ ```
41
+ coffee-liberica-end/
42
+ └── business/liberica-business-master/master-api/
43
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/response/
44
+ └── MasterEmployeeResponse.java
45
+ ├── employeeId: Long
46
+ ├── employeeCode: String
47
+ ├── employeeName: String
48
+ ├── employeeNo: String
49
+ ├── employeePhone: String
50
+ ├── employeeEmail: String
51
+ ├── employeeSex: SexEnum
52
+ ├── employeeIdType: String
53
+ ├── employeeIdNo: String
54
+ ├── employeeJoinedDate: Date
55
+ ├── employeeLeaveDate: Date
56
+ ├── employeeBirthday: Date
57
+ ├── organizationId: Long
58
+ ├── orgCode: String
59
+ ├── orgName: String
60
+ ├── organizationManagerFlag: String
61
+ ├── positionId: String
62
+ ├── positionName: String
63
+ ├── jobType: String
64
+ ├── jobLevelNo: String
65
+ ├── evaluator1: String (员工编码)
66
+ ├── evaluator2: String (员工编码)
67
+ ├── coach: String (员工编码)
68
+ ├── employeeStatus: String
69
+ ├── statusFlag: Integer (1=enable, 2=disable)
70
+ ├── employeeBankAccount: String
71
+ ├── employeeDepositBank: String
72
+ ├── account: String
73
+ ├── encryptPassword: String
74
+ ├── showQrCode: boolean
75
+ ├── qrCode: String (SVG)
76
+ ├── createTime: String
77
+ └── updateTime: String
78
+ ```
79
+
80
+ ## 2.3 CLI参数设计
81
+
82
+ ### 命令结构
83
+ ```
84
+ barista liberica employees get <id> [options]
85
+ ```
86
+
87
+ ### 位置参数
88
+ | 参数 | 类型 | 必填 | 说明 |
89
+ |------|------|------|------|
90
+ | id | number | ✅ | 员工ID (employeeId) |
91
+
92
+ ### 全局选项
93
+ | 选项 | 类型 | 说明 |
94
+ |------|------|------|
95
+ | `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
96
+ | `--tenant` | string | 租户代码 |
97
+ | `--json` | boolean | JSON输出 |
98
+
99
+ ### 命令选项
100
+ | 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
101
+ |------|--------|------|------|--------|------|
102
+ | — | — | — | — | — | 此命令无额外选项,ID 通过位置参数传入 |
103
+
104
+ ## 2.4 字段映射表
105
+
106
+ | CLI参数 | DTO字段 | 类型转换 | 验证规则 |
107
+ |---------|---------|----------|----------|
108
+ | <id> (位置参数) | employeeId | string→Long | @NotNull, 必须为正整数 |
109
+
110
+ ## 2.5 错误码引用
111
+
112
+ ### ExceptionEnum位置
113
+ ```
114
+ coffee-liberica-end/
115
+ └── business/liberica-business-master/master-api/
116
+ └── src/main/java/com/newpeak/liberica/master/api/exception/enums/
117
+ └── EmployeeExceptionEnum.java
118
+ ├── MASTER_EMPLOYEE_NOT_EXISTED("01001150001", "查询结果不存在")
119
+ ├── MASTER_EMPLOYEE_CODE_VALIDATE_NOT_EXIST_ERROR("01001150007", "指定{}不存在")
120
+ └── MASTER_EMPLOYEE_NAME_VALIDATE_NOT_EXIST_ERROR("01001150009", "指定{}不存在")
121
+ ```
122
+
123
+ ### 已知错误码
124
+ | 错误码 | 错误消息 | 触发条件 |
125
+ |--------|----------|----------|
126
+ | 01001150001 | 查询结果不存在 | employeeId 不存在或不属于当前租户 |
127
+
128
+ ## 2.6 权限检查
129
+
130
+ | 检查项 | 位置 | 说明 |
131
+ |--------|------|------|
132
+ | 注解 | `@GetResource(path = "/detail")` | 无 requiredPermission |
133
+
134
+ ## 2.7 实现要点
135
+
136
+ 1. **位置参数**:`get` 命令使用 `<id>` 位置参数指定员工ID
137
+ 2. **错误处理**:员工不存在时抛出 `MASTER_EMPLOYEE_NOT_EXISTED`,CLI 显示友好错误信息
138
+ 3. **tenantId来源**:来自 X-TENANT-ID header,后端自动按租户隔离数据
139
+ 4. **QR Code**:响应中包含 qrCode (SVG),可在需要时通过 --json 输出展示
140
+
141
+ ## 2.8 示例用法
142
+
143
+ ```bash
144
+ # 获取员工详情
145
+ barista liberica employees get 12345
146
+
147
+ # JSON 输出
148
+ barista liberica employees get 12345 --json
149
+
150
+ # 员工不存在
151
+ barista liberica employees get 99999
152
+ # 输出: Error: 员工不存在 (01001150001)
153
+ ```
@@ -0,0 +1,168 @@
1
+ # barista liberica employees list
2
+
3
+ 分页查询员工列表。
4
+
5
+ ## 2.1 命令元数据
6
+
7
+ | 字段 | 值 |
8
+ |------|-----|
9
+ | 完整命令 | `barista liberica employees list` |
10
+ | 功能描述 | 分页查询员工列表 |
11
+ | HTTP方法 | GET |
12
+ | 是否需要认证 | ✅ 是 |
13
+ | 是否支持dry-run | ⬜ 否 |
14
+
15
+ ## 2.2 后端接口引用
16
+
17
+ ### Controller位置
18
+ ```
19
+ coffee-liberica-end/
20
+ └── facade/liberica-facade-enterprise/
21
+ └── src/main/java/com/newpeak/liberica/facade/enterprise/controller/master/
22
+ └── EnterpriseEmployeeController.java
23
+ └── page(@GetResource(path = "/page"))
24
+ └── public ResponseData<PageResult<MasterEmployeeResponse>> page(
25
+ @RequestHeader("X-TENANT-ID") Long tenantId,
26
+ MasterEmployeeRequest request
27
+ )
28
+ ```
29
+
30
+ ### Request DTO位置
31
+ ```
32
+ coffee-liberica-end/
33
+ └── business/liberica-business-master/master-api/
34
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/request/
35
+ └── MasterEmployeeRequest.java
36
+ ├── current: Long (分页当前页)
37
+ ├── size: Long (分页大小)
38
+ ├── searchText: String (搜索: 姓名/编码)
39
+ ├── employeeStatus: String (在职状态)
40
+ ├── organizationId: Long (部门ID)
41
+ ├── excludeEmployeeCodeList: Set<String>
42
+ ├── excludeEmployeeIdList: Set<Long>
43
+ ├── searchBeginTime: String
44
+ └── searchEndTime: String
45
+ ```
46
+
47
+ ### Response DTO位置
48
+ ```
49
+ coffee-liberica-end/
50
+ └── business/liberica-business-master/master-api/
51
+ └── src/main/java/com/newpeak/liberica/master/api/pojo/response/
52
+ └── MasterEmployeeResponse.java
53
+ ├── employeeId: Long
54
+ ├── employeeCode: String
55
+ ├── employeeName: String
56
+ ├── employeeNo: String
57
+ ├── employeePhone: String
58
+ ├── employeeEmail: String
59
+ ├── employeeSex: SexEnum
60
+ ├── organizationId: Long
61
+ ├── orgName: String
62
+ ├── positionId: String
63
+ ├── positionName: String
64
+ ├── statusFlag: Integer (1=enable, 2=disable)
65
+ ├── createTime: String
66
+ └── updateTime: String
67
+ ```
68
+
69
+ ### 分页包装器
70
+ ```
71
+ cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult
72
+ ├── total: long
73
+ ├── size: long
74
+ ├── current: long
75
+ └── records: List<MasterEmployeeResponse>
76
+ ```
77
+
78
+ ## 2.3 CLI参数设计
79
+
80
+ ### 命令结构
81
+ ```
82
+ barista liberica employees list [options]
83
+ ```
84
+
85
+ ### 全局选项
86
+ | 选项 | 类型 | 说明 |
87
+ |------|------|------|
88
+ | `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
89
+ | `--tenant` | string | 租户代码 |
90
+ | `--json` | boolean | JSON输出 |
91
+
92
+ ### 命令选项
93
+ | 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 | 对应DTO字段 |
94
+ |------|--------|------|------|--------|------|-------------|
95
+ | --page | -p | number | ⬜ | 1 | 页码 | current |
96
+ | --size | -s | number | ⬜ | 20 | 每页条数 | size |
97
+ | --status | — | string | ⬜ | - | 在职状态 | employeeStatus |
98
+ | --org-id | — | number | ⬜ | - | 部门ID | organizationId |
99
+ | --search | — | string | ⬜ | - | 搜索关键词(姓名/编码) | searchText |
100
+
101
+ ## 2.4 字段映射表
102
+
103
+ | CLI参数 | DTO字段 | 类型转换 | 验证规则 |
104
+ |---------|---------|----------|----------|
105
+ | --page / -p | current | number→Long | >= 1 |
106
+ | --size / -s | size | number→Long | 1-100 |
107
+ | --status | employeeStatus | 直接传递 | 枚举验证 |
108
+ | --org-id | organizationId | string→Long | - |
109
+ | --search | searchText | 直接传递 | - |
110
+
111
+ ## 2.5 错误码引用
112
+
113
+ ### ExceptionEnum位置
114
+ ```
115
+ coffee-liberica-end/
116
+ └── business/liberica-business-master/master-api/
117
+ └── src/main/java/com/newpeak/liberica/master/api/exception/enums/
118
+ └── EmployeeExceptionEnum.java
119
+ ├── MASTER_EMPLOYEE_NOT_EXISTED("01001150001", "查询结果不存在")
120
+ ├── MASTER_EMPLOYEE_NAME_VALIDATE_NOT_EXIST_ERROR("01001150009", "指定{}不存在")
121
+ └── MASTER_EMPLOYEE_IMPORT_DATA_EMPTY("01001150010", "职员导入数据为空")
122
+ ```
123
+
124
+ ### 已知错误码
125
+ | 错误码 | 错误消息 | 触发条件 |
126
+ |--------|----------|----------|
127
+ | 01001150001 | 查询结果不存在 | 条件查询无匹配结果(通常返回空列表而非报错) |
128
+
129
+ ## 2.6 权限检查
130
+
131
+ | 检查项 | 位置 | 说明 |
132
+ |--------|------|------|
133
+ | 注解 | `@GetResource(path = "/page")` | 无 requiredPermission(无需权限码) |
134
+
135
+ **注意**:list 和 page 接口在 Controller 层无需权限校验,数据范围通过 tenantId 隔离。
136
+
137
+ ## 2.7 实现要点
138
+
139
+ 1. **分页默认值**:page=1, size=20
140
+ 2. **搜索行为**:searchText 同时匹配 employeeName 和 employeeCode(模糊查询)
141
+ 3. **无结果处理**:返回空列表,不抛出异常
142
+ 4. **tenantId来源**:来自 X-TENANT-ID header
143
+ 5. **输出格式**:表格形式展示,分页信息在底部显示
144
+
145
+ ## 2.8 示例用法
146
+
147
+ ```bash
148
+ # 默认分页
149
+ barista liberica employees list
150
+
151
+ # 指定页码和每页条数
152
+ barista liberica employees list --page 2 --size 50
153
+
154
+ # 按部门筛选
155
+ barista liberica employees list --org-id 1001
156
+
157
+ # 按在职状态筛选
158
+ barista liberica employees list --status IN_SERVICE
159
+
160
+ # 关键词搜索
161
+ barista liberica employees list --search "张三"
162
+
163
+ # 组合筛选
164
+ barista liberica employees list --page 1 --size 10 --org-id 1001 --status IN_SERVICE
165
+
166
+ # JSON 输出(便于脚本处理)
167
+ barista liberica employees list --page 1 --size 20 --json
168
+ ```