feat(sync): add converters from Hiboutik DTOs to Prisma inputs
Includes helpers for Hiboutik dates ("0000-00-00" is ignored) and optional prices ("0.00" means no value).
This commit is contained in:
22
src/models/converter/category.converter.ts
Normal file
22
src/models/converter/category.converter.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CategoryHiboutikDto } from '../hiboutikDTO/category.hiboutik.dto';
|
||||
import { Converter } from './converter';
|
||||
import { CategoryCreateInput } from '../../../prisma/generated/models/Category';
|
||||
|
||||
@Injectable()
|
||||
export class CategoryConverter extends Converter<CategoryCreateInput, CategoryHiboutikDto> {
|
||||
/** The parent is not set here: it is linked afterwards, once every category exists (see CategoryHiboutikService). */
|
||||
fromHiboutik(hiboutikDto: CategoryHiboutikDto): CategoryCreateInput {
|
||||
return {
|
||||
hiboutikId: hiboutikDto.category_id,
|
||||
name: hiboutikDto.category_name,
|
||||
enabled: hiboutikDto.category_enabled == 1,
|
||||
position: Number(hiboutikDto.category_position) || 0,
|
||||
webEnabled: hiboutikDto.category_enabled_www == 1,
|
||||
};
|
||||
}
|
||||
|
||||
toHiboutik(): CategoryHiboutikDto {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user