Files
dinggadingga-backend/src/models/converter/category.converter.ts
MastersGame db699822f9 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).
2026-11-05 23:00:48 +01:00

23 lines
909 B
TypeScript

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.');
}
}