refactor: 重构产品相关Mapper
- 空值处理与类型控制:为相关关系型字段的数据处理添加空值处理与类型控制 - 调整目录结构:将文件目录按照实际查询划分为Product和ProductList两个文件
This commit is contained in:
@ -26,25 +26,6 @@ export function toQuestionTypeView(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 Question 数据转换为 ProductQuestionView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Question 数据
|
||||
* @returns 转换后的 ProductQuestionView 对象
|
||||
*
|
||||
* @example
|
||||
* const view = toProductQuestionView(rawQuestion);
|
||||
*/
|
||||
export function toProductQuestionView(raw: Question): ProductQuestionView {
|
||||
const trans = raw.translations?.[0];
|
||||
|
||||
return {
|
||||
id: raw.id.toString(),
|
||||
title: trans?.title ?? '',
|
||||
content: trans?.content ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 Question 数据转换为 QuestionListView 视图模型
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user