@newpeak/barista-cli 0.1.3 → 0.1.5

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 (205) hide show
  1. package/dist/commands/liberica/auth/index.d.ts.map +1 -1
  2. package/dist/commands/liberica/auth/index.js +5 -0
  3. package/dist/commands/liberica/auth/index.js.map +1 -1
  4. package/dist/commands/liberica/clients/create.d.ts +3 -0
  5. package/dist/commands/liberica/clients/create.d.ts.map +1 -0
  6. package/dist/commands/liberica/clients/create.js +125 -0
  7. package/dist/commands/liberica/clients/create.js.map +1 -0
  8. package/dist/commands/liberica/clients/delete.d.ts +3 -0
  9. package/dist/commands/liberica/clients/delete.d.ts.map +1 -0
  10. package/dist/commands/liberica/clients/delete.js +125 -0
  11. package/dist/commands/liberica/clients/delete.js.map +1 -0
  12. package/dist/commands/liberica/clients/get.d.ts +3 -0
  13. package/dist/commands/liberica/clients/get.d.ts.map +1 -0
  14. package/dist/commands/liberica/clients/get.js +77 -0
  15. package/dist/commands/liberica/clients/get.js.map +1 -0
  16. package/dist/commands/liberica/clients/index.d.ts +3 -0
  17. package/dist/commands/liberica/clients/index.d.ts.map +1 -0
  18. package/dist/commands/liberica/clients/index.js +17 -0
  19. package/dist/commands/liberica/clients/index.js.map +1 -0
  20. package/dist/commands/liberica/clients/list.d.ts +3 -0
  21. package/dist/commands/liberica/clients/list.d.ts.map +1 -0
  22. package/dist/commands/liberica/clients/list.js +92 -0
  23. package/dist/commands/liberica/clients/list.js.map +1 -0
  24. package/dist/commands/liberica/clients/update.d.ts +3 -0
  25. package/dist/commands/liberica/clients/update.d.ts.map +1 -0
  26. package/dist/commands/liberica/clients/update.js +106 -0
  27. package/dist/commands/liberica/clients/update.js.map +1 -0
  28. package/dist/commands/liberica/index.d.ts.map +1 -1
  29. package/dist/commands/liberica/index.js +11 -0
  30. package/dist/commands/liberica/index.js.map +1 -1
  31. package/dist/commands/liberica/materials/create.d.ts +3 -0
  32. package/dist/commands/liberica/materials/create.d.ts.map +1 -0
  33. package/dist/commands/liberica/materials/create.js +154 -0
  34. package/dist/commands/liberica/materials/create.js.map +1 -0
  35. package/dist/commands/liberica/materials/delete.d.ts +3 -0
  36. package/dist/commands/liberica/materials/delete.d.ts.map +1 -0
  37. package/dist/commands/liberica/materials/delete.js +104 -0
  38. package/dist/commands/liberica/materials/delete.js.map +1 -0
  39. package/dist/commands/liberica/materials/disable.d.ts +3 -0
  40. package/dist/commands/liberica/materials/disable.d.ts.map +1 -0
  41. package/dist/commands/liberica/materials/disable.js +146 -0
  42. package/dist/commands/liberica/materials/disable.js.map +1 -0
  43. package/dist/commands/liberica/materials/enable.d.ts +3 -0
  44. package/dist/commands/liberica/materials/enable.d.ts.map +1 -0
  45. package/dist/commands/liberica/materials/enable.js +126 -0
  46. package/dist/commands/liberica/materials/enable.js.map +1 -0
  47. package/dist/commands/liberica/materials/get.d.ts +3 -0
  48. package/dist/commands/liberica/materials/get.d.ts.map +1 -0
  49. package/dist/commands/liberica/materials/get.js +71 -0
  50. package/dist/commands/liberica/materials/get.js.map +1 -0
  51. package/dist/commands/liberica/materials/index.d.ts +3 -0
  52. package/dist/commands/liberica/materials/index.d.ts.map +1 -0
  53. package/dist/commands/liberica/materials/index.js +21 -0
  54. package/dist/commands/liberica/materials/index.js.map +1 -0
  55. package/dist/commands/liberica/materials/list.d.ts +3 -0
  56. package/dist/commands/liberica/materials/list.d.ts.map +1 -0
  57. package/dist/commands/liberica/materials/list.js +107 -0
  58. package/dist/commands/liberica/materials/list.js.map +1 -0
  59. package/dist/commands/liberica/materials/update.d.ts +3 -0
  60. package/dist/commands/liberica/materials/update.d.ts.map +1 -0
  61. package/dist/commands/liberica/materials/update.js +118 -0
  62. package/dist/commands/liberica/materials/update.js.map +1 -0
  63. package/dist/commands/liberica/suppliers/create.d.ts +3 -0
  64. package/dist/commands/liberica/suppliers/create.d.ts.map +1 -0
  65. package/dist/commands/liberica/suppliers/create.js +140 -0
  66. package/dist/commands/liberica/suppliers/create.js.map +1 -0
  67. package/dist/commands/liberica/suppliers/delete.d.ts +3 -0
  68. package/dist/commands/liberica/suppliers/delete.d.ts.map +1 -0
  69. package/dist/commands/liberica/suppliers/delete.js +102 -0
  70. package/dist/commands/liberica/suppliers/delete.js.map +1 -0
  71. package/dist/commands/liberica/suppliers/disable.d.ts +3 -0
  72. package/dist/commands/liberica/suppliers/disable.d.ts.map +1 -0
  73. package/dist/commands/liberica/suppliers/disable.js +144 -0
  74. package/dist/commands/liberica/suppliers/disable.js.map +1 -0
  75. package/dist/commands/liberica/suppliers/enable.d.ts +3 -0
  76. package/dist/commands/liberica/suppliers/enable.d.ts.map +1 -0
  77. package/dist/commands/liberica/suppliers/enable.js +124 -0
  78. package/dist/commands/liberica/suppliers/enable.js.map +1 -0
  79. package/dist/commands/liberica/suppliers/get.d.ts +3 -0
  80. package/dist/commands/liberica/suppliers/get.d.ts.map +1 -0
  81. package/dist/commands/liberica/suppliers/get.js +75 -0
  82. package/dist/commands/liberica/suppliers/get.js.map +1 -0
  83. package/dist/commands/liberica/suppliers/index.d.ts +3 -0
  84. package/dist/commands/liberica/suppliers/index.d.ts.map +1 -0
  85. package/dist/commands/liberica/suppliers/index.js +21 -0
  86. package/dist/commands/liberica/suppliers/index.js.map +1 -0
  87. package/dist/commands/liberica/suppliers/list.d.ts +3 -0
  88. package/dist/commands/liberica/suppliers/list.d.ts.map +1 -0
  89. package/dist/commands/liberica/suppliers/list.js +100 -0
  90. package/dist/commands/liberica/suppliers/list.js.map +1 -0
  91. package/dist/commands/liberica/suppliers/update.d.ts +3 -0
  92. package/dist/commands/liberica/suppliers/update.d.ts.map +1 -0
  93. package/dist/commands/liberica/suppliers/update.js +122 -0
  94. package/dist/commands/liberica/suppliers/update.js.map +1 -0
  95. package/dist/commands/liberica/uoms/create.d.ts +3 -0
  96. package/dist/commands/liberica/uoms/create.d.ts.map +1 -0
  97. package/dist/commands/liberica/uoms/create.js +120 -0
  98. package/dist/commands/liberica/uoms/create.js.map +1 -0
  99. package/dist/commands/liberica/uoms/delete.d.ts +3 -0
  100. package/dist/commands/liberica/uoms/delete.d.ts.map +1 -0
  101. package/dist/commands/liberica/uoms/delete.js +104 -0
  102. package/dist/commands/liberica/uoms/delete.js.map +1 -0
  103. package/dist/commands/liberica/uoms/disable.d.ts +3 -0
  104. package/dist/commands/liberica/uoms/disable.d.ts.map +1 -0
  105. package/dist/commands/liberica/uoms/disable.js +146 -0
  106. package/dist/commands/liberica/uoms/disable.js.map +1 -0
  107. package/dist/commands/liberica/uoms/enable.d.ts +3 -0
  108. package/dist/commands/liberica/uoms/enable.d.ts.map +1 -0
  109. package/dist/commands/liberica/uoms/enable.js +126 -0
  110. package/dist/commands/liberica/uoms/enable.js.map +1 -0
  111. package/dist/commands/liberica/uoms/get.d.ts +3 -0
  112. package/dist/commands/liberica/uoms/get.d.ts.map +1 -0
  113. package/dist/commands/liberica/uoms/get.js +71 -0
  114. package/dist/commands/liberica/uoms/get.js.map +1 -0
  115. package/dist/commands/liberica/uoms/index.d.ts +3 -0
  116. package/dist/commands/liberica/uoms/index.d.ts.map +1 -0
  117. package/dist/commands/liberica/uoms/index.js +21 -0
  118. package/dist/commands/liberica/uoms/index.js.map +1 -0
  119. package/dist/commands/liberica/uoms/list.d.ts +3 -0
  120. package/dist/commands/liberica/uoms/list.d.ts.map +1 -0
  121. package/dist/commands/liberica/uoms/list.js +98 -0
  122. package/dist/commands/liberica/uoms/list.js.map +1 -0
  123. package/dist/commands/liberica/uoms/update.d.ts +3 -0
  124. package/dist/commands/liberica/uoms/update.d.ts.map +1 -0
  125. package/dist/commands/liberica/uoms/update.js +115 -0
  126. package/dist/commands/liberica/uoms/update.js.map +1 -0
  127. package/dist/core/api/client.d.ts +30 -0
  128. package/dist/core/api/client.d.ts.map +1 -1
  129. package/dist/core/api/client.js +590 -0
  130. package/dist/core/api/client.js.map +1 -1
  131. package/dist/index.js +1 -1
  132. package/dist/types/client.d.ts +100 -0
  133. package/dist/types/client.d.ts.map +1 -0
  134. package/dist/types/client.js +2 -0
  135. package/dist/types/client.js.map +1 -0
  136. package/dist/types/index.d.ts +6 -0
  137. package/dist/types/index.d.ts.map +1 -1
  138. package/dist/types/material.d.ts +49 -0
  139. package/dist/types/material.d.ts.map +1 -0
  140. package/dist/types/material.js +2 -0
  141. package/dist/types/material.js.map +1 -0
  142. package/dist/types/supplier.d.ts +53 -0
  143. package/dist/types/supplier.d.ts.map +1 -0
  144. package/dist/types/supplier.js +2 -0
  145. package/dist/types/supplier.js.map +1 -0
  146. package/dist/types/uom.d.ts +47 -0
  147. package/dist/types/uom.d.ts.map +1 -0
  148. package/dist/types/uom.js +2 -0
  149. package/dist/types/uom.js.map +1 -0
  150. package/docs/commands/REFERENCE.md +21 -15
  151. package/docs/commands/liberica/materials-create.md +293 -0
  152. package/docs/commands/liberica/materials-delete.md +240 -0
  153. package/docs/commands/liberica/materials-disable.md +150 -0
  154. package/docs/commands/liberica/materials-enable.md +146 -0
  155. package/docs/commands/liberica/materials-get.md +188 -0
  156. package/docs/commands/liberica/materials-list.md +198 -0
  157. package/docs/commands/liberica/materials-update.md +250 -0
  158. package/docs/commands/liberica/uoms-create.md +136 -0
  159. package/docs/commands/liberica/uoms-delete.md +119 -0
  160. package/docs/commands/liberica/uoms-disable.md +117 -0
  161. package/docs/commands/liberica/uoms-enable.md +115 -0
  162. package/docs/commands/liberica/uoms-get.md +119 -0
  163. package/docs/commands/liberica/uoms-list.md +155 -0
  164. package/docs/commands/liberica/uoms-update.md +148 -0
  165. package/package.json +2 -4
  166. package/src/commands/liberica/auth/index.ts +6 -0
  167. package/src/commands/liberica/clients/create.ts +122 -0
  168. package/src/commands/liberica/clients/delete.ts +125 -0
  169. package/src/commands/liberica/clients/get.ts +88 -0
  170. package/src/commands/liberica/clients/index.ts +19 -0
  171. package/src/commands/liberica/clients/list.ts +123 -0
  172. package/src/commands/liberica/clients/update.ts +103 -0
  173. package/src/commands/liberica/index.ts +11 -0
  174. package/src/commands/liberica/materials/create.ts +168 -0
  175. package/src/commands/liberica/materials/delete.ts +105 -0
  176. package/src/commands/liberica/materials/disable.ts +148 -0
  177. package/src/commands/liberica/materials/enable.ts +129 -0
  178. package/src/commands/liberica/materials/get.ts +83 -0
  179. package/src/commands/liberica/materials/index.ts +23 -0
  180. package/src/commands/liberica/materials/list.ts +142 -0
  181. package/src/commands/liberica/materials/update.ts +125 -0
  182. package/src/commands/liberica/suppliers/create.ts +149 -0
  183. package/src/commands/liberica/suppliers/delete.ts +102 -0
  184. package/src/commands/liberica/suppliers/disable.ts +145 -0
  185. package/src/commands/liberica/suppliers/enable.ts +126 -0
  186. package/src/commands/liberica/suppliers/get.ts +86 -0
  187. package/src/commands/liberica/suppliers/index.ts +23 -0
  188. package/src/commands/liberica/suppliers/list.ts +134 -0
  189. package/src/commands/liberica/suppliers/update.ts +128 -0
  190. package/src/commands/liberica/uoms/create.ts +134 -0
  191. package/src/commands/liberica/uoms/delete.ts +105 -0
  192. package/src/commands/liberica/uoms/disable.ts +148 -0
  193. package/src/commands/liberica/uoms/enable.ts +129 -0
  194. package/src/commands/liberica/uoms/get.ts +83 -0
  195. package/src/commands/liberica/uoms/index.ts +23 -0
  196. package/src/commands/liberica/uoms/list.ts +129 -0
  197. package/src/commands/liberica/uoms/update.ts +124 -0
  198. package/src/core/api/client.ts +758 -21
  199. package/src/index.ts +1 -1
  200. package/src/types/client.ts +115 -0
  201. package/src/types/index.ts +6 -0
  202. package/src/types/material.ts +61 -0
  203. package/src/types/supplier.ts +66 -0
  204. package/src/types/uom.ts +60 -0
  205. package/bin/barista.js +0 -3
