blog/frontend/src/lib/label/adapter/gateway/updateLabelRequestDto.ts
2025-10-15 22:01:25 +08:00

27 lines
635 B
TypeScript

import { ColorDto } from '$lib/label/adapter/gateway/colorDto';
import type { UpdateLabelParams } from '$lib/label/application/gateway/labelRepository';
export class UpdateLabelRequestDto {
readonly name: string;
readonly color: ColorDto;
private constructor(props: { name: string; color: ColorDto }) {
this.name = props.name;
this.color = props.color;
}
static fromParams(params: UpdateLabelParams): UpdateLabelRequestDto {
return new UpdateLabelRequestDto({
name: params.name,
color: ColorDto.fromEntity(params.color),
});
}
toJson() {
return {
name: this.name,
color: this.color.toJson(),
};
}
}