From 1b89ce6f7136b6b38e05e77ad1409f8837032512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AF=92=E5=AF=92?= <2596194220@qq.com> Date: Sun, 7 Jun 2026 02:09:05 +0800 Subject: [PATCH] chore: clean project config --- .prettierrc | 5 ++- .../202606040001_phase3_courses.sql | 33 ------------------- .../202606040002_add_course_content.sql | 7 ---- .../202606040003_course_list_indexes.sql | 5 --- ...202606040004_api_call_log_list_indexes.sql | 5 --- ...02606040005_structured_course_products.sql | 10 ------ .../src/order-logs/order-logs.service.ts | 19 +++++++---- 7 files changed, 15 insertions(+), 69 deletions(-) delete mode 100644 docs/migrations/202606040001_phase3_courses.sql delete mode 100644 docs/migrations/202606040002_add_course_content.sql delete mode 100644 docs/migrations/202606040003_course_list_indexes.sql delete mode 100644 docs/migrations/202606040004_api_call_log_list_indexes.sql delete mode 100644 docs/migrations/202606040005_structured_course_products.sql diff --git a/.prettierrc b/.prettierrc index 2b63da8..0a15d60 100644 --- a/.prettierrc +++ b/.prettierrc @@ -6,6 +6,5 @@ "trailingComma": "all", "tabWidth": 2, "proseWrap": "never", - "overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }], - "plugins": ["prettier-plugin-organize-imports", "prettier-plugin-packagejson"] -} \ No newline at end of file + "overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }] +} diff --git a/docs/migrations/202606040001_phase3_courses.sql b/docs/migrations/202606040001_phase3_courses.sql deleted file mode 100644 index a945b2e..0000000 --- a/docs/migrations/202606040001_phase3_courses.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE IF NOT EXISTS `categories` ( - `id` varchar(36) NOT NULL, - `api_account_id` varchar(36) NOT NULL, - `remote_category_id` varchar(120) NOT NULL, - `name` varchar(160) NOT NULL, - `sort_order` int NOT NULL DEFAULT 0, - `raw_payload` json NULL, - `last_synced_at` datetime NOT NULL, - `created_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), - `updated_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), - PRIMARY KEY (`id`), - UNIQUE KEY `IDX_categories_account_remote` (`api_account_id`, `remote_category_id`), - KEY `IDX_categories_account` (`api_account_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - -CREATE TABLE IF NOT EXISTS `courses` ( - `id` varchar(36) NOT NULL, - `api_account_id` varchar(36) NOT NULL, - `category_id` varchar(36) NULL, - `remote_category_id` varchar(120) NOT NULL DEFAULT '', - `remote_course_id` varchar(160) NOT NULL, - `name` varchar(255) NOT NULL, - `is_favorite` tinyint NOT NULL DEFAULT 0, - `enabled` tinyint NOT NULL DEFAULT 1, - `raw_payload` json NULL, - `last_synced_at` datetime NOT NULL, - `created_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), - `updated_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), - PRIMARY KEY (`id`), - UNIQUE KEY `IDX_courses_account_remote_category` (`api_account_id`, `remote_course_id`, `remote_category_id`), - KEY `IDX_courses_account` (`api_account_id`), - KEY `IDX_courses_category` (`category_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/docs/migrations/202606040002_add_course_content.sql b/docs/migrations/202606040002_add_course_content.sql deleted file mode 100644 index 2bce82d..0000000 --- a/docs/migrations/202606040002_add_course_content.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE `courses` - ADD COLUMN `content` text NULL AFTER `name`; - -UPDATE `courses` -SET `content` = JSON_UNQUOTE(JSON_EXTRACT(`raw_payload`, '$.content')) -WHERE `content` IS NULL - AND JSON_EXTRACT(`raw_payload`, '$.content') IS NOT NULL; diff --git a/docs/migrations/202606040003_course_list_indexes.sql b/docs/migrations/202606040003_course_list_indexes.sql deleted file mode 100644 index 26ed358..0000000 --- a/docs/migrations/202606040003_course_list_indexes.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE INDEX `IDX_courses_account_favorite_updated` - ON `courses` (`api_account_id`, `is_favorite`, `updated_at`); - -CREATE INDEX `IDX_courses_account_category_favorite_updated` - ON `courses` (`api_account_id`, `category_id`, `is_favorite`, `updated_at`); diff --git a/docs/migrations/202606040004_api_call_log_list_indexes.sql b/docs/migrations/202606040004_api_call_log_list_indexes.sql deleted file mode 100644 index 61c0c7f..0000000 --- a/docs/migrations/202606040004_api_call_log_list_indexes.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE INDEX `IDX_api_call_logs_created_at` - ON `api_call_logs` (`created_at`); - -CREATE INDEX `IDX_api_call_logs_act_created_at` - ON `api_call_logs` (`act`, `created_at`); diff --git a/docs/migrations/202606040005_structured_course_products.sql b/docs/migrations/202606040005_structured_course_products.sql deleted file mode 100644 index 22beb48..0000000 --- a/docs/migrations/202606040005_structured_course_products.sql +++ /dev/null @@ -1,10 +0,0 @@ -ALTER TABLE `courses` - ADD COLUMN `price` decimal(10,2) NOT NULL DEFAULT 0.00 AFTER `name`; - -UPDATE `courses` -SET `price` = CAST(JSON_UNQUOTE(JSON_EXTRACT(`raw_payload`, '$.price')) AS DECIMAL(10,2)) -WHERE JSON_EXTRACT(`raw_payload`, '$.price') IS NOT NULL - AND JSON_UNQUOTE(JSON_EXTRACT(`raw_payload`, '$.price')) REGEXP '^-?[0-9]+(\\.[0-9]+)?$'; - -ALTER TABLE `courses` - DROP COLUMN `raw_payload`; diff --git a/packages/backend/src/order-logs/order-logs.service.ts b/packages/backend/src/order-logs/order-logs.service.ts index e81fbab..55a98ea 100644 --- a/packages/backend/src/order-logs/order-logs.service.ts +++ b/packages/backend/src/order-logs/order-logs.service.ts @@ -57,7 +57,6 @@ export class OrderLogsService { let httpStatus: number | null = null; let responsePayload: unknown | null = null; let errorMessage: string | null = null; - let status: 'success' | 'failure' = 'failure'; let logged = false; try { @@ -71,7 +70,7 @@ export class OrderLogsService { httpStatus = response.status; const text = await response.text(); responsePayload = this.parseStreamText(text); - status = response.ok ? 'success' : 'failure'; + const status = response.ok ? 'success' : 'failure'; if (!response.ok) { errorMessage = `HTTP ${response.status}`; } @@ -88,7 +87,9 @@ export class OrderLogsService { logged = true; if (!response.ok) { - throw new BadRequestException(`第三方 Stream 日志请求失败:HTTP ${response.status}`); + throw new BadRequestException( + `第三方 Stream 日志请求失败:HTTP ${response.status}`, + ); } return { @@ -136,7 +137,9 @@ export class OrderLogsService { const type = String(query.type || '').trim(); const status = String(query.status || '').trim(); const orderId = String(query.orderId || '').trim(); - const acts = type ? [this.typeToAct(type)] : Object.values(logTypeActs).concat('streamLogs'); + const acts = type + ? [this.typeToAct(type)] + : Object.values(logTypeActs).concat('streamLogs'); const builder = this.apiCallLogsRepository .createQueryBuilder('log') @@ -183,7 +186,9 @@ export class OrderLogsService { } private buildStreamLogUrl(orderId: string) { - const apiUrl = new URL(this.configService.getOrThrow('WK_BASE_URL')); + const apiUrl = new URL( + this.configService.getOrThrow('WK_BASE_URL'), + ); const streamUrl = new URL('/api/streamLogs', apiUrl.origin); streamUrl.searchParams.set('id', orderId); return streamUrl.toString(); @@ -272,7 +277,9 @@ export class OrderLogsService { private getErrorMessage(error: unknown) { if (error instanceof Error) { - return error.name === 'AbortError' ? '第三方 Stream 日志请求超时' : error.message; + return error.name === 'AbortError' + ? '第三方 Stream 日志请求超时' + : error.message; } return '第三方 Stream 日志请求失败'; }