@@ -0,0 +1,115 @@
1
+ # barista liberica uoms enable
2
+
3
+ 启用计量单位(批量)。
4
+
5
+ ## 2.1 命令元数据
6
+
7
+ | 字段 | 值 |
8
+ |------|-----|
9
+ | 完整命令 | `barista liberica uoms enable <uom-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/sales/
22
+ └── MasterUomController.java
23
+ └── enableUom(@PostResource(path = "/batchActive"))
24
+ └── public ResponseData<Void> enableUom(
25
+ @RequestBody Map<String, List<String>> request
26
+ )
27
+ ```
28
+
29
+ ### Request DTO位置
30
+ ```
31
+ - 批量启用请求:{ uomIdList: List<String> }
32
+ ```
33
+
34
+ ### Response DTO位置
35
+ ```
36
+ - 返回 void 或成功标记(ResponseData<Void>)
37
+ ```
38
+
39
+ ## 2.3 CLI参数设计
40
+
41
+ ### 命令结构
42
+ ```
43
+ barista liberica uoms enable <uom-id...> [options]
44
+ ```
45
+
46
+ ### 全局选项
47
+ | 选项 | 类型 | 说明 |
48
+ |------|------|------|
49
+ | `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
50
+ | `--tenant` | string | 租户代码 |
51
+ | `--json` | boolean | JSON输出 |
52
+
53
+ ### 位置参数
54
+ | 参数 | 类型 | 必填 | 说明 |
55
+ |------|------|------|------|
56
+ | uom-id... | string | ✅ | 一个或多个计量单位ID |
57
+
58
+ ### 命令选项
59
+ | 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 | 对应DTO字段 |
60
+ |------|--------|------|------|--------|------|-------------|
61
+ | --uom-id | -i | string | ⬜ | - | 计量单位ID(逗号分隔,与位置参数互斥) | uomIdList |
62
+
63
+ ## 2.4 字段映射表
64
+
65
+ | CLI参数 | DTO字段 | 类型转换 | 验证规则 |
66
+ |---------|---------|----------|----------|
67
+ | uom-id... (位置参数) | uomIdList | string[]→List<String> | 至少一个ID |
68
+ | --uom-id / -i | uomIdList | string→List<String> | 逗号分隔 |
69
+
70
+ ## 2.5 错误码引用
71
+
72
+ ### ExceptionEnum位置
73
+ ```
74
+ coffee-liberica-end/
75
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/exception/enums/MasterUomExceptionEnum.java
76
+ ```
77
+
78
+ ### 已知错误码
79
+ | 错误码 | 错误消息 | 触发条件 |
80
+ |--------|----------|----------|
81
+ | UOM_NOT_EXIST | 计量单位不存在 | UOM不存在 |
82
+ | UOM_NO_PERMISSION | 无权限操作 | 无权限操作 |
83
+
84
+ ## 2.6 权限检查
85
+
86
+ | 检查项 | 位置 | 说明 |
87
+ |--------|------|------|
88
+ | 注解 | MasterUomController.java | 需要 `master_uom:edit` 权限 |
89
+
90
+ ## 2.7 实现要点
91
+
92
+ 1. **批量支持**:支持单个ID或多个ID(空格分隔)
93
+ 2. **ID来源**:可通过位置参数或 --uom-id 选项传递
94
+ 3. **逗号分隔**:--uom-id 选项支持逗号分隔的多个ID
95
+ 4. **状态变更**:将 statusFlag 从 2(禁用)改为 1(启用)
96
+ 5. **部分失败**:如果某些ID不存在,后端可能返回错误或仅处理存在的ID
97
+ 6. **API路径**:POST `/api/enterprise/sales/uom/batchActive`
98
+ 7. **请求格式**:{ uomIdList: ["id1", "id2", ...] }
99
+
100
+ ## 2.8 示例用法
101
+
102
+ ```bash
103
+ # 启用单个计量单位
104
+ barista liberica uoms enable "1234567890123456789"
105
+
106
+ # 启用多个计量单位
107
+ barista liberica uoms enable "1234567890123456789" "9876543210987654321"
108
+
109
+ # 通过选项参数启用(逗号分隔)
110
+ barista liberica uoms enable --uom-id "1234567890123456789,9876543210987654321"
111
+ barista liberica uoms enable -i "1234567890123456789,9876543210987654321"
112
+
113
+ # JSON 输出
114
+ barista liberica uoms enable "1234567890123456789" --json
115
+ ```
@@ -0,0 +1,119 @@
1
+ # barista liberica uoms get
2
+
3
+ 获取单个计量单位详情。
4
+
5
+ ## 2.1 命令元数据
6
+
7
+ | 字段 | 值 |
8
+ |------|-----|
9
+ | 完整命令 | `barista liberica uoms get <uom-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/sales/
22
+ └── MasterUomController.java
23
+ └── getUom(@GetResource(path = "/detail"))
24
+ └── public ResponseData<MasterUomResponse> getUom(
25
+ @RequestParam String uomId
26
+ )
27
+ ```
28
+
29
+ ### Request DTO位置
30
+ ```
31
+ [无Request DTO]
32
+ - uomId通过@RequestParam传递
33
+ ```
34
+
35
+ ### Response DTO位置
36
+ ```
37
+ coffee-liberica-end/
38
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/pojo/response/MasterUomResponse.java
39
+ ├── uomId: String
40
+ ├── uomCode: String
41
+ ├── uomName: String
42
+ ├── uomFractionPlaces: Integer
43
+ ├── statusFlag: Integer (1=启用,2=禁用)
44
+ ├── remark: String
45
+ ├── createTime: String
46
+ └── updateTime: String
47
+ ```
48
+
49
+ ## 2.3 CLI参数设计
50
+
51
+ ### 命令结构
52
+ ```
53
+ barista liberica uoms get <uom-id> [options]
54
+ ```
55
+
56
+ ### 全局选项
57
+ | 选项 | 类型 | 说明 |
58
+ |------|------|------|
59
+ | `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
60
+ | `--tenant` | string | 租户代码 |
61
+ | `--json` | boolean | JSON输出 |
62
+
63
+ ### 位置参数
64
+ | 参数 | 类型 | 必填 | 说明 |
65
+ |------|------|------|------|
66
+ | uom-id | string | ✅ | 计量单位ID |
67
+
68
+ ### 命令选项
69
+ | 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 | 对应DTO字段 |
70
+ |------|--------|------|------|--------|------|-------------|
71
+ | --uom-id | -i | string | ⬜ | - | 计量单位ID(与位置参数互斥) | uomId |
72
+
73
+ ## 2.4 字段映射表
74
+
75
+ | CLI参数 | DTO字段 | 类型转换 | 验证规则 |
76
+ |---------|---------|----------|----------|
77
+ | uom-id (位置参数) | uomId | string→String | @NotBlank |
78
+ | --uom-id / -i | uomId | string→String | @NotBlank |
79
+
80
+ ## 2.5 错误码引用
81
+
82
+ ### ExceptionEnum位置
83
+ ```
84
+ coffee-liberica-end/
85
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/exception/enums/MasterUomExceptionEnum.java
86
+ ```
87
+
88
+ ### 已知错误码
89
+ | 错误码 | 错误消息 | 触发条件 |
90
+ |--------|----------|----------|
91
+ | UOM_NOT_EXIST | 计量单位不存在 | ID不存在 |
92
+
93
+ ## 2.6 权限检查
94
+
95
+ | 检查项 | 位置 | 说明 |
96
+ |--------|------|------|
97
+ | 注解 | 无需权限 | 登录用户可访问 |
98
+
99
+ ## 2.7 实现要点
100
+
101
+ 1. **参数解析**:支持位置参数 `<uom-id>` 和选项参数 `--uom-id`
102
+ 2. **ID必填**:uomId为必填参数
103
+ 3. **输出格式**:格式化展示UOM详情,包括基本信息和状态
104
+ 4. **错误处理**:UOM不存在时显示友好错误提示
105
+ 5. **API路径**:GET `/api/enterprise/sales/uom/detail`
106
+
107
+ ## 2.8 示例用法
108
+
109
+ ```bash
110
+ # 通过位置参数获取
111
+ barista liberica uoms get "1234567890123456789"
112
+
113
+ # 通过选项参数获取
114
+ barista liberica uoms get --uom-id "1234567890123456789"
115
+ barista liberica uoms get -i "1234567890123456789"
116
+
117
+ # JSON 输出
118
+ barista liberica uoms get "1234567890123456789" --json
119
+ ```
@@ -0,0 +1,155 @@
1
+ # barista liberica uoms list
2
+
3
+ 分页查询计量单位列表。
4
+
5
+ ## 2.1 命令元数据
6
+
7
+ | 字段 | 值 |
8
+ |------|-----|
9
+ | 完整命令 | `barista liberica uoms 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/sales/
22
+ └── MasterUomController.java
23
+ └── listUoms(@GetResource(path = "/page"))
24
+ └── public ResponseData<PageResult<MasterUomResponse>> listUoms(
25
+ @ParameterObject MasterUomRequest request
26
+ )
27
+ ```
28
+
29
+ ### Request DTO位置
30
+ ```
31
+ coffee-liberica-end/
32
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/pojo/request/MasterUomRequest.java
33
+ ├── pageNo: Long (分页页码,从0开始)
34
+ ├── pageSize: Long (分页大小)
35
+ ├── uomCode: String (计量单位编码)
36
+ ├── uomName: String (计量单位名称)
37
+ └── statusFlag: Integer (状态:1=启用,2=禁用)
38
+ ```
39
+
40
+ ### Response DTO位置
41
+ ```
42
+ coffee-liberica-end/
43
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/pojo/response/MasterUomResponse.java
44
+ ├── uomId: String
45
+ ├── uomCode: String
46
+ ├── uomName: String
47
+ ├── uomFractionPlaces: Integer
48
+ ├── statusFlag: Integer (1=启用,2=禁用)
49
+ ├── remark: String
50
+ ├── createTime: String
51
+ └── updateTime: String
52
+ ```
53
+
54
+ ### 分页包装器
55
+ ```
56
+ cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult
57
+ ├── totalRows: long
58
+ ├── pageSize: long
59
+ ├── pageNo: long
60
+ └── rows: List<MasterUomResponse>
61
+ ```
62
+
63
+ ## 2.3 CLI参数设计
64
+
65
+ ### 命令结构
66
+ ```
67
+ barista liberica uoms list [options]
68
+ ```
69
+
70
+ ### 全局选项
71
+ | 选项 | 类型 | 说明 |
72
+ |------|------|------|
73
+ | `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
74
+ | `--tenant` | string | 租户代码 |
75
+ | `--json` | boolean | JSON输出 |
76
+
77
+ ### 命令选项
78
+ | 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 | 对应DTO字段 |
79
+ |------|--------|------|------|--------|------|-------------|
80
+ | --page | -p | number | ⬜ | 1 | 页码(从1开始) | pageNo (转换:CLI页码-1) |
81
+ | --size | -s | number | ⬜ | 20 | 每页条数 | pageSize |
82
+ | --status | — | string | ⬜ | - | 状态:enable/disable | statusFlag (enable=1, disable=2) |
83
+ | --code | -c | string | ⬜ | - | 计量单位编码 | uomCode |
84
+ | --name | -n | string | ⬜ | - | 计量单位名称 | uomName |
85
+ | --keyword | -k | string | ⬜ | - | 搜索关键词(编码/名称) | uomCode/uomName |
86
+
87
+ ## 2.4 字段映射表
88
+
89
+ | CLI参数 | DTO字段 | 类型转换 | 验证规则 |
90
+ |---------|---------|----------|----------|
91
+ | --page / -p | pageNo | number→Long,CLI页码-1 | >= 1 |
92
+ | --size / -s | pageSize | number→Long | 1-100 |
93
+ | --status | statusFlag | string→Integer | enable=1, disable=2 |
94
+ | --code / -c | uomCode | string→String | - |
95
+ | --name / -n | uomName | string→String | - |
96
+ | --keyword / -k | uomCode/uomName | string→String | 模糊查询 |
97
+
98
+ ## 2.5 错误码引用
99
+
100
+ ### ExceptionEnum位置
101
+ ```
102
+ coffee-liberica-end/
103
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/exception/enums/MasterUomExceptionEnum.java
104
+ ```
105
+
106
+ ### 已知错误码
107
+ | 错误码 | 错误消息 | 触发条件 |
108
+ |--------|----------|----------|
109
+ | UOM_NOT_EXIST | 计量单位不存在 | 查询/编辑/删除时ID不存在 |
110
+ | UOM_CODE_DUPLICATE | 计量单位编码重复 | 创建/编辑时编码已存在 |
111
+
112
+ ## 2.6 权限检查
113
+
114
+ | 检查项 | 位置 | 说明 |
115
+ |--------|------|------|
116
+ | 注解 | 无需权限 | 登录用户可访问 |
117
+
118
+ ## 2.7 实现要点
119
+
120
+ 1. **分页默认值**:page=1, size=20
121
+ 2. **分页转换**:CLI使用1-based页码,API使用0-based页码(调用时需减1)
122
+ 3. **搜索行为**:keyword 同时匹配 uomCode 和 uomName(模糊查询)
123
+ 4. **状态映射**:CLI参数 `enable`/`disable` 映射到 API 值 `1`/`2`
124
+ 5. **无结果处理**:返回空列表,不抛出异常
125
+ 6. **tenantId来源**:来自 JWT token(无需 X-TENANT-ID header)
126
+ 7. **输出格式**:表格形式展示,分页信息在底部显示
127
+ 8. **API路径**:GET `/api/enterprise/sales/uom/page`
128
+
129
+ ## 2.8 示例用法
130
+
131
+ ```bash
132
+ # 默认分页
133
+ barista liberica uoms list
134
+
135
+ # 指定页码和每页条数
136
+ barista liberica uoms list --page 2 --size 50
137
+
138
+ # 按状态筛选
139
+ barista liberica uoms list --status enable
140
+
141
+ # 按编码筛选
142
+ barista liberica uoms list --code "kg"
143
+
144
+ # 按名称搜索
145
+ barista liberica uoms list --name "千克"
146
+
147
+ # 关键词搜索
148
+ barista liberica uoms list --keyword "克"
149
+
150
+ # 组合筛选
151
+ barista liberica uoms list --page 1 --size 10 --status enable --keyword "kg"
152
+
153
+ # JSON 输出(便于脚本处理)
154
+ barista liberica uoms list --page 1 --size 20 --json
155
+ ```
@@ -0,0 +1,148 @@
1
+ # barista liberica uoms update
2
+
3
+ 更新计量单位信息。
4
+
5
+ ## 2.1 命令元数据
6
+
7
+ | 字段 | 值 |
8
+ |------|-----|
9
+ | 完整命令 | `barista liberica uoms update <uom-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/sales/
22
+ └── MasterUomController.java
23
+ └── updateUom(@PostResource(path = "/edit"))
24
+ └── public ResponseData<MasterUomResponse> updateUom(
25
+ @RequestBody @Validated MasterUomRequest request
26
+ )
27
+ ```
28
+
29
+ ### Request DTO位置
30
+ ```
31
+ coffee-liberica-end/
32
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/pojo/request/MasterUomRequest.java
33
+ ├── uomId: String (@NotBlank)
34
+ ├── uomCode: String (@NotBlank)
35
+ ├── uomName: String (@NotBlank)
36
+ ├── uomFractionPlaces: Integer (default: 2)
37
+ ├── statusFlag: Integer (1=启用, 2=禁用)
38
+ └── remark: String (optional)
39
+ ```
40
+
41
+ ### Response DTO位置
42
+ ```
43
+ coffee-liberica-end/
44
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/pojo/response/MasterUomResponse.java
45
+ ├── uomId: String
46
+ ├── uomCode: String
47
+ ├── uomName: String
48
+ ├── uomFractionPlaces: Integer
49
+ ├── statusFlag: Integer
50
+ ├── remark: String
51
+ ├── createTime: String
52
+ └── updateTime: String
53
+ ```
54
+
55
+ ## 2.3 CLI参数设计
56
+
57
+ ### 命令结构
58
+ ```
59
+ barista liberica uoms update <uom-id> [options]
60
+ ```
61
+
62
+ ### 全局选项
63
+ | 选项 | 类型 | 说明 |
64
+ |------|------|------|
65
+ | `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
66
+ | `--tenant` | string | 租户代码 |
67
+ | `--dry-run` | boolean | 预览模式 |
68
+ | `--json` | boolean | JSON输出 |
69
+
70
+ ### 位置参数
71
+ | 参数 | 类型 | 必填 | 说明 |
72
+ |------|------|------|------|
73
+ | uom-id | string | ✅ | 计量单位ID |
74
+
75
+ ### 命令选项
76
+ | 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 | 对应DTO字段 |
77
+ |------|--------|------|------|--------|------|-------------|
78
+ | --uom-id | -i | string | ⬜ | - | 计量单位ID(与位置参数互斥) | uomId |
79
+ | --code | -c | string | ✅ | - | 计量单位编码 | uomCode |
80
+ | --name | -n | string | ✅ | - | 计量单位名称 | uomName |
81
+ | --fraction-places | -f | number | ⬜ | 2 | 小数位数 | uomFractionPlaces |
82
+ | --remark | -r | string | ⬜ | - | 备注 | remark |
83
+
84
+ ## 2.4 字段映射表
85
+
86
+ | CLI参数 | DTO字段 | 类型转换 | 验证规则 |
87
+ |---------|---------|----------|----------|
88
+ | uom-id (位置参数) | uomId | string→String | @NotBlank |
89
+ | --uom-id / -i | uomId | string→String | @NotBlank |
90
+ | --code / -c | uomCode | string→String | @NotBlank, max=255 |
91
+ | --name / -n | uomName | string→String | @NotBlank, max=255 |
92
+ | --fraction-places / -f | uomFractionPlaces | number→Integer | >= 0, <= 10 |
93
+ | --remark / -r | remark | string→String | max=500 |
94
+
95
+ ## 2.5 错误码引用
96
+
97
+ ### ExceptionEnum位置
98
+ ```
99
+ coffee-liberica-end/
100
+ └── business/liberica-business-uom/uom-api/src/main/java/com/newpeak/liberica/uom/api/exception/enums/MasterUomExceptionEnum.java
101
+ ```
102
+
103
+ ### 已知错误码
104
+ | 错误码 | 错误消息 | 触发条件 |
105
+ |--------|----------|----------|
106
+ | UOM_NOT_EXIST | 计量单位不存在 | UOM不存在 |
107
+ | UOM_CODE_DUPLICATE | 计量单位编码重复 | 编码重复 |
108
+ | UOM_CODE_EMPTY | 计量单位编码不能为空 | 编码为空 |
109
+ | UOM_NAME_EMPTY | 计量单位名称不能为空 | 名称为空 |
110
+
111
+ ## 2.6 权限检查
112
+
113
+ | 检查项 | 位置 | 说明 |
114
+ |--------|------|------|
115
+ | 注解 | MasterUomController.java | 需要 `master_uom:edit` 权限 |
116
+
117
+ ## 2.7 实现要点
118
+
119
+ 1. **ID必填**:uomId为必填参数(位置参数或 --uom-id 选项)
120
+ 2. **必填字段**:uomCode 和 uomName 为必填参数(通常需要先获取现有值再修改)
121
+ 3. **dry-run 支持**:支持 `--dry-run` 预览模式,显示将要更新的字段变化
122
+ 4. **完整更新**:后端可能是完整更新模式,需要提供所有字段值
123
+ 5. **建议用法**:先执行 `barista liberica uoms get <id>` 获取当前值,再更新指定字段
124
+ 6. **API路径**:POST `/api/enterprise/sales/uom/edit`
125
+ 7. **成功响应**:返回更新后的UOM详情
126
+
127
+ ## 2.8 示例用法
128
+
129
+ ```bash
130
+ # 更新计量单位(通过位置参数)
131
+ barista liberica uoms update "1234567890123456789" --code "kg" --name "千克"
132
+
133
+ # 更新计量单位(通过选项参数)
134
+ barista liberica uoms update --uom-id "1234567890123456789" --code "kg" --name "千克"
135
+ barista liberica uoms update -i "1234567890123456789" -c "kg" -n "千克"
136
+
137
+ # 更新小数位数
138
+ barista liberica uoms update "1234567890123456789" --code "m" --name "米" --fraction-places 3
139
+
140
+ # 更新备注
141
+ barista liberica uoms update "1234567890123456789" --code "pcs" --name "件" --remark "新的备注"
142
+
143
+ # 预览模式(dry-run)
144
+ barista liberica uoms update "1234567890123456789" --code "box" --name "箱" --dry-run
145
+
146
+ # JSON 输出
147
+ barista liberica uoms update "1234567890123456789" --code "kg" --name "千克" --json
148
+ ```
package/package.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "@newpeak/barista-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "AI Tools CLI for Liberica and Arabica services",
5
5
  "type": "module",
