blog/frontend/src/lib/post/adapter/presenter/labelViewModel.ts
2025-07-24 00:04:12 +08:00

23 lines
590 B
TypeScript

import { ColorViewModel } from '$lib/post/adapter/presenter/colorViewModel';
import type { Label } from '$lib/post/domain/entity/label';
export class LabelViewModel {
readonly id: number;
readonly name: string;
readonly color: ColorViewModel;
private constructor(props: { id: number; name: string; color: ColorViewModel }) {
this.id = props.id;
this.name = props.name;
this.color = props.color;
}
static fromEntity(label: Label): LabelViewModel {
return new LabelViewModel({
id: label.id,
name: label.name,
color: ColorViewModel.fromEntity(label.color)
});
}
}