@xbongbong/xbbcli 2.4.5 → 2.4.6
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/README.md +15 -4
- package/business-info-detail.js +126 -0
- package/business-info-search.js +95 -0
- package/buyer-inquiry-detail.js +16 -47
- package/buyer-inquiry-list.js +18 -56
- package/clue-add-couser.js +14 -39
- package/clue-add.js +15 -41
- package/clue-back.js +14 -39
- package/clue-del.js +14 -39
- package/clue-delete-couser.js +14 -39
- package/clue-delete-mainuser.js +14 -39
- package/clue-detail.js +15 -40
- package/clue-distribution.js +14 -43
- package/clue-edit.js +15 -41
- package/clue-handover.js +15 -45
- package/clue-list.js +18 -61
- package/clue-thorough-delete.js +14 -39
- package/communicate-add.js +15 -56
- package/communicate-del.js +17 -59
- package/communicate-detail.js +15 -56
- package/communicate-edit.js +15 -56
- package/communicate-list.js +17 -62
- package/communicate-plan-add.js +16 -42
- package/communicate-plan-cancel.js +14 -40
- package/communicate-plan-del.js +14 -40
- package/communicate-plan-detail.js +15 -41
- package/communicate-plan-list.js +18 -46
- package/communicate-plan-single-operate.js +14 -39
- package/contact-add-couser.js +14 -39
- package/contact-add-mainuser.js +14 -39
- package/contact-add.js +15 -51
- package/contact-del.js +15 -38
- package/contact-delete-couser.js +14 -39
- package/contact-delete-mainuser.js +14 -39
- package/contact-detail.js +15 -38
- package/contact-edit.js +14 -47
- package/contact-handover.js +14 -39
- package/contact-list.js +37 -61
- package/contract-add-couser.js +16 -58
- package/contract-add-mainuser.js +16 -58
- package/contract-add.js +15 -57
- package/contract-del.js +17 -58
- package/contract-delete-couser.js +16 -57
- package/contract-delete-mainuser.js +16 -58
- package/contract-detail.js +15 -57
- package/contract-edit.js +15 -57
- package/contract-handover.js +15 -56
- package/contract-list.js +18 -61
- package/contract-outstock-add.js +15 -46
- package/contract-outstock-del.js +15 -41
- package/contract-outstock-detail.js +15 -41
- package/contract-outstock-edit.js +15 -46
- package/contract-outstock-list.js +18 -46
- package/customer-add-couser.js +13 -54
- package/customer-add.js +15 -58
- package/customer-back.js +15 -57
- package/customer-del.js +17 -58
- package/customer-delete-couser.js +16 -57
- package/customer-delete-mainuser.js +16 -58
- package/customer-detail.js +13 -54
- package/customer-distribution.js +15 -57
- package/customer-edit.js +13 -53
- package/customer-handover.js +15 -56
- package/customer-invoice-address-add.js +15 -41
- package/customer-invoice-address-edit.js +15 -40
- package/customer-invoice-address.js +17 -42
- package/customer-invoice-info-add.js +15 -41
- package/customer-invoice-info-edit.js +15 -40
- package/customer-invoice-info.js +17 -42
- package/customer-list.js +18 -61
- package/department-add.js +14 -39
- package/department-del.js +14 -40
- package/department-edit.js +14 -39
- package/department-list.js +17 -59
- package/form-data-add-couser.js +14 -39
- package/form-data-add-mainuser.js +14 -39
- package/form-data-add.js +13 -54
- package/form-data-del.js +13 -53
- package/form-data-delete-couser.js +14 -40
- package/form-data-delete-mainuser.js +14 -39
- package/form-data-detail.js +13 -54
- package/form-data-edit.js +13 -54
- package/form-data-handover.js +14 -39
- package/form-data-list.js +37 -63
- package/form-get.js +13 -53
- package/form-list.js +19 -66
- package/hkh-call-add-task.js +14 -44
- package/hkh-word-list.js +16 -44
- package/invoice-add.js +15 -45
- package/invoice-cancel.js +14 -44
- package/invoice-del.js +15 -45
- package/invoice-detail.js +15 -45
- package/invoice-edit.js +15 -45
- package/invoice-get-amount-detail.js +14 -44
- package/invoice-list.js +18 -50
- package/invoice-red.js +15 -45
- package/label-add.js +14 -44
- package/label-all-list.js +16 -44
- package/label-batch-add.js +14 -44
- package/label-batch-remove.js +14 -44
- package/label-del-completely.js +14 -44
- package/label-del.js +15 -45
- package/label-edit.js +14 -44
- package/label-group-add.js +15 -45
- package/label-group-del.js +15 -45
- package/label-group-list.js +16 -44
- package/label-group-update.js +15 -45
- package/label-list.js +16 -44
- package/label-reduction.js +15 -45
- package/label-repeat.js +15 -45
- package/market-activity-add.js +14 -49
- package/market-activity-del.js +15 -46
- package/market-activity-detail.js +15 -45
- package/market-activity-edit.js +15 -46
- package/market-activity-handover.js +14 -40
- package/market-activity-list.js +18 -46
- package/opportunity-add-couser.js +16 -58
- package/opportunity-add-mainuser.js +16 -58
- package/opportunity-add.js +15 -56
- package/opportunity-del.js +17 -59
- package/opportunity-delete-couser.js +16 -58
- package/opportunity-delete-mainuser.js +16 -57
- package/opportunity-detail.js +15 -58
- package/opportunity-edit.js +15 -56
- package/opportunity-handover.js +15 -57
- package/opportunity-list.js +40 -65
- package/orginal-text-list.js +16 -61
- package/package.json +8 -1
- package/pay-plan-add-couser.js +14 -41
- package/pay-plan-add-mainuser.js +14 -41
- package/pay-plan-add.js +15 -46
- package/pay-plan-delete-couser.js +14 -40
- package/pay-plan-delete-mainuser.js +14 -40
- package/pay-plan-handover.js +14 -40
- package/pay-sheet-add-bad.js +15 -46
- package/pay-sheet-add-couser.js +14 -40
- package/pay-sheet-add-mainuser.js +14 -41
- package/pay-sheet-add-red.js +15 -46
- package/pay-sheet-add-write-off.js +15 -46
- package/pay-sheet-del.js +14 -48
- package/pay-sheet-delete-couser.js +14 -40
- package/pay-sheet-delete-mainuser.js +14 -41
- package/pay-sheet-detail.js +15 -46
- package/pay-sheet-edit-bad.js +14 -49
- package/pay-sheet-edit-red.js +14 -49
- package/pay-sheet-edit-write-off.js +15 -46
- package/pay-sheet-get-amount-detail.js +14 -44
- package/pay-sheet-list.js +18 -46
- package/payment-add-couser.js +16 -58
- package/payment-add-mainuser.js +16 -58
- package/payment-add.js +15 -56
- package/payment-del.js +17 -58
- package/payment-delete-couser.js +16 -57
- package/payment-delete-mainuser.js +16 -57
- package/payment-detail.js +15 -56
- package/payment-edit.js +15 -56
- package/payment-handover.js +15 -57
- package/payment-list.js +37 -61
- package/payment-sheet-add-bad-debt.js +15 -57
- package/payment-sheet-add-pre.js +15 -46
- package/payment-sheet-add-red.js +15 -57
- package/payment-sheet-add-write-off.js +15 -52
- package/payment-sheet-del.js +17 -53
- package/payment-sheet-detail.js +15 -52
- package/payment-sheet-edit-bad-debt.js +15 -51
- package/payment-sheet-edit-red.js +15 -56
- package/payment-sheet-edit-write-off.js +15 -56
- package/payment-sheet-get-amount-detail.js +14 -45
- package/payment-sheet-handover.js +14 -40
- package/payment-sheet-list.js +37 -60
- package/product-add.js +15 -51
- package/product-category-add.js +13 -48
- package/product-category-del.js +13 -53
- package/product-category-list.js +17 -60
- package/product-category-update.js +13 -54
- package/product-del.js +17 -53
- package/product-detail.js +13 -54
- package/product-edit.js +15 -51
- package/product-list.js +37 -63
- package/product-online.js +14 -44
- package/quotation-add-couser.js +15 -45
- package/quotation-add-mainuser.js +15 -45
- package/quotation-add.js +15 -45
- package/quotation-del.js +15 -45
- package/quotation-delete-couser.js +15 -45
- package/quotation-delete-mainuser.js +15 -45
- package/quotation-detail.js +15 -45
- package/quotation-edit.js +15 -45
- package/quotation-handover.js +14 -39
- package/quotation-list.js +18 -50
- package/refund-add.js +15 -39
- package/refund-del.js +15 -38
- package/refund-detail.js +15 -39
- package/refund-edit.js +15 -39
- package/refund-list.js +37 -61
- package/role-list.js +18 -46
- package/sign-in-list.js +21 -49
- package/stage-get.js +16 -42
- package/stage-jump.js +15 -49
- package/supplier-add.js +15 -57
- package/token-del.js +1 -1
- package/token-list.js +20 -1
- package/token-set.js +1 -1
- package/token-use.js +2 -35
- package/user-add.js +14 -39
- package/user-del.js +14 -40
- package/user-edit.js +14 -40
- package/user-handover.js +14 -40
- package/user-list.js +16 -62
- package/work-order-add.js +13 -54
- package/work-order-asset-add-couser.js +15 -45
- package/work-order-asset-add-mainuser.js +15 -45
- package/work-order-asset-add.js +15 -45
- package/work-order-asset-del-couser.js +15 -45
- package/work-order-asset-del-mainuser.js +15 -45
- package/work-order-asset-del.js +15 -45
- package/work-order-asset-detail.js +15 -45
- package/work-order-asset-edit.js +15 -45
- package/work-order-asset-handover.js +15 -45
- package/work-order-asset-list.js +18 -50
- package/work-order-del.js +13 -54
- package/work-order-detail.js +13 -53
- package/work-order-dynamic-list.js +18 -56
- package/work-order-edit.js +13 -54
- package/work-order-list.js +17 -59
- package/work-order-operate.js +13 -54
- package/work-order-template-detail.js +13 -54
- package/work-order-template-list.js +17 -60
- package/work-report-daily-add.js +14 -39
- package/work-report-daily-del.js +14 -39
- package/work-report-daily-detail.js +15 -40
- package/work-report-daily-edit.js +17 -52
- package/work-report-daily-get-work-plan.js +14 -40
- package/work-report-daily-list.js +18 -45
- package/work-report-monthly-add.js +14 -40
- package/work-report-monthly-del.js +14 -43
- package/work-report-monthly-detail.js +15 -40
- package/work-report-monthly-edit.js +15 -40
- package/work-report-monthly-list.js +18 -45
- package/work-report-weekly-add.js +14 -40
- package/work-report-weekly-del.js +14 -40
- package/work-report-weekly-detail.js +15 -41
- package/work-report-weekly-edit.js +15 -41
- package/work-report-weekly-list.js +18 -45
- package/work-task-add-couser.js +14 -43
- package/work-task-add.js +15 -41
- package/work-task-delete-couser.js +14 -40
- package/work-task-detail.js +15 -40
- package/work-task-edit.js +14 -39
- package/work-task-handover.js +14 -40
- package/workorder-add-couser.js +16 -57
- package/workorder-delete-couser.js +16 -58
- package/workorder-handover.js +17 -58
- package/workorderlist.js +38 -60
- package/workorderproductlist.js +18 -59
- package/worktimerecorddetail.js +13 -54
- package/worktimerecordlist.js +18 -59
- package/xbb-http.js +71 -0
package/quotation-list.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway, createPagination } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/quotation/list';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
4
|
+
const API_PATH = '/pro/v2/api/quotation/list';
|
|
11
5
|
const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, apiUrl) {
|
|
28
|
-
const apiPath = new URL(apiUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
31
|
-
let lastPagination = null;
|
|
6
|
+
const pagination = createPagination();
|
|
32
7
|
|
|
33
8
|
function buildConditions(kwargs) {
|
|
34
9
|
if (String(kwargs.conditions ?? '').trim()) {
|
|
@@ -69,7 +44,7 @@ cli({
|
|
|
69
44
|
{ name: 'debug', type: 'bool', default: false, help: '输出请求体和返回体调试信息' },
|
|
70
45
|
],
|
|
71
46
|
columns: ['rank', 'dataId', 'formId', 'addTime', 'updateTime', 'data', 'code', 'msg'],
|
|
72
|
-
footerExtra:
|
|
47
|
+
footerExtra: pagination.footerExtra,
|
|
73
48
|
func: async function (kwargs) {
|
|
74
49
|
const debug = Boolean(kwargs.debug);
|
|
75
50
|
let conditions;
|
|
@@ -90,30 +65,23 @@ cli({
|
|
|
90
65
|
if (runtimeUserId) payload.userId = runtimeUserId;
|
|
91
66
|
if (conditions.length) payload.conditions = conditions;
|
|
92
67
|
if (String(kwargs.viewApproval ?? '') !== '') payload.viewApproval = Number(kwargs.viewApproval);
|
|
93
|
-
const requestBody = JSON.stringify(payload);
|
|
94
68
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 opencli xbb token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
95
69
|
if (!token) return makeErrorRow('NO_TOKEN', MISSING_TOKEN_MESSAGE);
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
70
|
+
const gateway = await requestGateway({
|
|
71
|
+
baseUrl,
|
|
72
|
+
apiPath: API_PATH,
|
|
73
|
+
payload,
|
|
74
|
+
token,
|
|
75
|
+
userId: runtimeUserId,
|
|
76
|
+
debug,
|
|
77
|
+
});
|
|
78
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
79
|
+
pagination.update(gateway.data);
|
|
80
|
+
if (kwargs.raw) return [{ raw: gateway.responseBody }];
|
|
81
|
+
if (gateway.data.code !== 1) {
|
|
82
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
107
83
|
}
|
|
108
|
-
const
|
|
109
|
-
lastPagination = data?.code === 1 && data?.result?.totalCount != null && data?.result?.totalPage != null
|
|
110
|
-
? { totalCount: data.result.totalCount, totalPage: data.result.totalPage }
|
|
111
|
-
: null;
|
|
112
|
-
const responseBody = JSON.stringify(data);
|
|
113
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
114
|
-
if (kwargs.raw) return [{ raw: responseBody }];
|
|
115
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
116
|
-
const list = Array.isArray(data.result?.list) ? data.result.list : [];
|
|
84
|
+
const list = Array.isArray(gateway.data.result?.list) ? gateway.data.result.list : [];
|
|
117
85
|
if (!list.length) return makeErrorRow('NO_DATA', '接口成功,但 list 为空');
|
|
118
86
|
return list.map((item, index) => ({ rank: index + 1, dataId: item.dataId || '', formId: item.formId || '', addTime: item.addTime || '', updateTime: item.updateTime || '', data: JSON.stringify(item.data || {}), code: '', msg: '' }));
|
|
119
87
|
},
|
package/refund-add.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/refund/add';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
function getRuntimeConfig() {
|
|
17
|
-
const config = readConfig();
|
|
18
|
-
return { corpid: String(config.corpid || '').trim(), token: String(config.token || '').trim(), baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(), userId: String(config.userId || '').trim() };
|
|
19
|
-
}
|
|
20
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
21
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
22
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
23
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/refund/add';
|
|
24
5
|
function parseDataList(raw) {
|
|
25
6
|
if (raw && typeof raw === 'object' && !Array.isArray(raw)) return raw;
|
|
26
7
|
const text = String(raw || '').trim();
|
|
@@ -57,30 +38,25 @@ cli({
|
|
|
57
38
|
if (runtimeUserId) payload.userId = runtimeUserId;
|
|
58
39
|
const parsedDataList = parseDataList(kwargs.dataList);
|
|
59
40
|
if (parsedDataList) payload.dataList = parsedDataList;
|
|
60
|
-
const body = JSON.stringify(payload);
|
|
61
41
|
|
|
62
42
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
63
43
|
if (!token) return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
64
44
|
if (parsedDataList === null) return makeErrorRow('NO_DATALIST', '缺少 --dataList');
|
|
65
45
|
if (parsedDataList === undefined) return makeErrorRow('INVALID_DATALIST', '--dataList 必须是 JSON 对象字符串');
|
|
66
46
|
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return makeErrorRow(
|
|
47
|
+
const gateway = await requestGateway({
|
|
48
|
+
baseUrl,
|
|
49
|
+
apiPath: API_PATH,
|
|
50
|
+
payload,
|
|
51
|
+
token,
|
|
52
|
+
userId: runtimeUserId,
|
|
53
|
+
debug,
|
|
54
|
+
});
|
|
55
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
56
|
+
if (gateway.data.code !== 1) {
|
|
57
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
78
58
|
}
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
82
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
83
|
-
const result = data.result || {};
|
|
84
|
-
return [{ dataId: result.dataId || '', resultCode: result.code ?? '', resultMsg: result.msg || '', code: data.code ?? '', msg: data.msg || '' }];
|
|
59
|
+
const result = gateway.data.result || {};
|
|
60
|
+
return [{ dataId: result.dataId || '', resultCode: result.code ?? '', resultMsg: result.msg || '', code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
85
61
|
},
|
|
86
62
|
});
|
package/refund-del.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/refund/del';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
function getRuntimeConfig() {
|
|
17
|
-
const config = readConfig();
|
|
18
|
-
return { corpid: String(config.corpid || '').trim(), token: String(config.token || '').trim(), baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(), userId: String(config.userId || '').trim() };
|
|
19
|
-
}
|
|
20
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
21
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
22
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
23
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/refund/del';
|
|
24
5
|
function makeErrorRow(code, msg) {
|
|
25
6
|
return [{ resultCode: '', resultMsg: '', errorDataMemo: '', code, msg }];
|
|
26
7
|
}
|
|
@@ -44,28 +25,24 @@ cli({
|
|
|
44
25
|
const { corpid, token, baseUrl, userId } = getRuntimeConfig();
|
|
45
26
|
const payload = { corpid, dataId: Number(kwargs.dataId || 0) };
|
|
46
27
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
47
|
-
const body = JSON.stringify(payload);
|
|
48
28
|
|
|
49
29
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
50
30
|
if (!payload.dataId) return makeErrorRow('NO_DATAID', '缺少 --dataId');
|
|
51
31
|
if (!token) return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
52
32
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
33
|
+
const gateway = await requestGateway({
|
|
34
|
+
baseUrl,
|
|
35
|
+
apiPath: API_PATH,
|
|
36
|
+
payload,
|
|
37
|
+
token,
|
|
38
|
+
userId,
|
|
39
|
+
debug,
|
|
40
|
+
});
|
|
41
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
42
|
+
if (gateway.data.code !== 1) {
|
|
43
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
63
44
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
67
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
68
|
-
const result = data.result || {};
|
|
69
|
-
return [{ resultCode: data.code ?? '', resultMsg: data.msg || '', errorDataMemo: result.errorDataMemo || '', code: data.code ?? '', msg: data.msg || '' }];
|
|
45
|
+
const result = gateway.data.result || {};
|
|
46
|
+
return [{ resultCode: gateway.data.code ?? '', resultMsg: gateway.data.msg || '', errorDataMemo: result.errorDataMemo || '', code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
70
47
|
},
|
|
71
48
|
});
|
package/refund-detail.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/refund/detail';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
function getRuntimeConfig() {
|
|
17
|
-
const config = readConfig();
|
|
18
|
-
return { corpid: String(config.corpid || '').trim(), token: String(config.token || '').trim(), baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(), userId: String(config.userId || '').trim() };
|
|
19
|
-
}
|
|
20
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
21
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
22
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
23
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/refund/detail';
|
|
24
5
|
function makeErrorRow(code, msg) {
|
|
25
6
|
return [{ dataId: '', formId: '', addTime: '', updateTime: '', data: '', code, msg }];
|
|
26
7
|
}
|
|
@@ -46,29 +27,24 @@ cli({
|
|
|
46
27
|
const payload = { corpid, dataId: Number(kwargs.dataId || 0) };
|
|
47
28
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
48
29
|
if (String(kwargs.queryFlag ?? '') !== '') payload.queryFlag = Number(kwargs.queryFlag);
|
|
49
|
-
const body = JSON.stringify(payload);
|
|
50
30
|
|
|
51
31
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
52
32
|
if (!payload.dataId) return makeErrorRow('NO_DATAID', '缺少 --dataId');
|
|
53
33
|
if (!token) return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
54
34
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return makeErrorRow(
|
|
35
|
+
const gateway = await requestGateway({
|
|
36
|
+
baseUrl,
|
|
37
|
+
apiPath: API_PATH,
|
|
38
|
+
payload,
|
|
39
|
+
token,
|
|
40
|
+
userId,
|
|
41
|
+
debug,
|
|
42
|
+
});
|
|
43
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
44
|
+
if (gateway.data.code !== 1) {
|
|
45
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
66
46
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
70
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
71
|
-
const result = data.result || {};
|
|
72
|
-
return [{ dataId: result.dataId || '', formId: result.formId || '', addTime: result.addTime || '', updateTime: result.updateTime || '', data: JSON.stringify(result.data || {}), code: data.code ?? '', msg: data.msg || '' }];
|
|
47
|
+
const result = gateway.data.result || {};
|
|
48
|
+
return [{ dataId: result.dataId || '', formId: result.formId || '', addTime: result.addTime || '', updateTime: result.updateTime || '', data: JSON.stringify(result.data || {}), code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
73
49
|
},
|
|
74
50
|
});
|
package/refund-edit.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/refund/edit';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
function getRuntimeConfig() {
|
|
17
|
-
const config = readConfig();
|
|
18
|
-
return { corpid: String(config.corpid || '').trim(), token: String(config.token || '').trim(), baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(), userId: String(config.userId || '').trim() };
|
|
19
|
-
}
|
|
20
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
21
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
22
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
23
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/refund/edit';
|
|
24
5
|
function parseDataList(raw) {
|
|
25
6
|
if (raw && typeof raw === 'object' && !Array.isArray(raw)) return raw;
|
|
26
7
|
const text = String(raw || '').trim();
|
|
@@ -57,7 +38,6 @@ cli({
|
|
|
57
38
|
const payload = { corpid, dataId: Number(kwargs.dataId || 0) };
|
|
58
39
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
59
40
|
if (parsedDataList) payload.dataList = parsedDataList;
|
|
60
|
-
const body = JSON.stringify(payload);
|
|
61
41
|
|
|
62
42
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
63
43
|
if (!payload.dataId) return makeErrorRow('NO_DATAID', '缺少 --dataId');
|
|
@@ -65,23 +45,19 @@ cli({
|
|
|
65
45
|
if (parsedDataList === null) return makeErrorRow('NO_DATALIST', '缺少 --dataList');
|
|
66
46
|
if (parsedDataList === undefined) return makeErrorRow('INVALID_DATALIST', '--dataList 必须是 JSON 对象字符串');
|
|
67
47
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return makeErrorRow(
|
|
48
|
+
const gateway = await requestGateway({
|
|
49
|
+
baseUrl,
|
|
50
|
+
apiPath: API_PATH,
|
|
51
|
+
payload,
|
|
52
|
+
token,
|
|
53
|
+
userId,
|
|
54
|
+
debug,
|
|
55
|
+
});
|
|
56
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
57
|
+
if (gateway.data.code !== 1) {
|
|
58
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
79
59
|
}
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
83
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
84
|
-
const result = data.result || {};
|
|
85
|
-
return [{ dataId: result.dataId || '', resultCode: result.code ?? '', resultMsg: result.msg || '', code: data.code ?? '', msg: data.msg || '' }];
|
|
60
|
+
const result = gateway.data.result || {};
|
|
61
|
+
return [{ dataId: result.dataId || '', resultCode: result.code ?? '', resultMsg: result.msg || '', code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
86
62
|
},
|
|
87
63
|
});
|
package/refund-list.js
CHANGED
|
@@ -1,36 +1,20 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway, createPagination } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const REFUND_LIST_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/refund/list';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
4
|
+
const REFUND_LIST_API_PATH = '/pro/v2/api/refund/list';
|
|
11
5
|
const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function readConfig() {
|
|
15
|
-
return readActiveConfig();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function getRuntimeConfig() {
|
|
19
|
-
const config = readConfig();
|
|
20
|
-
return {
|
|
21
|
-
corpid: String(config.corpid || '').trim(),
|
|
22
|
-
token: String(config.token || '').trim(),
|
|
23
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
24
|
-
userId: String(config.userId || '').trim(),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
29
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
30
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
31
|
-
}
|
|
6
|
+
const pagination = createPagination();
|
|
32
7
|
|
|
33
8
|
function buildConditions(kwargs) {
|
|
9
|
+
const conditions = kwargs.conditions;
|
|
10
|
+
if (typeof conditions === 'string' && conditions.trim()) {
|
|
11
|
+
const parsed = JSON.parse(conditions);
|
|
12
|
+
if (!Array.isArray(parsed)) {
|
|
13
|
+
throw new Error('INVALID_CONDITIONS:conditions 必须是 JSON 数组');
|
|
14
|
+
}
|
|
15
|
+
return parsed;
|
|
16
|
+
}
|
|
17
|
+
|
|
34
18
|
if (!(kwargs.attr && kwargs.value)) {
|
|
35
19
|
return [];
|
|
36
20
|
}
|
|
@@ -127,6 +111,7 @@ cli({
|
|
|
127
111
|
args: [
|
|
128
112
|
{ name: 'userId', type: 'str', default: '', help: '操作人id(可选)' },
|
|
129
113
|
{ name: 'viewApproval', type: 'str', default: '', help: '是否查询审批中数据,1是,0否' },
|
|
114
|
+
{ name: 'conditions', type: 'str', default: '', help: '条件集合 JSON 数组字符串,优先级高于 --attr/--value' },
|
|
130
115
|
{ name: 'attr', type: 'str', default: '', help: '筛选字段 attr,例如 serialNo' },
|
|
131
116
|
{ name: 'value', type: 'str', default: '', help: '筛选值,和 --attr 配合使用' },
|
|
132
117
|
{ name: 'symbol', type: 'str', default: 'equal', help: '筛选操作符,默认 equal' },
|
|
@@ -136,51 +121,42 @@ cli({
|
|
|
136
121
|
{ name: 'raw', type: 'bool', default: false, help: '输出接口返回的原文' },
|
|
137
122
|
],
|
|
138
123
|
columns: ['rank', 'dataId', 'formId', 'serialNo', 'customerId', 'contractId', 'refundType', 'refundAmount', 'creatorId', 'addTime', 'updateTime', 'data', 'code', 'msg'],
|
|
139
|
-
footerExtra:
|
|
124
|
+
footerExtra: pagination.footerExtra,
|
|
140
125
|
func: async function (kwargs) {
|
|
141
126
|
const debug = Boolean(kwargs.debug);
|
|
142
127
|
const { corpid, token, baseUrl, userId } = getRuntimeConfig();
|
|
143
|
-
|
|
144
|
-
|
|
128
|
+
let payload;
|
|
129
|
+
try {
|
|
130
|
+
payload = buildPayload(kwargs, corpid);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
const message = String(error?.message || error);
|
|
133
|
+
const separatorIndex = message.indexOf(':');
|
|
134
|
+
const code = separatorIndex > 0 ? message.slice(0, separatorIndex) : 'INVALID_PAYLOAD';
|
|
135
|
+
const detail = separatorIndex > 0 ? message.slice(separatorIndex + 1) : message;
|
|
136
|
+
return makeErrorRow(code, detail);
|
|
137
|
+
}
|
|
145
138
|
|
|
146
139
|
const validationError = getValidationError(payload, token);
|
|
147
140
|
if (validationError) {
|
|
148
141
|
return makeErrorRow(validationError.code, validationError.msg);
|
|
149
142
|
}
|
|
150
143
|
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
process.stderr.write(`[debug] URL: ${apiUrl}\n[debug] Headers: ${JSON.stringify(headers)}\n[debug] RequestBody: ${body}\n`);
|
|
159
|
-
}
|
|
160
|
-
const resp = await fetch(apiUrl, {
|
|
161
|
-
method: 'POST',
|
|
162
|
-
headers,
|
|
163
|
-
body,
|
|
144
|
+
const gateway = await requestGateway({
|
|
145
|
+
baseUrl,
|
|
146
|
+
apiPath: REFUND_LIST_API_PATH,
|
|
147
|
+
payload,
|
|
148
|
+
token,
|
|
149
|
+
userId,
|
|
150
|
+
debug,
|
|
164
151
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return makeErrorRow(
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const data = await resp.json();
|
|
173
|
-
lastPagination = data?.code === 1 && data?.result?.totalCount != null && data?.result?.totalPage != null
|
|
174
|
-
? { totalCount: data.result.totalCount, totalPage: data.result.totalPage }
|
|
175
|
-
: null;
|
|
176
|
-
const responseBody = JSON.stringify(data);
|
|
177
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
178
|
-
if (kwargs.raw) return [{ raw: responseBody }];
|
|
179
|
-
if (data.code !== 1) {
|
|
180
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
152
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
153
|
+
pagination.update(gateway.data);
|
|
154
|
+
if (kwargs.raw) return [{ raw: gateway.responseBody }];
|
|
155
|
+
if (gateway.data.code !== 1) {
|
|
156
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
181
157
|
}
|
|
182
158
|
|
|
183
|
-
const list = Array.isArray(data.result?.list) ? data.result.list : [];
|
|
159
|
+
const list = Array.isArray(gateway.data.result?.list) ? gateway.data.result.list : [];
|
|
184
160
|
if (!list.length) {
|
|
185
161
|
return makeErrorRow('NO_DATA', '接口成功,但 list 为空');
|
|
186
162
|
}
|
package/role-list.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway, createPagination } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/role/list';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
4
|
+
const API_PATH = '/pro/v2/api/role/list';
|
|
11
5
|
const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function readConfig() {
|
|
15
|
-
return readActiveConfig();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function getRuntimeConfig() {
|
|
19
|
-
const config = readConfig();
|
|
20
|
-
return {
|
|
21
|
-
corpid: String(config.corpid || '').trim(),
|
|
22
|
-
token: String(config.token || '').trim(),
|
|
23
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
24
|
-
userId: String(config.userId || '').trim(),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function buildApiUrl(baseUrl, apiUrl) {
|
|
29
|
-
const apiPath = new URL(apiUrl).pathname;
|
|
30
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
31
|
-
}
|
|
6
|
+
const pagination = createPagination();
|
|
32
7
|
|
|
33
8
|
function makeErrorRow(code, msg) {
|
|
34
9
|
return [{ rank: '', id: '', roleName: '', code, msg }];
|
|
@@ -49,33 +24,30 @@ cli({
|
|
|
49
24
|
{ name: 'raw', type: 'bool', default: false, help: '输出接口返回的原文' },
|
|
50
25
|
],
|
|
51
26
|
columns: ['rank', 'id', 'roleName', 'code', 'msg'],
|
|
52
|
-
footerExtra:
|
|
27
|
+
footerExtra: pagination.footerExtra,
|
|
53
28
|
func: async function (kwargs) {
|
|
54
29
|
const debug = Boolean(kwargs.debug);
|
|
55
30
|
const { corpid, token, baseUrl, userId } = getRuntimeConfig();
|
|
56
31
|
const payload = { corpid };
|
|
57
32
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
58
33
|
if (String(kwargs.roleNameLike || '').trim()) payload.roleNameLike = String(kwargs.roleNameLike);
|
|
59
|
-
const requestBody = JSON.stringify(payload);
|
|
60
34
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
61
35
|
if (!token) return makeErrorRow('NO_TOKEN', MISSING_TOKEN_MESSAGE);
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
36
|
+
const gateway = await requestGateway({
|
|
37
|
+
baseUrl,
|
|
38
|
+
apiPath: API_PATH,
|
|
39
|
+
payload,
|
|
40
|
+
token,
|
|
41
|
+
userId,
|
|
42
|
+
debug,
|
|
43
|
+
});
|
|
44
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
45
|
+
pagination.update(gateway.data);
|
|
46
|
+
if (kwargs.raw) return [{ raw: gateway.responseBody }];
|
|
47
|
+
if (gateway.data.code !== 1) {
|
|
48
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
67
49
|
}
|
|
68
|
-
const
|
|
69
|
-
if (!resp.ok) return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
70
|
-
const data = await resp.json();
|
|
71
|
-
lastPagination = data?.code === 1 && data?.result?.totalCount != null && data?.result?.totalPage != null
|
|
72
|
-
? { totalCount: data.result.totalCount, totalPage: data.result.totalPage }
|
|
73
|
-
: null;
|
|
74
|
-
const responseBody = JSON.stringify(data);
|
|
75
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
76
|
-
if (kwargs.raw) return [{ raw: responseBody }];
|
|
77
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
78
|
-
const list = Array.isArray(data.result?.roleList) ? data.result.roleList : [];
|
|
50
|
+
const list = Array.isArray(gateway.data.result?.roleList) ? gateway.data.result.roleList : [];
|
|
79
51
|
if (!list.length) return makeErrorRow('NO_DATA', '接口成功,但 roleList 为空');
|
|
80
52
|
return list.map((item, index) => ({ rank: index + 1, id: item.id || '', roleName: item.roleName || '', code: '', msg: '' }));
|
|
81
53
|
},
|