6
- "bin": {
7
- "barista": "./bin/barista.js"
8
- },
6
+ "bin": "./bin/barista",
9
7
  "scripts": {
10
8
  "build": "tsc",
11
9
  "dev": "tsc --watch",
@@ -90,6 +90,12 @@ export function createLibericaAuthCommand(): Command {
90
90
 
91
91
  await configManager.setTenant(resolvedTenant);
92
92
 
93
+ const indexInfo = await apiClient.getUserIndexInfo(environment, resolvedTenant);
94
+ if (!indexInfo.success) {
95
+ console.error(chalk.yellow(`\n⚠ Warning: Failed to refresh permissions cache: ${indexInfo.error?.message || 'Unknown error'}`));
96
+ console.error(chalk.gray(' You may need to relogin to refresh permissions.\n'));
97
+ }
98
+
93
99
  console.log(chalk.green('\n✓ Login successful'));
94
100
  if (response.data.expiresAt) {
95
101
  console.log(chalk.gray(` Token expires: ${response.data.expiresAt}`));
@@ -0,0 +1,122 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { configManager } from '../../../core/config/manager.js';
4
+ import { apiClient } from '../../../core/api/client.js';
5
+ import { CreateClientRequest, StatusFlag } from '../../../types/client.js';
6
+
7
+ export function createClientCreateCommand(): Command {
8
+ const cmd = new Command('create');
9
+ cmd.description('Create a new client (auto-generates client code if not provided)');
10
+
11
+ cmd
12
+ .option('--client-code <code>', 'Client code (auto-generated if not provided)')
13
+ .option('--client-name <name>', 'Client name')
14
+ .option('--follower <name>', 'Follower/salesperson')
15
+ .option('--office-address <address>', 'Office address')
16
+ .option('--office-telephone <phone>', 'Office telephone')
17
+ .option('--status <status>', 'Status (1=enable, 2=disable)')
18
+ .option('--remark <remark>', 'Remark')
19
+ .option('--dry-run', 'Preview the operation without executing')
20
+ .option('--json', 'Output as JSON')
21
+ .action(async (options: Record<string, unknown>) => {
22
+ const context = configManager.getCurrentContext();
23
+ const environment = context.environment;
24
+ const tenant = context.tenant;
25
+ const jsonOutput = options.json === true;
26
+
27
+ let clientCode = options.clientCode as string | undefined;
28
+ const clientName = options.clientName as string | undefined;
29
+ const follower = options.follower as string | undefined;
30
+ const officeAddress = options.officeAddress as string | undefined;
31
+ const officeTelephone = options.officeTelephone as string | undefined;
32
+ const status = options.status as string | undefined;
33
+ const remark = options.remark as string | undefined;
34
+
35
+ if (!clientCode) {
36
+ const codeResponse = await apiClient.getCodeByType(environment, tenant, 'TenantClientCode');
37
+ if (codeResponse.success && codeResponse.data) {
38
+ clientCode = codeResponse.data;
39
+ } else {
40
+ const errMsg = codeResponse.error?.message || 'Failed to generate client code';
41
+ if (jsonOutput) {
42
+ console.log(JSON.stringify({ success: false, error: { code: 'CODE_GENERATION_ERROR', message: errMsg } }));
43
+ } else {
44
+ console.error(chalk.red(`\n✗ Failed to generate client code: ${errMsg}\n`));
45
+ }
46
+ process.exit(1);
47
+ }
48
+ }
49
+
50
+ const data: CreateClientRequest = {
51
+ clientCode,
52
+ clientName,
53
+ follower,
54
+ officeAddress,
55
+ officeTelephone,
56
+ statusFlag: status ? parseInt(status) as StatusFlag : undefined,
57
+ remark,
58
+ };
59
+
60
+ Object.keys(data).forEach(key => {
61
+ if (data[key as keyof CreateClientRequest] === undefined) {
62
+ delete data[key as keyof CreateClientRequest];
63
+ }
64
+ });
65
+
66
+ if (options.dryRun) {
67
+ if (jsonOutput) {
68
+ console.log(JSON.stringify({ success: true, dryRun: true, data }));
69
+ } else {
70
+ console.log(chalk.cyan('\n🔍 Dry-Run Mode: No actual API call will be made\n'));
71
+ console.log(chalk.gray(' This operation will create the following client:'));
72
+ console.log(` ${chalk.gray('Client Code:')} ${clientCode}`);
73
+ if (clientName) console.log(` ${chalk.gray('Client Name:')} ${clientName}`);
74
+ if (follower) console.log(` ${chalk.gray('Follower:')} ${follower}`);
75
+ if (officeAddress) console.log(` ${chalk.gray('Office:')} ${officeAddress}`);
76
+ console.log();
77
+ }
78
+ return;
79
+ }
80
+
81
+ try {
82
+ const response = await apiClient.createClient(environment, tenant, data);
83
+
84
+ if (response.success) {
85
+ if (jsonOutput) {
86
+ console.log(JSON.stringify({ success: true, data: response.data }));
87
+ } else {
88
+ console.log(chalk.green('\n✓ Client created successfully\n'));
89
+ if (response.data && typeof response.data === 'object' && 'clientId' in response.data) {
90
+ console.log(` ${chalk.gray('Client ID:')} ${chalk.green(String((response.data as { clientId: string }).clientId))}`);
91
+ }
92
+ if (clientCode) console.log(` ${chalk.gray('Client Code:')} ${chalk.green(clientCode)}`);
93
+ if (clientName) console.log(` ${chalk.gray('Client Name:')} ${clientName}`);
94
+ console.log();
95
+ }
96
+ } else {
97
+ const errorMsg = response.error?.message || 'Failed to create client';
98
+ const errorCode = response.error?.code || 'CREATE_CLIENT_ERROR';
99
+ if (jsonOutput) {
100
+ console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
101
+ } else {
102
+ console.error(chalk.red(`\n✗ Failed to create client: ${errorMsg}`));
103
+ if (response.error?.code) {
104
+ console.error(chalk.gray(` Error code: ${response.error.code}`));
105
+ }
106
+ console.error();
107
+ }
108
+ process.exit(1);
109
+ }
110
+ } catch (error) {
111
+ const errMsg = error instanceof Error ? error.message : 'Unknown error';
112
+ if (jsonOutput) {
113
+ console.log(JSON.stringify({ success: false, error: { code: 'ERROR', message: errMsg } }));
114
+ } else {
115
+ console.error(chalk.red(`\n✗ Error: ${errMsg}\n`));
116
+ }
117
+ process.exit(1);
118
+ }
119
+ });
120
+
121
+ return cmd;
122
+ }