edit phoneNUmber add field email
This commit is contained in:
parent
bd3cb33a5e
commit
dca044eeae
2 changed files with 100 additions and 0 deletions
|
|
@ -6362,4 +6362,97 @@ export class ProfileController extends Controller {
|
||||||
);
|
);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขเบอร์โทรศัพท์
|
||||||
|
*
|
||||||
|
* @summary แก้ไขเบอร์โทรศัพท์ (USER)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Put("updatePhoneNumber/user")
|
||||||
|
async updatePhoneNumber(@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
phone: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const profile = await this.profileRepo.findOne({
|
||||||
|
relations: {
|
||||||
|
posLevel: true,
|
||||||
|
posType: true,
|
||||||
|
},
|
||||||
|
where: { keycloak: request.user.sub },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
|
const history = new ProfileHistory();
|
||||||
|
|
||||||
|
Object.assign(profile, body);
|
||||||
|
Object.assign(history, { ...profile, id: undefined });
|
||||||
|
|
||||||
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
|
history.lastUpdateUserId = request.user.sub;
|
||||||
|
history.lastUpdateFullName = request.user.name;
|
||||||
|
history.createdUserId = request.user.sub;
|
||||||
|
history.createdFullName = request.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
this.profileRepo.save(profile, { data: request }),
|
||||||
|
this.profileHistoryRepo.save(history, { data: request }),
|
||||||
|
]);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้ไขอีเมล
|
||||||
|
*
|
||||||
|
* @summary แก้ไขอีเมล (USER)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Put("updateEmail/user")
|
||||||
|
async updateEmail(@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
email: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const profile = await this.profileRepo.findOne({
|
||||||
|
relations: {
|
||||||
|
posLevel: true,
|
||||||
|
posType: true,
|
||||||
|
},
|
||||||
|
where: { keycloak: request.user.sub },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
|
const history = new ProfileHistory();
|
||||||
|
|
||||||
|
Object.assign(profile, body);
|
||||||
|
Object.assign(history, { ...profile, id: undefined });
|
||||||
|
|
||||||
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
|
history.lastUpdateUserId = request.user.sub;
|
||||||
|
history.lastUpdateFullName = request.user.name;
|
||||||
|
history.createdUserId = request.user.sub;
|
||||||
|
history.createdFullName = request.user.name;
|
||||||
|
history.createdAt = new Date();
|
||||||
|
history.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
this.profileRepo.save(profile, { data: request }),
|
||||||
|
this.profileHistoryRepo.save(history, { data: request }),
|
||||||
|
]);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,13 @@ export class Profile extends EntityBase {
|
||||||
})
|
})
|
||||||
email: string;
|
email: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "สถานะอีเมล",//VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
statusEmail: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
length: 20,
|
length: 20,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue