mirror of
https://github.com/hpd840321/craftlabs-authorization-sdk.git
synced 2026-06-09 10:00:30 +08:00
8c167d4909
V24 migration creates platform_user table. Backend UserAdminController provides list/create/update/toggleStatus. Frontend UserManagementView enables admin to add/edit/disable users. Replaces hardcoded auth with database-backed user lifecycle. Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
490 lines
15 KiB
JavaScript
490 lines
15 KiB
JavaScript
import axios from "axios";
|
||
|
||
/**
|
||
* @param {{ page?: number, size?: number, keyword?: string }} params
|
||
*/
|
||
export function uploadContractAttachment(contractId, file) {
|
||
const formData = new FormData();
|
||
formData.append('file', file);
|
||
return axios.post(`/api/v1/contracts/${contractId}/attachments`, formData, {
|
||
headers: { 'Content-Type': 'multipart/form-data' }
|
||
});
|
||
}
|
||
|
||
export function listContractAttachments(contractId) {
|
||
return axios.get(`/api/v1/contracts/${contractId}/attachments`);
|
||
}
|
||
|
||
export function listCustomers(params) {
|
||
return axios.get("/api/v1/customers", { params });
|
||
}
|
||
|
||
export function createCustomer(body) {
|
||
return axios.post("/api/v1/customers", body);
|
||
}
|
||
|
||
export function updateCustomer(id, body) {
|
||
return axios.put(`/api/v1/customers/${id}`, body);
|
||
}
|
||
|
||
export function deleteCustomer(id) {
|
||
return axios.delete(`/api/v1/customers/${id}`);
|
||
}
|
||
|
||
/**
|
||
* @param {{ page?: number, size?: number, customerId?: string | number }} params
|
||
*/
|
||
export function listProjects(params) {
|
||
return axios.get("/api/v1/projects", { params });
|
||
}
|
||
|
||
export function createProject(body) {
|
||
return axios.post("/api/v1/projects", body);
|
||
}
|
||
|
||
export function updateProject(id, body) {
|
||
return axios.put(`/api/v1/projects/${id}`, body);
|
||
}
|
||
|
||
export function deleteProject(id) {
|
||
return axios.delete(`/api/v1/projects/${id}`);
|
||
}
|
||
|
||
export function getCustomerSummary(id) {
|
||
return axios.get(`/api/v1/customers/${id}/summary`);
|
||
}
|
||
|
||
export function getProjectPhaseDictionary() {
|
||
return axios.get("/api/v1/dictionaries/PROJECT_PHASE");
|
||
}
|
||
|
||
/**
|
||
* 合同列表(分页)。后端就绪后路径以 OpenAPI 为准。
|
||
* @param {{ page?: number, size?: number, customerId?: string | number, projectId?: string | number, keyword?: string }} params
|
||
*/
|
||
export function listContracts(params) {
|
||
return axios.get("/api/v1/contracts", { params });
|
||
}
|
||
|
||
/**
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function createContract(body) {
|
||
return axios.post("/api/v1/contracts", body);
|
||
}
|
||
|
||
export function getContract(id) {
|
||
return axios.get(`/api/v1/contracts/${id}`);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} id
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function updateContract(id, body) {
|
||
return axios.put(`/api/v1/contracts/${id}`, body);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} contractId
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function addLine(contractId, body) {
|
||
return axios.post(`/api/v1/contracts/${contractId}/lines`, body);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} contractId
|
||
* @param {string | number} lineId
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function updateLine(contractId, lineId, body) {
|
||
return axios.put(`/api/v1/contracts/${contractId}/lines/${lineId}`, body);
|
||
}
|
||
|
||
export function deleteLine(contractId, lineId) {
|
||
return axios.delete(`/api/v1/contracts/${contractId}/lines/${lineId}`);
|
||
}
|
||
|
||
/**
|
||
* 状态迁移:后端 `PATCH /api/v1/contracts/{id}/status`,body `{ status: "PENDING_EFFECTIVE" }` 等。
|
||
* @param {string | number} id
|
||
* @param {{ status: string }} body
|
||
*/
|
||
export function patchContractStatus(id, body) {
|
||
return axios.patch(`/api/v1/contracts/${id}/status`, body);
|
||
}
|
||
|
||
/**
|
||
* M10-F01 审计分页:`GET /api/v1/audit-events`。
|
||
* @param {{ entityType?: string, entityId?: string | number, page?: number, size?: number }} params
|
||
*/
|
||
export function listAuditEvents(params) {
|
||
return axios.get("/api/v1/audit-events", { params });
|
||
}
|
||
|
||
/**
|
||
* M10-F02 审计检索:`GET /api/v1/audit-events`(无分页)。
|
||
* @param {{ entityType?: string, entityId?: string | number, from?: string, to?: string }} params
|
||
*/
|
||
export function searchAuditEvents(params) {
|
||
return axios.get("/api/v1/audit-events", { params });
|
||
}
|
||
|
||
/**
|
||
* M10-F03 审计导出 CSV:`GET /api/v1/audit-events/export`。
|
||
* @param {{ entityType?: string, entityId?: string | number, from?: string, to?: string }} params
|
||
*/
|
||
export function getAuditRetentionConfig() {
|
||
return axios.get('/api/v1/audit-events/retention-config');
|
||
}
|
||
|
||
export function exportAuditEvents(params) {
|
||
return axios.get("/api/v1/audit-events/export", { params, responseType: 'blob' });
|
||
}
|
||
|
||
/**
|
||
* @param {{ page?: number, size?: number, projectId?: string | number, keyword?: string }} params
|
||
*/
|
||
export function listDeliveryBatches(params) {
|
||
return axios.get("/api/v1/delivery-batches", { params });
|
||
}
|
||
|
||
/**
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function createDeliveryBatch(body) {
|
||
return axios.post("/api/v1/delivery-batches", body);
|
||
}
|
||
|
||
export function getDeliveryBatch(id) {
|
||
return axios.get(`/api/v1/delivery-batches/${id}`);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} id
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function updateDeliveryBatch(id, body) {
|
||
return axios.put(`/api/v1/delivery-batches/${id}`, body);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} id
|
||
* @param {{ status: string }} body
|
||
*/
|
||
export function patchDeliveryBatchStatus(id, body) {
|
||
return axios.patch(`/api/v1/delivery-batches/${id}/status`, body);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} batchId
|
||
*/
|
||
export function listDeliveryLines(batchId) {
|
||
return axios.get(`/api/v1/delivery-batches/${batchId}/lines`);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} batchId
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function addDeliveryLine(batchId, body) {
|
||
return axios.post(`/api/v1/delivery-batches/${batchId}/lines`, body);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} batchId
|
||
* @param {string | number} lineId
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function updateDeliveryLine(batchId, lineId, body) {
|
||
return axios.put(`/api/v1/delivery-batches/${batchId}/lines/${lineId}`, body);
|
||
}
|
||
|
||
export function deleteDeliveryLine(batchId, lineId) {
|
||
return axios.delete(`/api/v1/delivery-batches/${batchId}/lines/${lineId}`);
|
||
}
|
||
|
||
/**
|
||
* @param {{ page?: number, size?: number, projectId?: string | number, keyword?: string }} params
|
||
*/
|
||
export function listLicenseSns(params) {
|
||
return axios.get("/api/v1/license-sns", { params });
|
||
}
|
||
|
||
/**
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function createLicenseSn(body) {
|
||
return axios.post("/api/v1/license-sns", body);
|
||
}
|
||
|
||
export function getLicenseSn(id) {
|
||
return axios.get(`/api/v1/license-sns/${id}`);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} id
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function updateLicenseSn(id, body) {
|
||
return axios.put(`/api/v1/license-sns/${id}`, body);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} id
|
||
* @param {{ status: string }} body
|
||
*/
|
||
export function patchLicenseSnStatus(id, body) {
|
||
return axios.patch(`/api/v1/license-sns/${id}/status`, body);
|
||
}
|
||
|
||
export function batchImportLicenseSns(body) {
|
||
return axios.post('/api/v1/license-sns/batch-import', body);
|
||
}
|
||
|
||
/* —— I5 Callback Inbox & M6 integration read APIs (paths per docs/engineering/iterations/I5_I6_DESIGN.md A.3) —— */
|
||
|
||
/**
|
||
* @param {{
|
||
* page?: number,
|
||
* size?: number,
|
||
* status?: string,
|
||
* eventType?: string,
|
||
* snCode?: string,
|
||
* projectId?: string | number,
|
||
* productLineId?: string | number,
|
||
* environmentId?: string | number,
|
||
* from?: string,
|
||
* to?: string,
|
||
* }} params
|
||
*/
|
||
export function listCallbackInbox(params) {
|
||
return axios.get("/api/v1/callback-inbox", { params });
|
||
}
|
||
|
||
export function getCallbackInbox(id) {
|
||
return axios.get(`/api/v1/callback-inbox/${id}`);
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} id
|
||
* @param {{ status: string }} body
|
||
*/
|
||
export function patchCallbackInboxStatus(id, body) {
|
||
return axios.patch(`/api/v1/callback-inbox/${id}/status`, body);
|
||
}
|
||
|
||
/**
|
||
* 人工挂接(M5-F04)。body 字段以 OpenAPI 为准。
|
||
* @param {string | number} id
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function patchCallbackInboxLink(id, body) {
|
||
return axios.patch(`/api/v1/callback-inbox/${id}/link`, body);
|
||
}
|
||
|
||
/**
|
||
* M5-F10:模拟投递(仅测试环境)。
|
||
* @param {Record<string, unknown>} body
|
||
*/
|
||
export function simulateCallback(body) {
|
||
return axios.post('/api/v1/callback-inbox/simulate', body);
|
||
}
|
||
|
||
/**
|
||
* I8:将 Webhook 侧 DEAD 出库按收据 ID 重新入队(需平台配置 LICENSE_WEBHOOK_*)。
|
||
* @param {string | number} id — callback inbox id
|
||
*/
|
||
export function replayCallbackWebhookDelivery(id) {
|
||
return axios.post(`/api/v1/callback-inbox/${id}/replay-webhook-delivery`);
|
||
}
|
||
|
||
/**
|
||
* I9:只读查询 Webhook 侧平台投递行状态(需 LICENSE_WEBHOOK_*)。
|
||
* @param {string | number} id — callback inbox id
|
||
*/
|
||
export function getCallbackWebhookDelivery(id) {
|
||
return axios.get(`/api/v1/callback-inbox/${id}/webhook-delivery`);
|
||
}
|
||
|
||
/**
|
||
* @param {{ page?: number, size?: number }} params
|
||
*/
|
||
export function listIntegrationEnvironments(params) {
|
||
return axios.get("/api/v1/integration/environments", { params });
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} id
|
||
*/
|
||
export function getIntegrationEnvironment(id) {
|
||
return axios.get(`/api/v1/integration/environments/${id}`);
|
||
}
|
||
|
||
export function createIntegrationEnvironment(body) {
|
||
return axios.post("/api/v1/integration/environments", body);
|
||
}
|
||
|
||
export function updateIntegrationEnvironment(id, body) {
|
||
return axios.put(`/api/v1/integration/environments/${id}`, body);
|
||
}
|
||
|
||
export function deleteIntegrationEnvironment(id) {
|
||
return axios.delete(`/api/v1/integration/environments/${id}`);
|
||
}
|
||
|
||
/**
|
||
* @param {{ page?: number, size?: number }} params
|
||
*/
|
||
export function listProductLines(params) {
|
||
return axios.get("/api/v1/integration/product-lines", { params });
|
||
}
|
||
|
||
/**
|
||
* @param {string | number} id
|
||
*/
|
||
export function getProductLine(id) {
|
||
return axios.get(`/api/v1/integration/product-lines/${id}`);
|
||
}
|
||
|
||
export function createProductLine(body) {
|
||
return axios.post("/api/v1/integration/product-lines", body);
|
||
}
|
||
|
||
export function updateProductLine(id, body) {
|
||
return axios.put(`/api/v1/integration/product-lines/${id}`, body);
|
||
}
|
||
|
||
export function deleteProductLine(id) {
|
||
return axios.delete(`/api/v1/integration/product-lines/${id}`);
|
||
}
|
||
|
||
// —— M7 设备管理 ————————————————————————————
|
||
export function listDevices(params) {
|
||
return axios.get('/api/v1/devices', { params });
|
||
}
|
||
export function getDevice(id) {
|
||
return axios.get(`/api/v1/devices/${id}`);
|
||
}
|
||
export function createDevice(body) {
|
||
return axios.post('/api/v1/devices', body);
|
||
}
|
||
export function updateDevice(id, body) {
|
||
return axios.put(`/api/v1/devices/${id}`, body);
|
||
}
|
||
export function getDeviceBindings(id) {
|
||
return axios.get(`/api/v1/devices/${id}/bindings`);
|
||
}
|
||
export function createDeviceSwapRequest(id, body) {
|
||
return axios.post(`/api/v1/devices/${id}/swap-request`, body);
|
||
}
|
||
|
||
// —— M8 通知待办 ————————————————————————————
|
||
export function listTodos(params) {
|
||
return axios.get('/api/v1/todos', { params });
|
||
}
|
||
export function patchTodoStatus(id, body) {
|
||
return axios.patch(`/api/v1/todos/${id}/status`, body);
|
||
}
|
||
export function batchUpdateTodoStatus(body) {
|
||
return axios.post('/api/v1/todos/batch-status', body);
|
||
}
|
||
export function getNotificationConfig(params) {
|
||
return axios.get('/api/v1/notifications/config', { params });
|
||
}
|
||
export function updateNotificationConfig(body) {
|
||
return axios.put('/api/v1/notifications/config', body);
|
||
}
|
||
|
||
// —— M9 报表对账 ————————————————————————————
|
||
export function getContractSnReport(params) {
|
||
return axios.get('/api/v1/reports/contract-sn', { params });
|
||
}
|
||
export function exportReport(params) {
|
||
return axios.get('/api/v1/reports/export', { params, responseType: 'blob' });
|
||
}
|
||
export function getCallbackStats(params) {
|
||
return axios.get('/api/v1/reports/callback-stats', { params });
|
||
}
|
||
export function getProjectHealth() {
|
||
return axios.get('/api/v1/reports/project-health');
|
||
}
|
||
|
||
// —— I11 合同变更版本 ——————————————————————————
|
||
export function initiateContractChange(id, body) {
|
||
return axios.post(`/api/v1/contracts/${id}/changes`, body);
|
||
}
|
||
export function completeContractChange(id) {
|
||
return axios.post(`/api/v1/contracts/${id}/changes/complete`);
|
||
}
|
||
|
||
// —— I12 M6 比特 ID 映射 ——————————————————————
|
||
export function listIdMappings(params) {
|
||
return axios.get('/api/v1/integration/id-mappings', { params });
|
||
}
|
||
export function createIdMapping(body) {
|
||
return axios.post('/api/v1/integration/id-mappings', body);
|
||
}
|
||
export function updateIdMapping(id, body) {
|
||
return axios.put(`/api/v1/integration/id-mappings/${id}`, body);
|
||
}
|
||
export function deleteIdMapping(id) {
|
||
return axios.delete(`/api/v1/integration/id-mappings/${id}`);
|
||
}
|
||
|
||
// —— I12-2 M6 JSON 模板 ——————————————————————
|
||
export function listJsonTemplates() {
|
||
return axios.get('/api/v1/integration/json-templates');
|
||
}
|
||
export function getJsonTemplate(id) {
|
||
return axios.get(`/api/v1/integration/json-templates/${id}`);
|
||
}
|
||
export function createJsonTemplate(body) {
|
||
return axios.post('/api/v1/integration/json-templates', body);
|
||
}
|
||
export function updateJsonTemplate(id, body) {
|
||
return axios.put(`/api/v1/integration/json-templates/${id}`, body);
|
||
}
|
||
export function deleteJsonTemplate(id) {
|
||
return axios.delete(`/api/v1/integration/json-templates/${id}`);
|
||
}
|
||
|
||
// —— I16-T3 M6-F04 特征映射 ——————————————————————————
|
||
export function listFeatureMappings(params) {
|
||
return axios.get('/api/v1/integration/feature-mappings', { params });
|
||
}
|
||
|
||
// —— I15-T2 M2-F08 SKU 映射 ——————————————————————————
|
||
export function listSkuMappings(params) { return axios.get('/api/v1/integration/sku-mappings', { params }); }
|
||
export function createSkuMapping(contractLineId, body) { return axios.post(`/api/v1/integration/sku-mappings?contractLineId=${contractLineId}`, body); }
|
||
export function updateSkuMapping(id, body) { return axios.put(`/api/v1/integration/sku-mappings/${id}`, body); }
|
||
export function deleteSkuMapping(id) { return axios.delete(`/api/v1/integration/sku-mappings/${id}`); }
|
||
|
||
// —— M11-F14 用户管理 ————————————————————————————
|
||
export function listUsers() {
|
||
return axios.get('/api/v1/admin/users');
|
||
}
|
||
export function createUser(body) {
|
||
return axios.post('/api/v1/admin/users', body);
|
||
}
|
||
export function updateUser(id, body) {
|
||
return axios.put(`/api/v1/admin/users/${id}`, body);
|
||
}
|
||
export function patchUserStatus(id, body) {
|
||
return axios.patch(`/api/v1/admin/users/${id}/status`, body);
|
||
}
|
||
|
||
export function listStakeholders(projectId) {
|
||
return axios.get(`/api/v1/projects/${projectId}/stakeholders`);
|
||
}
|
||
export function addStakeholder(projectId, body) {
|
||
return axios.post(`/api/v1/projects/${projectId}/stakeholders`, body);
|
||
}
|
||
export function updateStakeholder(projectId, id, body) {
|
||
return axios.put(`/api/v1/projects/${projectId}/stakeholders/${id}`, body);
|
||
}
|
||
export function deleteStakeholder(projectId, id) {
|
||
return axios.delete(`/api/v1/projects/${projectId}/stakeholders/${id}`);
|
||
}
|