chore: clean project config

This commit is contained in:
2026-06-07 02:09:05 +08:00
parent aa593449bb
commit 1b89ce6f71
7 changed files with 15 additions and 69 deletions
+2 -3
View File
@@ -6,6 +6,5 @@
"trailingComma": "all", "trailingComma": "all",
"tabWidth": 2, "tabWidth": 2,
"proseWrap": "never", "proseWrap": "never",
"overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }], "overrides": [{ "files": ".prettierrc", "options": { "parser": "json" } }]
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-packagejson"] }
}
@@ -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;
@@ -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;
@@ -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`);
@@ -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`);
@@ -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`;
@@ -57,7 +57,6 @@ export class OrderLogsService {
let httpStatus: number | null = null; let httpStatus: number | null = null;
let responsePayload: unknown | null = null; let responsePayload: unknown | null = null;
let errorMessage: string | null = null; let errorMessage: string | null = null;
let status: 'success' | 'failure' = 'failure';
let logged = false; let logged = false;
try { try {
@@ -71,7 +70,7 @@ export class OrderLogsService {
httpStatus = response.status; httpStatus = response.status;
const text = await response.text(); const text = await response.text();
responsePayload = this.parseStreamText(text); responsePayload = this.parseStreamText(text);
status = response.ok ? 'success' : 'failure'; const status = response.ok ? 'success' : 'failure';
if (!response.ok) { if (!response.ok) {
errorMessage = `HTTP ${response.status}`; errorMessage = `HTTP ${response.status}`;
} }
@@ -88,7 +87,9 @@ export class OrderLogsService {
logged = true; logged = true;
if (!response.ok) { if (!response.ok) {
throw new BadRequestException(`第三方 Stream 日志请求失败:HTTP ${response.status}`); throw new BadRequestException(
`第三方 Stream 日志请求失败:HTTP ${response.status}`,
);
} }
return { return {
@@ -136,7 +137,9 @@ export class OrderLogsService {
const type = String(query.type || '').trim(); const type = String(query.type || '').trim();
const status = String(query.status || '').trim(); const status = String(query.status || '').trim();
const orderId = String(query.orderId || '').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 const builder = this.apiCallLogsRepository
.createQueryBuilder('log') .createQueryBuilder('log')
@@ -183,7 +186,9 @@ export class OrderLogsService {
} }
private buildStreamLogUrl(orderId: string) { private buildStreamLogUrl(orderId: string) {
const apiUrl = new URL(this.configService.getOrThrow<string>('WK_BASE_URL')); const apiUrl = new URL(
this.configService.getOrThrow<string>('WK_BASE_URL'),
);
const streamUrl = new URL('/api/streamLogs', apiUrl.origin); const streamUrl = new URL('/api/streamLogs', apiUrl.origin);
streamUrl.searchParams.set('id', orderId); streamUrl.searchParams.set('id', orderId);
return streamUrl.toString(); return streamUrl.toString();
@@ -272,7 +277,9 @@ export class OrderLogsService {
private getErrorMessage(error: unknown) { private getErrorMessage(error: unknown) {
if (error instanceof Error) { if (error instanceof Error) {
return error.name === 'AbortError' ? '第三方 Stream 日志请求超时' : error.message; return error.name === 'AbortError'
? '第三方 Stream 日志请求超时'
: error.message;
} }
return '第三方 Stream 日志请求失败'; return '第三方 Stream 日志请求失败';
} }