feat: 为搜索条目添加细分类型
- 类型细分:有原先的四大分类添加细分类型,例如产品(原纸分切机) - 接口调整:原先的type分类改为sectionType并将type作为细分类型使用
This commit is contained in:
@ -17,9 +17,10 @@ describe('converters', () => {
|
||||
const result = converters.products(item);
|
||||
expect(result).toEqual({
|
||||
id: 1,
|
||||
type: 'product',
|
||||
sectionType: 'product',
|
||||
title: 'Hydraulic Pump',
|
||||
summary: 'High efficiency',
|
||||
type: 'pump',
|
||||
thumbnail: '/api/assets/rand-om__-uuid-1234',
|
||||
});
|
||||
});
|
||||
@ -36,9 +37,10 @@ describe('converters', () => {
|
||||
const result = converters.solutions(item);
|
||||
expect(result).toEqual({
|
||||
id: 1,
|
||||
type: 'solution',
|
||||
sectionType: 'solution',
|
||||
title: 'Solution A',
|
||||
summary: 'Effective solution',
|
||||
type: 'Type A',
|
||||
thumbnail: '/api/assets/rand-om__-uuid-5678',
|
||||
});
|
||||
});
|
||||
@ -51,13 +53,15 @@ describe('converters', () => {
|
||||
'This is a detailed explanation of how to use the product effectively.',
|
||||
products: ['Product A'],
|
||||
product_types: ['Type A'],
|
||||
type: 'Question Type',
|
||||
};
|
||||
const result = converters.questions(item);
|
||||
expect(result).toEqual({
|
||||
id: 1,
|
||||
title: 'How to use product?',
|
||||
summary: '',
|
||||
type: 'question',
|
||||
summary: undefined,
|
||||
type: 'Question Type',
|
||||
sectionType: 'question',
|
||||
});
|
||||
});
|
||||
|
||||
@ -68,13 +72,15 @@ describe('converters', () => {
|
||||
products: ['Product A'],
|
||||
product_types: ['Type A'],
|
||||
fileUUID: 'TEST-UUID',
|
||||
type: 'manual',
|
||||
};
|
||||
const result = converters.product_documents(item);
|
||||
expect(result).toEqual({
|
||||
id: 'TEST-UUID',
|
||||
title: 'User Manual',
|
||||
summary: '',
|
||||
type: 'document',
|
||||
summary: undefined,
|
||||
sectionType: 'document',
|
||||
type: 'manual',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -6,33 +6,35 @@ export const converters: {
|
||||
} = {
|
||||
products: (item: MeiliIndexMap['products']): SearchItemView => ({
|
||||
id: item.id,
|
||||
type: 'product',
|
||||
sectionType: 'product',
|
||||
title: item.name,
|
||||
summary: item?.summary ?? '',
|
||||
summary: item?.summary,
|
||||
type: item?.type,
|
||||
thumbnail: item?.cover ? `/api/assets/${item.cover}` : undefined,
|
||||
}),
|
||||
|
||||
solutions: (item: MeiliIndexMap['solutions']): SearchItemView => ({
|
||||
id: item.id,
|
||||
type: 'solution',
|
||||
sectionType: 'solution',
|
||||
title: item.title,
|
||||
summary: item?.summary ?? '',
|
||||
summary: item?.summary,
|
||||
type: item?.type,
|
||||
thumbnail: item?.cover ? `/api/assets/${item.cover}` : undefined,
|
||||
}),
|
||||
|
||||
questions: (item: MeiliIndexMap['questions']): SearchItemView => ({
|
||||
id: item.id,
|
||||
type: 'question',
|
||||
sectionType: 'question',
|
||||
title: item.title,
|
||||
summary: '',
|
||||
type: item?.type,
|
||||
}),
|
||||
|
||||
product_documents: (
|
||||
item: MeiliIndexMap['product_documents']
|
||||
): SearchItemView => ({
|
||||
id: item.fileUUID || item.id,
|
||||
type: 'document',
|
||||
sectionType: 'document',
|
||||
title: item.title,
|
||||
summary: '',
|
||||
type: item?.type,
|
||||
}),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user