diff --git a/src/dto/user/userDetailDto.ts b/src/dto/user/userDetailDto.ts index 894dea2..a9d513e 100644 --- a/src/dto/user/userDetailDto.ts +++ b/src/dto/user/userDetailDto.ts @@ -2,39 +2,50 @@ import { IUser } from '../../models/user'; import { Gender, IUpdateUserDetailReq } from '../../types/user.type'; export class UserDetailDto { - private readonly id: string; - private readonly name: string; - private readonly birthDate: Date; - private readonly gender: Gender; - private readonly phone: string; - private readonly address: string; + private readonly _id: string; + private readonly _name: string; + private readonly _birthDate: Date; + private readonly _gender: Gender; + private readonly _phone: string; + private readonly _address: string; + private readonly _avatarPath: string; - get getId(): string { - return this.id; + get avatarPath(): string { + return this._avatarPath; } - get getName(): string { - return this.name; + + get id(): string { + return this._id; } - get getBirthDate(): Date { - return this.birthDate; + + get name(): string { + return this._name; } - get getGender(): string { - return this.gender; + + get birthDate(): Date { + return this._birthDate; } - get getPhone(): string { - return this.phone; + + get gender(): Gender { + return this._gender; } - get getAddress(): string { - return this.address; + + get phone(): string { + return this._phone; + } + + get address(): string { + return this._address; } constructor(req: IUpdateUserDetailReq) { - this.id = (req.user as IUser).id.toString(); - const { name, birthDate, gender, phone, address } = req.body; - this.name = name; - this.birthDate = birthDate; - this.gender = gender; - this.phone = phone; - this.address = address; + this._id = (req.user as IUser).id.toString(); + const { name, birthDate, gender, phone, address, avatarPath } = req.body; + this._name = name; + this._birthDate = birthDate; + this._gender = gender; + this._phone = phone; + this._address = address; + this._avatarPath = avatarPath; } } diff --git a/src/repository/userRepository.ts b/src/repository/userRepository.ts index da3e4d5..3d45bc8 100644 --- a/src/repository/userRepository.ts +++ b/src/repository/userRepository.ts @@ -52,13 +52,14 @@ export class UserRepository { public async updateUserDetail(userDetailDto: UserDetailDto) { return UserModel.findByIdAndUpdate( - { _id: new Types.ObjectId(userDetailDto.getId) }, + { _id: new Types.ObjectId(userDetailDto.id) }, { - name: userDetailDto.getName, - birthDate: userDetailDto.getBirthDate, - gender: userDetailDto.getGender, - phone: userDetailDto.getPhone, - address: userDetailDto.getAddress, + name: userDetailDto.name, + birthDate: userDetailDto.birthDate, + gender: userDetailDto.gender, + phone: userDetailDto.phone, + address: userDetailDto.address, + avatarPath: userDetailDto.avatarPath, }, updateOptions, ); diff --git a/src/routes/userRoute.ts b/src/routes/userRoute.ts index 557a45b..5248909 100644 --- a/src/routes/userRoute.ts +++ b/src/routes/userRoute.ts @@ -54,7 +54,7 @@ export class UserRoute extends BaseRoute { "gender": "none", "phone": "0912345678", "address": "aaaabbb", - "imgUrl": "" + "avatarPath": "avatarPath" } } */ diff --git a/src/types/user.type.ts b/src/types/user.type.ts index 18018a7..49c23f9 100644 --- a/src/types/user.type.ts +++ b/src/types/user.type.ts @@ -109,5 +109,6 @@ export interface IUpdateUserDetailReq extends IUserReq { gender: Gender; phone: string; address: string; + avatarPath: string; }; }