@newpeak/barista-cli 0.1.7 → 0.1.8
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/dist/commands/liberica/calendar/index.d.ts +3 -0
- package/dist/commands/liberica/calendar/index.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/index.js +11 -0
- package/dist/commands/liberica/calendar/index.js.map +1 -0
- package/dist/commands/liberica/calendar/list.d.ts +3 -0
- package/dist/commands/liberica/calendar/list.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/list.js +181 -0
- package/dist/commands/liberica/calendar/list.js.map +1 -0
- package/dist/commands/liberica/calendar/set.d.ts +3 -0
- package/dist/commands/liberica/calendar/set.d.ts.map +1 -0
- package/dist/commands/liberica/calendar/set.js +120 -0
- package/dist/commands/liberica/calendar/set.js.map +1 -0
- package/dist/commands/liberica/client-contacts/create.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/create.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/create.js +132 -0
- package/dist/commands/liberica/client-contacts/create.js.map +1 -0
- package/dist/commands/liberica/client-contacts/delete.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/delete.js +139 -0
- package/dist/commands/liberica/client-contacts/delete.js.map +1 -0
- package/dist/commands/liberica/client-contacts/get.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/get.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/get.js +92 -0
- package/dist/commands/liberica/client-contacts/get.js.map +1 -0
- package/dist/commands/liberica/client-contacts/index.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/index.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/index.js +17 -0
- package/dist/commands/liberica/client-contacts/index.js.map +1 -0
- package/dist/commands/liberica/client-contacts/list.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/list.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/list.js +92 -0
- package/dist/commands/liberica/client-contacts/list.js.map +1 -0
- package/dist/commands/liberica/client-contacts/update.d.ts +3 -0
- package/dist/commands/liberica/client-contacts/update.d.ts.map +1 -0
- package/dist/commands/liberica/client-contacts/update.js +156 -0
- package/dist/commands/liberica/client-contacts/update.js.map +1 -0
- package/dist/commands/liberica/dict-types/get.d.ts +3 -0
- package/dist/commands/liberica/dict-types/get.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/get.js +62 -0
- package/dist/commands/liberica/dict-types/get.js.map +1 -0
- package/dist/commands/liberica/dict-types/index.d.ts +3 -0
- package/dist/commands/liberica/dict-types/index.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/index.js +13 -0
- package/dist/commands/liberica/dict-types/index.js.map +1 -0
- package/dist/commands/liberica/dict-types/list.d.ts +3 -0
- package/dist/commands/liberica/dict-types/list.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/list.js +91 -0
- package/dist/commands/liberica/dict-types/list.js.map +1 -0
- package/dist/commands/liberica/dict-types/update.d.ts +3 -0
- package/dist/commands/liberica/dict-types/update.d.ts.map +1 -0
- package/dist/commands/liberica/dict-types/update.js +127 -0
- package/dist/commands/liberica/dict-types/update.js.map +1 -0
- package/dist/commands/liberica/dicts/create.d.ts +3 -0
- package/dist/commands/liberica/dicts/create.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/create.js +157 -0
- package/dist/commands/liberica/dicts/create.js.map +1 -0
- package/dist/commands/liberica/dicts/delete.d.ts +3 -0
- package/dist/commands/liberica/dicts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/delete.js +106 -0
- package/dist/commands/liberica/dicts/delete.js.map +1 -0
- package/dist/commands/liberica/dicts/get.d.ts +3 -0
- package/dist/commands/liberica/dicts/get.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/get.js +69 -0
- package/dist/commands/liberica/dicts/get.js.map +1 -0
- package/dist/commands/liberica/dicts/index.d.ts +3 -0
- package/dist/commands/liberica/dicts/index.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/index.js +17 -0
- package/dist/commands/liberica/dicts/index.js.map +1 -0
- package/dist/commands/liberica/dicts/list.d.ts +3 -0
- package/dist/commands/liberica/dicts/list.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/list.js +88 -0
- package/dist/commands/liberica/dicts/list.js.map +1 -0
- package/dist/commands/liberica/dicts/update.d.ts +3 -0
- package/dist/commands/liberica/dicts/update.d.ts.map +1 -0
- package/dist/commands/liberica/dicts/update.js +112 -0
- package/dist/commands/liberica/dicts/update.js.map +1 -0
- package/dist/commands/liberica/index.d.ts.map +1 -1
- package/dist/commands/liberica/index.js +18 -0
- package/dist/commands/liberica/index.js.map +1 -1
- package/dist/commands/liberica/operations/active.d.ts +3 -0
- package/dist/commands/liberica/operations/active.d.ts.map +1 -0
- package/dist/commands/liberica/operations/active.js +152 -0
- package/dist/commands/liberica/operations/active.js.map +1 -0
- package/dist/commands/liberica/operations/batch-delete.d.ts +3 -0
- package/dist/commands/liberica/operations/batch-delete.d.ts.map +1 -0
- package/dist/commands/liberica/operations/batch-delete.js +130 -0
- package/dist/commands/liberica/operations/batch-delete.js.map +1 -0
- package/dist/commands/liberica/operations/copy.d.ts +3 -0
- package/dist/commands/liberica/operations/copy.d.ts.map +1 -0
- package/dist/commands/liberica/operations/copy.js +137 -0
- package/dist/commands/liberica/operations/copy.js.map +1 -0
- package/dist/commands/liberica/operations/create.d.ts +3 -0
- package/dist/commands/liberica/operations/create.d.ts.map +1 -0
- package/dist/commands/liberica/operations/create.js +212 -0
- package/dist/commands/liberica/operations/create.js.map +1 -0
- package/dist/commands/liberica/operations/deactive.d.ts +3 -0
- package/dist/commands/liberica/operations/deactive.d.ts.map +1 -0
- package/dist/commands/liberica/operations/deactive.js +152 -0
- package/dist/commands/liberica/operations/deactive.js.map +1 -0
- package/dist/commands/liberica/operations/delete.d.ts +3 -0
- package/dist/commands/liberica/operations/delete.d.ts.map +1 -0
- package/dist/commands/liberica/operations/delete.js +128 -0
- package/dist/commands/liberica/operations/delete.js.map +1 -0
- package/dist/commands/liberica/operations/get.d.ts +3 -0
- package/dist/commands/liberica/operations/get.d.ts.map +1 -0
- package/dist/commands/liberica/operations/get.js +93 -0
- package/dist/commands/liberica/operations/get.js.map +1 -0
- package/dist/commands/liberica/operations/index.d.ts +3 -0
- package/dist/commands/liberica/operations/index.d.ts.map +1 -0
- package/dist/commands/liberica/operations/index.js +25 -0
- package/dist/commands/liberica/operations/index.js.map +1 -0
- package/dist/commands/liberica/operations/list.d.ts +3 -0
- package/dist/commands/liberica/operations/list.d.ts.map +1 -0
- package/dist/commands/liberica/operations/list.js +141 -0
- package/dist/commands/liberica/operations/list.js.map +1 -0
- package/dist/commands/liberica/operations/update.d.ts +3 -0
- package/dist/commands/liberica/operations/update.d.ts.map +1 -0
- package/dist/commands/liberica/operations/update.js +208 -0
- package/dist/commands/liberica/operations/update.js.map +1 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.d.ts +2 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.d.ts.map +1 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.js +41 -0
- package/dist/commands/liberica/stock/__tests__/ledger.test.js.map +1 -0
- package/dist/commands/liberica/stock/__tests__/list.test.d.ts +2 -0
- package/dist/commands/liberica/stock/__tests__/list.test.d.ts.map +1 -0
- package/dist/commands/liberica/stock/__tests__/list.test.js +39 -0
- package/dist/commands/liberica/stock/__tests__/list.test.js.map +1 -0
- package/dist/commands/liberica/stock/index.d.ts +3 -0
- package/dist/commands/liberica/stock/index.d.ts.map +1 -0
- package/dist/commands/liberica/stock/index.js +11 -0
- package/dist/commands/liberica/stock/index.js.map +1 -0
- package/dist/commands/liberica/stock/ledger.d.ts +3 -0
- package/dist/commands/liberica/stock/ledger.d.ts.map +1 -0
- package/dist/commands/liberica/stock/ledger.js +154 -0
- package/dist/commands/liberica/stock/ledger.js.map +1 -0
- package/dist/commands/liberica/stock/list.d.ts +3 -0
- package/dist/commands/liberica/stock/list.d.ts.map +1 -0
- package/dist/commands/liberica/stock/list.js +127 -0
- package/dist/commands/liberica/stock/list.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/create.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/create.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/create.js +129 -0
- package/dist/commands/liberica/supplier-contacts/create.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/delete.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/delete.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/delete.js +88 -0
- package/dist/commands/liberica/supplier-contacts/delete.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/get.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/get.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/get.js +84 -0
- package/dist/commands/liberica/supplier-contacts/get.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/index.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/index.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/index.js +17 -0
- package/dist/commands/liberica/supplier-contacts/index.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/list.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/list.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/list.js +98 -0
- package/dist/commands/liberica/supplier-contacts/list.js.map +1 -0
- package/dist/commands/liberica/supplier-contacts/update.d.ts +3 -0
- package/dist/commands/liberica/supplier-contacts/update.d.ts.map +1 -0
- package/dist/commands/liberica/supplier-contacts/update.js +136 -0
- package/dist/commands/liberica/supplier-contacts/update.js.map +1 -0
- package/dist/core/api/client.d.ts +46 -0
- package/dist/core/api/client.d.ts.map +1 -1
- package/dist/core/api/client.js +865 -52
- package/dist/core/api/client.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/calendar.d.ts +28 -0
- package/dist/types/calendar.d.ts.map +1 -0
- package/dist/types/calendar.js +2 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/client-contact.d.ts +65 -0
- package/dist/types/client-contact.d.ts.map +1 -0
- package/dist/types/client-contact.js +4 -0
- package/dist/types/client-contact.js.map +1 -0
- package/dist/types/dict.d.ts +97 -0
- package/dist/types/dict.d.ts.map +1 -0
- package/dist/types/dict.js +2 -0
- package/dist/types/dict.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/operation.d.ts +66 -0
- package/dist/types/operation.d.ts.map +1 -0
- package/dist/types/operation.js +2 -0
- package/dist/types/operation.js.map +1 -0
- package/dist/types/stock.d.ts +133 -0
- package/dist/types/stock.d.ts.map +1 -0
- package/dist/types/stock.js +3 -0
- package/dist/types/stock.js.map +1 -0
- package/dist/types/supplier-contact.d.ts +65 -0
- package/dist/types/supplier-contact.d.ts.map +1 -0
- package/dist/types/supplier-contact.js +4 -0
- package/dist/types/supplier-contact.js.map +1 -0
- package/docs/commands/REFERENCE.md +24 -4
- package/docs/commands/liberica/calendar/DESIGN.md +333 -0
- package/docs/commands/liberica/client-contacts/create.md +152 -0
- package/docs/commands/liberica/client-contacts/delete.md +123 -0
- package/docs/commands/liberica/client-contacts/get.md +133 -0
- package/docs/commands/liberica/client-contacts/list.md +143 -0
- package/docs/commands/liberica/client-contacts/update.md +158 -0
- package/docs/commands/liberica/stock/ledger.md +209 -0
- package/docs/commands/liberica/stock/list.md +165 -0
- package/docs/commands/liberica/supplier-contacts/create.md +152 -0
- package/docs/commands/liberica/supplier-contacts/delete.md +123 -0
- package/docs/commands/liberica/supplier-contacts/get.md +133 -0
- package/docs/commands/liberica/supplier-contacts/list.md +143 -0
- package/docs/commands/liberica/supplier-contacts/update.md +158 -0
- package/package.json +1 -1
- package/src/commands/liberica/calendar/index.ts +13 -0
- package/src/commands/liberica/calendar/list.ts +214 -0
- package/src/commands/liberica/calendar/set.ts +130 -0
- package/src/commands/liberica/client-contacts/create.ts +115 -0
- package/src/commands/liberica/client-contacts/delete.ts +140 -0
- package/src/commands/liberica/client-contacts/get.ts +103 -0
- package/src/commands/liberica/client-contacts/index.ts +19 -0
- package/src/commands/liberica/client-contacts/list.ts +118 -0
- package/src/commands/liberica/client-contacts/update.ts +137 -0
- package/src/commands/liberica/dict-types/get.ts +74 -0
- package/src/commands/liberica/dict-types/index.ts +15 -0
- package/src/commands/liberica/dict-types/list.ts +118 -0
- package/src/commands/liberica/dict-types/update.ts +134 -0
- package/src/commands/liberica/dicts/create.ts +175 -0
- package/src/commands/liberica/dicts/delete.ts +107 -0
- package/src/commands/liberica/dicts/get.ts +80 -0
- package/src/commands/liberica/dicts/index.ts +19 -0
- package/src/commands/liberica/dicts/list.ts +114 -0
- package/src/commands/liberica/dicts/update.ts +116 -0
- package/src/commands/liberica/index.ts +18 -0
- package/src/commands/liberica/operations/active.ts +153 -0
- package/src/commands/liberica/operations/batch-delete.ts +131 -0
- package/src/commands/liberica/operations/copy.ts +138 -0
- package/src/commands/liberica/operations/create.ts +223 -0
- package/src/commands/liberica/operations/deactive.ts +152 -0
- package/src/commands/liberica/operations/delete.ts +128 -0
- package/src/commands/liberica/operations/design.md +587 -0
- package/src/commands/liberica/operations/get.ts +112 -0
- package/src/commands/liberica/operations/index.ts +27 -0
- package/src/commands/liberica/operations/list.ts +180 -0
- package/src/commands/liberica/operations/update.ts +218 -0
- package/src/commands/liberica/stock/index.ts +13 -0
- package/src/commands/liberica/stock/ledger.ts +159 -0
- package/src/commands/liberica/stock/list.ts +128 -0
- package/src/commands/liberica/supplier-contacts/create.ts +120 -0
- package/src/commands/liberica/supplier-contacts/delete.ts +88 -0
- package/src/commands/liberica/supplier-contacts/get.ts +94 -0
- package/src/commands/liberica/supplier-contacts/index.ts +19 -0
- package/src/commands/liberica/supplier-contacts/list.ts +130 -0
- package/src/commands/liberica/supplier-contacts/update.ts +127 -0
- package/src/core/api/client.ts +1093 -74
- package/src/index.ts +1 -1
- package/src/types/calendar.ts +36 -0
- package/src/types/client-contact.ts +78 -0
- package/src/types/dict.ts +121 -0
- package/src/types/index.ts +5 -0
- package/src/types/operation.ts +72 -0
- package/src/types/stock.ts +161 -0
- package/src/types/supplier-contact.ts +78 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# barista liberica supplier-contacts list
|
|
2
|
+
|
|
3
|
+
查询供应商联系人列表。
|
|
4
|
+
|
|
5
|
+
## 2.1 命令元数据
|
|
6
|
+
|
|
7
|
+
| 字段 | 值 |
|
|
8
|
+
|------|-----|
|
|
9
|
+
| 完整命令 | `barista liberica supplier-contacts 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/purchases/
|
|
22
|
+
└── EnterpriseSupplierContactController.java
|
|
23
|
+
└── list(@GetResource(path = "/list"))
|
|
24
|
+
└── public ResponseData<List<MasterSupplierContactResponse>> list(
|
|
25
|
+
@RequestHeader("X-TENANT-ID") Long tenantId,
|
|
26
|
+
MasterSupplierContactRequest masterSupplierContactRequest
|
|
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
|
+
└── MasterSupplierContactRequest.java
|
|
36
|
+
├── supplierId: Long (@NotNull)
|
|
37
|
+
├── supplierContactName: String (搜索关键词)
|
|
38
|
+
├── pageNo: Long (分页页码)
|
|
39
|
+
└── pageSize: Long (分页大小)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Response DTO位置
|
|
43
|
+
```
|
|
44
|
+
coffee-liberica-end/
|
|
45
|
+
└── business/liberica-business-master/master-api/
|
|
46
|
+
└── src/main/java/com/newpeak/liberica/master/api/pojo/response/
|
|
47
|
+
└── MasterSupplierContactResponse.java
|
|
48
|
+
├── supplierContactId: Long
|
|
49
|
+
├── supplierId: Long
|
|
50
|
+
├── supplierContactName: String
|
|
51
|
+
├── supplierContactPhone: String
|
|
52
|
+
├── supplierContactTelephone: String
|
|
53
|
+
├── supplierContactEmail: String
|
|
54
|
+
├── supplierContactSex: String
|
|
55
|
+
├── supplierContactBirthday: Date
|
|
56
|
+
├── supplierContactQq: String
|
|
57
|
+
├── supplierContactWechat: String
|
|
58
|
+
├── supplierContactAddress: String
|
|
59
|
+
├── defaultFlag: String (Y/N)
|
|
60
|
+
├── remark: String
|
|
61
|
+
├── createTime: String
|
|
62
|
+
└── updateTime: String
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 2.3 CLI参数设计
|
|
66
|
+
|
|
67
|
+
### 命令结构
|
|
68
|
+
```
|
|
69
|
+
barista liberica supplier-contacts list [options]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 全局选项
|
|
73
|
+
| 选项 | 类型 | 说明 |
|
|
74
|
+
|------|------|------|
|
|
75
|
+
| `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
|
|
76
|
+
| `--tenant` | string | 租户代码 |
|
|
77
|
+
| `--json` | boolean | JSON输出 |
|
|
78
|
+
|
|
79
|
+
### 命令选项
|
|
80
|
+
| 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 | 对应DTO字段 |
|
|
81
|
+
|------|--------|------|------|--------|------|-------------|
|
|
82
|
+
| --supplier-id | -s | string | ✅ | - | 供应商ID | supplierId |
|
|
83
|
+
| --page | -p | number | ⬜ | 1 | 页码 | pageNo |
|
|
84
|
+
| --size | -z | number | ⬜ | 20 | 每页条数 | pageSize |
|
|
85
|
+
| --search | -S | string | ⬜ | - | 搜索关键词(姓名) | supplierContactName |
|
|
86
|
+
|
|
87
|
+
## 2.4 字段映射表
|
|
88
|
+
|
|
89
|
+
| CLI参数 | DTO字段 | 类型转换 | 验证规则 |
|
|
90
|
+
|---------|---------|----------|----------|
|
|
91
|
+
| --supplier-id / -s | supplierId | string→Long | @NotNull |
|
|
92
|
+
| --page / -p | pageNo | number→Long | >= 1 |
|
|
93
|
+
| --size / -z | pageSize | number→Long | 1-100 |
|
|
94
|
+
| --search / -S | supplierContactName | 直接传递 | 模糊查询 |
|
|
95
|
+
|
|
96
|
+
## 2.5 错误码引用
|
|
97
|
+
|
|
98
|
+
### ExceptionEnum位置
|
|
99
|
+
```
|
|
100
|
+
coffee-liberica-end/
|
|
101
|
+
└── business/liberica-business-master/master-api/
|
|
102
|
+
└── src/main/java/com/newpeak/liberica/master/api/exception/enums/
|
|
103
|
+
└── MasterSupplierContactExceptionEnum.java
|
|
104
|
+
└── MASTER_SUPPLIER_CONTACT_NOT_EXIST("01001XXX001", "租户供应商联系人不存在")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 已知错误码
|
|
108
|
+
| 错误码 | 错误消息 | 触发条件 |
|
|
109
|
+
|--------|----------|----------|
|
|
110
|
+
| 01001XXX001 | 租户供应商联系人不存在 | 供应商ID不存在时 |
|
|
111
|
+
|
|
112
|
+
## 2.6 权限检查
|
|
113
|
+
|
|
114
|
+
| 检查项 | 位置 | 说明 |
|
|
115
|
+
|--------|------|------|
|
|
116
|
+
| 注解 | `@GetResource(path = "/list")` | 无 requiredPermission(无需权限码) |
|
|
117
|
+
|
|
118
|
+
**注意**:list 接口在 Controller 层无需权限校验,数据范围通过 tenantId 隔离。
|
|
119
|
+
|
|
120
|
+
## 2.7 实现要点
|
|
121
|
+
|
|
122
|
+
1. **必填参数**:--supplier-id 必须指定
|
|
123
|
+
2. **分页默认值**:page=1, size=20
|
|
124
|
+
3. **搜索行为**:supplierContactName 支持模糊查询
|
|
125
|
+
4. **无结果处理**:返回空列表,不抛出异常
|
|
126
|
+
5. **tenantId来源**:来自 X-TENANT-ID header
|
|
127
|
+
6. **输出格式**:表格形式展示联系人列表
|
|
128
|
+
|
|
129
|
+
## 2.8 示例用法
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# 列出供应商的所有联系人
|
|
133
|
+
barista liberica supplier-contacts list --supplier-id 12345
|
|
134
|
+
|
|
135
|
+
# 指定页码和每页条数
|
|
136
|
+
barista liberica supplier-contacts list --supplier-id 12345 --page 2 --size 50
|
|
137
|
+
|
|
138
|
+
# 搜索联系人
|
|
139
|
+
barista liberica supplier-contacts list --supplier-id 12345 --search "张"
|
|
140
|
+
|
|
141
|
+
# JSON 输出(便于脚本处理)
|
|
142
|
+
barista liberica supplier-contacts list --supplier-id 12345 --json
|
|
143
|
+
```
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# barista liberica supplier-contacts update
|
|
2
|
+
|
|
3
|
+
更新供应商联系人信息。
|
|
4
|
+
|
|
5
|
+
## 2.1 命令元数据
|
|
6
|
+
|
|
7
|
+
| 字段 | 值 |
|
|
8
|
+
|------|-----|
|
|
9
|
+
| 完整命令 | `barista liberica supplier-contacts update <contact-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/purchases/
|
|
22
|
+
└── EnterpriseSupplierContactController.java
|
|
23
|
+
└── edit(@PostResource(path = "/edit", requiredPermission = true, requirePermissionCode = "EDIT_MASTER_SUPPLIER_CONTACT"))
|
|
24
|
+
└── public ResponseData<?> edit(
|
|
25
|
+
@RequestHeader("X-TENANT-ID") Long tenantId,
|
|
26
|
+
@RequestBody @Validated(BaseRequest.edit.class) MasterSupplierContactRequest masterSupplierContactRequest
|
|
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
|
+
└── MasterSupplierContactRequest.java
|
|
36
|
+
├── supplierContactId: Long (@NotNull on edit)
|
|
37
|
+
├── supplierContactName: String (@NotBlank, max=255)
|
|
38
|
+
├── supplierContactPhone: String (max=256)
|
|
39
|
+
├── supplierContactTelephone: String (max=256)
|
|
40
|
+
├── supplierContactEmail: String (max=512)
|
|
41
|
+
├── supplierContactSex: String (max=255)
|
|
42
|
+
├── supplierContactBirthday: Date
|
|
43
|
+
├── supplierContactQq: String (max=512)
|
|
44
|
+
├── supplierContactWechat: String (max=512)
|
|
45
|
+
├── supplierContactAddress: String (max=512)
|
|
46
|
+
├── defaultFlag: String (max=1)
|
|
47
|
+
└── remark: String (max=255)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Response DTO位置
|
|
51
|
+
```
|
|
52
|
+
coffee-liberica-end/
|
|
53
|
+
└── business/liberica-business-master/master-api/
|
|
54
|
+
└── src/main/java/com/newpeak/liberica/master/api/pojo/response/
|
|
55
|
+
└── MasterSupplierContactResponse.java
|
|
56
|
+
└── (同 get 接口)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 2.3 CLI参数设计
|
|
60
|
+
|
|
61
|
+
### 命令结构
|
|
62
|
+
```
|
|
63
|
+
barista liberica supplier-contacts update <contact-id> [options]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 位置参数
|
|
67
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
68
|
+
|------|------|------|------|
|
|
69
|
+
| contact-id | string | ✅ | 供应商联系人ID |
|
|
70
|
+
|
|
71
|
+
### 全局选项
|
|
72
|
+
| 选项 | 类型 | 说明 |
|
|
73
|
+
|------|------|------|
|
|
74
|
+
| `--env` | string | 目标环境(dev\|test\|prod-cn\|prod-jp) |
|
|
75
|
+
| `--tenant` | string | 租户代码 |
|
|
76
|
+
| `--dry-run` | boolean | 预览模式 |
|
|
77
|
+
| `--json` | boolean | JSON输出 |
|
|
78
|
+
|
|
79
|
+
### 命令选项
|
|
80
|
+
| 选项 | 短选项 | 类型 | 必填 | 默认值 | 说明 | 对应DTO字段 |
|
|
81
|
+
|------|--------|------|------|--------|------|-------------|
|
|
82
|
+
| --name | -n | string | ⬜ | - | 姓名 | supplierContactName |
|
|
83
|
+
| --phone | -p | string | ⬜ | - | 手机号 | supplierContactPhone |
|
|
84
|
+
| --telephone | -t | string | ⬜ | - | 座机号 | supplierContactTelephone |
|
|
85
|
+
| --email | -e | string | ⬜ | - | 电子邮箱 | supplierContactEmail |
|
|
86
|
+
| --sex | -x | string | ⬜ | - | 性别 | supplierContactSex |
|
|
87
|
+
| --birthday | -b | string | ⬜ | - | 生日(YYYY-MM-DD) | supplierContactBirthday |
|
|
88
|
+
| --qq | -q | string | ⬜ | - | QQ号 | supplierContactQq |
|
|
89
|
+
| --wechat | -w | string | ⬜ | - | 微信号 | supplierContactWechat |
|
|
90
|
+
| --address | -a | string | ⬜ | - | 详细地址 | supplierContactAddress |
|
|
91
|
+
| --default | -d | boolean | ⬜ | - | 是否默认联系人 | defaultFlag |
|
|
92
|
+
| --remark | -r | string | ⬜ | - | 备注 | remark |
|
|
93
|
+
|
|
94
|
+
**注意**:所有字段在 update 时都是可选的,至少需要提供一个要更新的字段。
|
|
95
|
+
|
|
96
|
+
## 2.4 字段映射表
|
|
97
|
+
|
|
98
|
+
| CLI参数 | DTO字段 | 类型转换 | 验证规则 |
|
|
99
|
+
|---------|---------|----------|----------|
|
|
100
|
+
| <contact-id> | supplierContactId | string→Long | @NotNull |
|
|
101
|
+
| --name / -n | supplierContactName | 直接传递 | max=255 |
|
|
102
|
+
| --phone / -p | supplierContactPhone | 直接传递 | max=256 |
|
|
103
|
+
| --telephone / -t | supplierContactTelephone | 直接传递 | max=256 |
|
|
104
|
+
| --email / -e | supplierContactEmail | 直接传递 | max=512 |
|
|
105
|
+
| --sex / -x | supplierContactSex | 直接传递 | max=255 |
|
|
106
|
+
| --birthday / -b | supplierContactBirthday | string→Date | yyyy-MM-dd |
|
|
107
|
+
| --qq / -q | supplierContactQq | 直接传递 | max=512 |
|
|
108
|
+
| --wechat / -w | supplierContactWechat | 直接传递 | max=512 |
|
|
109
|
+
| --address / -a | supplierContactAddress | 直接传递 | max=512 |
|
|
110
|
+
| --default / -d | defaultFlag | boolean→Y/N | max=1 |
|
|
111
|
+
| --remark / -r | remark | 直接传递 | max=255 |
|
|
112
|
+
|
|
113
|
+
## 2.5 错误码引用
|
|
114
|
+
|
|
115
|
+
### ExceptionEnum位置
|
|
116
|
+
```
|
|
117
|
+
coffee-liberica-end/
|
|
118
|
+
└── business/liberica-business-master/master-api/
|
|
119
|
+
└── src/main/java/com/newpeak/liberica/master/api/exception/enums/
|
|
120
|
+
└── MasterSupplierContactExceptionEnum.java
|
|
121
|
+
└── MASTER_SUPPLIER_CONTACT_NOT_EXIST("01001XXX001", "租户供应商联系人不存在")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 已知错误码
|
|
125
|
+
| 错误码 | 错误消息 | 触发条件 |
|
|
126
|
+
|--------|----------|----------|
|
|
127
|
+
| 01001XXX001 | 租户供应商联系人不存在 | contact-id 不存在或不属于当前租户 |
|
|
128
|
+
|
|
129
|
+
## 2.6 权限检查
|
|
130
|
+
|
|
131
|
+
| 检查项 | 位置 | 说明 |
|
|
132
|
+
|--------|------|------|
|
|
133
|
+
| PermissionConstants | `EDIT_MASTER_SUPPLIER_CONTACT` | 编辑供应商联系人需要此权限 |
|
|
134
|
+
| 注解 | `@PostResource(requirePermissionCode = "EDIT_MASTER_SUPPLIER_CONTACT")` | Controller方法上 |
|
|
135
|
+
|
|
136
|
+
## 2.7 实现要点
|
|
137
|
+
|
|
138
|
+
1. **位置参数**:contact-id 必须指定
|
|
139
|
+
2. **可选字段**:所有业务字段都是可选的,至少提供一个
|
|
140
|
+
3. **dry-run 模式**:预览模式下只显示将要更新的数据,不实际调用 API
|
|
141
|
+
4. **输出格式**:成功后显示更新后的联系人信息
|
|
142
|
+
5. **错误处理**:联系人不存在时显示友好错误信息
|
|
143
|
+
|
|
144
|
+
## 2.8 示例用法
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# 更新联系人姓名(dry-run 预览)
|
|
148
|
+
barista liberica supplier-contacts update 12345 --name "新姓名" --dry-run
|
|
149
|
+
|
|
150
|
+
# 实际更新
|
|
151
|
+
barista liberica supplier-contacts update 12345 --name "新姓名" --phone "13900139000"
|
|
152
|
+
|
|
153
|
+
# 更新多个字段
|
|
154
|
+
barista liberica supplier-contacts update 12345 --email "new@example.com" --address "新地址"
|
|
155
|
+
|
|
156
|
+
# JSON 输出
|
|
157
|
+
barista liberica supplier-contacts update 12345 --name "新姓名" --json
|
|
158
|
+
```
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createCalendarSetCommand } from './set.js';
|
|
3
|
+
import { createCalendarListCommand } from './list.js';
|
|
4
|
+
|
|
5
|
+
export function createCalendarCommand(): Command {
|
|
6
|
+
const calendarCommand = new Command('calendar');
|
|
7
|
+
calendarCommand.description('Manage calendar (workdays, holidays)');
|
|
8
|
+
|
|
9
|
+
calendarCommand.addCommand(createCalendarSetCommand());
|
|
10
|
+
calendarCommand.addCommand(createCalendarListCommand());
|
|
11
|
+
|
|
12
|
+
return calendarCommand;
|
|
13
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import Table from 'cli-table3';
|
|
4
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
6
|
+
import { CalendarQueryParams, CalendarItem } from '../../../types/calendar.js';
|
|
7
|
+
import { Environment } from '../../../types/index.js';
|
|
8
|
+
|
|
9
|
+
function getCurrentYear(): number {
|
|
10
|
+
return new Date().getFullYear();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getCurrentMonth(): number {
|
|
14
|
+
return new Date().getMonth() + 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function formatDate(dateStr: string): string {
|
|
18
|
+
return dateStr;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getDayOfWeek(dateStr: string): string {
|
|
22
|
+
const date = new Date(dateStr);
|
|
23
|
+
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
24
|
+
return days[date.getDay()];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function renderCalendarGrid(data: { [yearMonth: string]: CalendarItem[] }): void {
|
|
28
|
+
const yearMonths = Object.keys(data).sort();
|
|
29
|
+
|
|
30
|
+
for (const yearMonth of yearMonths) {
|
|
31
|
+
const items = data[yearMonth] || [];
|
|
32
|
+
const [year, month] = yearMonth.split('-').map(Number);
|
|
33
|
+
const monthName = new Date(year, month - 1).toLocaleString('default', { month: 'long' });
|
|
34
|
+
|
|
35
|
+
console.log(chalk.bold(`\n📅 ${year} ${monthName}\n`));
|
|
36
|
+
|
|
37
|
+
// Build calendar grid
|
|
38
|
+
const calendarGrid: string[][] = [];
|
|
39
|
+
const dayMap: { [day: string]: CalendarItem } = {};
|
|
40
|
+
|
|
41
|
+
for (const item of items) {
|
|
42
|
+
const day = item.calendarDate.split('-')[2];
|
|
43
|
+
dayMap[day] = item;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Header
|
|
47
|
+
calendarGrid.push(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map(d => chalk.gray(d)));
|
|
48
|
+
|
|
49
|
+
// Find first day of month
|
|
50
|
+
const firstDay = new Date(year, month - 1, 1).getDay();
|
|
51
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
52
|
+
|
|
53
|
+
let currentRow: string[] = [];
|
|
54
|
+
|
|
55
|
+
// Add empty cells for days before the first day
|
|
56
|
+
for (let i = 0; i < firstDay; i++) {
|
|
57
|
+
currentRow.push(' ');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Add days
|
|
61
|
+
for (let day = 1; day <= daysInMonth; day++) {
|
|
62
|
+
const dayStr = day.toString().padStart(2, '0');
|
|
63
|
+
const item = dayMap[dayStr];
|
|
64
|
+
|
|
65
|
+
if (item) {
|
|
66
|
+
if (item.dateType === 'WORKDAY') {
|
|
67
|
+
currentRow.push(chalk.green('·'));
|
|
68
|
+
} else if (item.dateType === 'HOLIDAY' || item.dateType === 'WEEKEND') {
|
|
69
|
+
currentRow.push(chalk.red('H'));
|
|
70
|
+
} else {
|
|
71
|
+
currentRow.push(' ');
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
currentRow.push(' ');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (currentRow.length === 7) {
|
|
78
|
+
calendarGrid.push(currentRow);
|
|
79
|
+
currentRow = [];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Add remaining empty cells
|
|
84
|
+
while (currentRow.length > 0 && currentRow.length < 7) {
|
|
85
|
+
currentRow.push(' ');
|
|
86
|
+
}
|
|
87
|
+
if (currentRow.length > 0) {
|
|
88
|
+
calendarGrid.push(currentRow);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Print grid
|
|
92
|
+
const gridTable = new Table({
|
|
93
|
+
style: { border: [], compact: true },
|
|
94
|
+
colWidths: Array(7).fill(4),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
for (const row of calendarGrid) {
|
|
98
|
+
gridTable.push(row);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log(gridTable.toString());
|
|
102
|
+
console.log();
|
|
103
|
+
console.log(chalk.gray(' · ') + chalk.green('Workday') + chalk.gray(' H ') + chalk.red('Holiday/Weekend'));
|
|
104
|
+
console.log();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function createCalendarListCommand(): Command {
|
|
109
|
+
const listCommand = new Command('list');
|
|
110
|
+
listCommand.description('List calendar entries (workdays, holidays)');
|
|
111
|
+
|
|
112
|
+
listCommand
|
|
113
|
+
.option('-y, --year <number>', 'Year (required for query)')
|
|
114
|
+
.option('-m, --month <number>', 'Month (required for query)')
|
|
115
|
+
.option('--months <number>', 'Number of months to query', '12')
|
|
116
|
+
.option('--grid', 'Calendar grid view mode')
|
|
117
|
+
.option('--json', 'Output as JSON')
|
|
118
|
+
.action(async (options) => {
|
|
119
|
+
const context = configManager.getCurrentContext();
|
|
120
|
+
const environment = (options.env as Environment) || context.environment;
|
|
121
|
+
const tenant = options.tenant || context.tenant;
|
|
122
|
+
|
|
123
|
+
// Default to current year/month if not provided
|
|
124
|
+
const year = options.year ? parseInt(options.year as string, 10) : getCurrentYear();
|
|
125
|
+
const month = options.month ? parseInt(options.month as string, 10) : getCurrentMonth();
|
|
126
|
+
const months = parseInt(options.months as string, 10);
|
|
127
|
+
|
|
128
|
+
const params: CalendarQueryParams = { year, month, months };
|
|
129
|
+
|
|
130
|
+
const response = await apiClient.listCalendar(environment, tenant, params);
|
|
131
|
+
|
|
132
|
+
if (!response.success) {
|
|
133
|
+
console.error(chalk.red(`\n✗ Failed to list calendar: ${response.error?.message || 'Unknown error'}`));
|
|
134
|
+
if (response.error?.code) {
|
|
135
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
136
|
+
}
|
|
137
|
+
console.error();
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const data = response.data;
|
|
142
|
+
|
|
143
|
+
if (!data) {
|
|
144
|
+
if (options.json) {
|
|
145
|
+
console.log(JSON.stringify({ success: true, data: {} }, null, 2));
|
|
146
|
+
} else {
|
|
147
|
+
console.log(chalk.bold('\n📅 Calendar\n'));
|
|
148
|
+
console.log(chalk.gray(' No calendar data found\n'));
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (options.json) {
|
|
154
|
+
console.log(JSON.stringify({ success: true, data }, null, 2));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (options.grid) {
|
|
159
|
+
renderCalendarGrid(data);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Table output mode
|
|
164
|
+
const allItems: CalendarItem[] = [];
|
|
165
|
+
for (const yearMonth of Object.keys(data)) {
|
|
166
|
+
const items = data[yearMonth] || [];
|
|
167
|
+
allItems.push(...items);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (allItems.length === 0) {
|
|
171
|
+
console.log(chalk.bold('\n📅 Calendar\n'));
|
|
172
|
+
console.log(chalk.gray(' No calendar data found\n'));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
console.log(chalk.bold('\n📅 Calendar\n'));
|
|
177
|
+
|
|
178
|
+
const table = new Table({
|
|
179
|
+
head: [chalk.bold('Date'), chalk.bold('Day'), chalk.bold('Type'), chalk.bold('Remark')],
|
|
180
|
+
colWidths: [12, 8, 12, 30],
|
|
181
|
+
style: {
|
|
182
|
+
head: [],
|
|
183
|
+
border: [],
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
for (const item of allItems) {
|
|
188
|
+
const dayType = item.dateType;
|
|
189
|
+
let typeText: string;
|
|
190
|
+
|
|
191
|
+
if (dayType === 'WORKDAY') {
|
|
192
|
+
typeText = chalk.green('WORKDAY');
|
|
193
|
+
} else if (dayType === 'HOLIDAY') {
|
|
194
|
+
typeText = chalk.red('HOLIDAY');
|
|
195
|
+
} else if (dayType === 'WEEKEND') {
|
|
196
|
+
typeText = chalk.red('WEEKEND');
|
|
197
|
+
} else {
|
|
198
|
+
typeText = dayType;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
table.push([
|
|
202
|
+
formatDate(item.calendarDate),
|
|
203
|
+
getDayOfWeek(item.calendarDate),
|
|
204
|
+
typeText,
|
|
205
|
+
item.remark || '-',
|
|
206
|
+
]);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
console.log(table.toString());
|
|
210
|
+
console.log();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
return listCommand;
|
|
214
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { apiClient } from '../../../core/api/client.js';
|
|
4
|
+
import { configManager } from '../../../core/config/manager.js';
|
|
5
|
+
import { CalendarSetRequest, DateType } from '../../../types/calendar.js';
|
|
6
|
+
|
|
7
|
+
const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
8
|
+
const DATE_TYPE_REGEX = /^(WORKDAY|WEEKEND|HOLIDAY)$/;
|
|
9
|
+
|
|
10
|
+
function validateFields(data: CalendarSetRequest): string | null {
|
|
11
|
+
if (!DATE_REGEX.test(data.calendarDate)) {
|
|
12
|
+
return 'Invalid date format. Date must be in YYYY-MM-DD format.';
|
|
13
|
+
}
|
|
14
|
+
if (!DATE_TYPE_REGEX.test(data.dateType)) {
|
|
15
|
+
return 'Invalid date type. Must be WORKDAY, WEEKEND, or HOLIDAY.';
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function formatTable(data: CalendarSetRequest): string {
|
|
21
|
+
const lines: string[] = [];
|
|
22
|
+
lines.push(` ${chalk.gray('Date:')} ${data.calendarDate}`);
|
|
23
|
+
lines.push(` ${chalk.gray('Type:')} ${data.dateType}`);
|
|
24
|
+
if (data.remark) lines.push(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
25
|
+
return lines.join('\n');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createCalendarSetCommand(): Command {
|
|
29
|
+
const cmd = new Command('set');
|
|
30
|
+
cmd.description('Set calendar date type');
|
|
31
|
+
|
|
32
|
+
cmd
|
|
33
|
+
.option('-d, --date <date>', 'Date to set (YYYY-MM-DD, required)')
|
|
34
|
+
.option('-t, --type <type>', 'Date type (WORKDAY|WEEKEND|HOLIDAY, required)')
|
|
35
|
+
.option('-r, --remark <text>', 'Remark/note')
|
|
36
|
+
.option('--dry-run', 'Preview without making API call')
|
|
37
|
+
.option('--json', 'Output as JSON');
|
|
38
|
+
|
|
39
|
+
cmd.action(async () => {
|
|
40
|
+
const context = configManager.getCurrentContext();
|
|
41
|
+
const opts = cmd.opts();
|
|
42
|
+
|
|
43
|
+
const date = opts.date as string | undefined;
|
|
44
|
+
const type = opts.type as string | undefined;
|
|
45
|
+
const remark = opts.remark as string | undefined;
|
|
46
|
+
const dryRun = opts.dryRun === true;
|
|
47
|
+
const jsonOutput = opts.json === true;
|
|
48
|
+
|
|
49
|
+
// Validate required options
|
|
50
|
+
if (!date) {
|
|
51
|
+
if (jsonOutput) {
|
|
52
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'Date is required. Use --date (or -d).' } }));
|
|
53
|
+
} else {
|
|
54
|
+
console.error(chalk.red('\n✗ Date is required. Use --date (or -d).\n'));
|
|
55
|
+
}
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!type) {
|
|
60
|
+
if (jsonOutput) {
|
|
61
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: 'Date type is required. Use --type (or -t).' } }));
|
|
62
|
+
} else {
|
|
63
|
+
console.error(chalk.red('\n✗ Date type is required. Use --type (or -t).\n'));
|
|
64
|
+
}
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const data: CalendarSetRequest = {
|
|
69
|
+
calendarDate: date,
|
|
70
|
+
dateType: type as DateType,
|
|
71
|
+
remark,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Validate fields
|
|
75
|
+
const validationError = validateFields(data);
|
|
76
|
+
if (validationError) {
|
|
77
|
+
if (jsonOutput) {
|
|
78
|
+
console.log(JSON.stringify({ success: false, error: { code: 'VALIDATION_ERROR', message: validationError } }));
|
|
79
|
+
} else {
|
|
80
|
+
console.error(chalk.red(`\n✗ ${validationError}\n`));
|
|
81
|
+
}
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (dryRun) {
|
|
86
|
+
if (jsonOutput) {
|
|
87
|
+
console.log(JSON.stringify({ success: true, dryRun: true, data }));
|
|
88
|
+
} else {
|
|
89
|
+
console.log(chalk.bold('\n🔍 Dry-Run Mode: No changes will be made\n'));
|
|
90
|
+
console.log(' Calendar to be updated:');
|
|
91
|
+
console.log(formatTable(data));
|
|
92
|
+
console.log();
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!jsonOutput) {
|
|
98
|
+
console.log(chalk.bold('\n📝 Updating Calendar\n'));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const response = await apiClient.setCalendar(context.environment, context.tenant, data);
|
|
102
|
+
|
|
103
|
+
if (!response.success) {
|
|
104
|
+
const errorMsg = response.error?.message || 'Failed to update calendar';
|
|
105
|
+
const errorCode = response.error?.code || 'SET_CALENDAR_ERROR';
|
|
106
|
+
if (jsonOutput) {
|
|
107
|
+
console.log(JSON.stringify({ success: false, error: { code: errorCode, message: errorMsg } }));
|
|
108
|
+
} else {
|
|
109
|
+
console.error(chalk.red(`\n✗ Failed to update calendar: ${errorMsg}`));
|
|
110
|
+
if (response.error?.code) {
|
|
111
|
+
console.error(chalk.gray(` Error code: ${response.error.code}`));
|
|
112
|
+
}
|
|
113
|
+
console.error();
|
|
114
|
+
}
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (jsonOutput) {
|
|
119
|
+
console.log(JSON.stringify({ success: true, data: { calendarDate: data.calendarDate, dateType: data.dateType, remark: data.remark } }));
|
|
120
|
+
} else {
|
|
121
|
+
console.log(chalk.green(`✓ Calendar updated: ${data.calendarDate} -> ${data.dateType}\n`));
|
|
122
|
+
if (data.remark) {
|
|
123
|
+
console.log(` ${chalk.gray('Remark:')} ${data.remark}`);
|
|
124
|
+
}
|
|
125
|
+
console.log();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return cmd;
|
|
130
|
+
}
|