34 lines
926 B
TypeScript
34 lines
926 B
TypeScript
/**
|
|
* 更新个人资料请求 DTO
|
|
*/
|
|
import {
|
|
UpdateProfileRequestSchema,
|
|
type UpdateProfileRequestInput,
|
|
type UpdateProfileRequestData,
|
|
} from "@/data/schemas/user/update_profile_request";
|
|
|
|
export class UpdateProfileRequest {
|
|
declare readonly username: string;
|
|
declare readonly nickname: string;
|
|
declare readonly preferredLanguage: string;
|
|
declare readonly currentMood: string;
|
|
|
|
private constructor(input: UpdateProfileRequestInput) {
|
|
const data = UpdateProfileRequestSchema.parse(input);
|
|
Object.assign(this, data);
|
|
Object.freeze(this);
|
|
}
|
|
|
|
static from(input: UpdateProfileRequestInput): UpdateProfileRequest {
|
|
return new UpdateProfileRequest(input);
|
|
}
|
|
|
|
static fromJson(json: unknown): UpdateProfileRequest {
|
|
return UpdateProfileRequest.from(json as UpdateProfileRequestInput);
|
|
}
|
|
|
|
toJson(): UpdateProfileRequestData {
|
|
return UpdateProfileRequestSchema.parse(this);
|
|
}
|
|
}
|