From 55a35b5498e3e3113787a30a98a00803e5327ba3 Mon Sep 17 00:00:00 2001 From: R2m1liA <15258427350@163.com> Date: Wed, 3 Dec 2025 16:56:57 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将问题类型的类型名字段命名由type改为name --- server/mappers/questionMapper.test.ts | 10 +++++----- server/mappers/questionMapper.ts | 6 +++--- shared/types/views/question-list-view.ts | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/mappers/questionMapper.test.ts b/server/mappers/questionMapper.test.ts index e97e2d5..ffa9afe 100644 --- a/server/mappers/questionMapper.test.ts +++ b/server/mappers/questionMapper.test.ts @@ -21,7 +21,7 @@ describe('toQuestionTypeView', () => { expect(toQuestionTypeView(rawData)).toEqual({ id: '1', - type: 'Type Name', + name: 'Type Name', }); }); @@ -33,7 +33,7 @@ describe('toQuestionTypeView', () => { expect(toQuestionTypeView(rawData)).toEqual({ id: '1', - type: '', + name: '', }); }); @@ -41,7 +41,7 @@ describe('toQuestionTypeView', () => { const rawData: QuestionType | null = null; expect(toQuestionTypeView(rawData)).toEqual({ - id: '', + id: '-1', type: '', }); }); @@ -120,7 +120,7 @@ describe('toQuestionListView', () => { id: '1', type: { id: '1', - type: 'Type Name', + name: 'Type Name', }, title: 'Question Title', content: 'Question Answer', @@ -160,7 +160,7 @@ describe('toQuestionListView', () => { id: '1', type: { id: '1', - type: 'Type Name', + name: 'Type Name', }, title: '', content: '', diff --git a/server/mappers/questionMapper.ts b/server/mappers/questionMapper.ts index e81b543..041c21e 100644 --- a/server/mappers/questionMapper.ts +++ b/server/mappers/questionMapper.ts @@ -14,15 +14,15 @@ export function toQuestionTypeView( ): QuestionTypeView { if (typeof raw === 'string' || raw === null) { return { - id: '', - type: '', + id: '-1', + name: '', } satisfies QuestionTypeView; } const trans = raw.translations?.[0]; return { id: raw.id.toString(), - type: trans?.name ?? '', + name: trans?.name ?? '', }; } diff --git a/shared/types/views/question-list-view.ts b/shared/types/views/question-list-view.ts index 0a1755e..362fd93 100644 --- a/shared/types/views/question-list-view.ts +++ b/shared/types/views/question-list-view.ts @@ -16,7 +16,7 @@ export interface QuestionTypeView { id: string; /** 类型名 **/ - type: string; + name: string; } /**