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; } /**