no message
This commit is contained in:
parent
3ea5ec3486
commit
61899e8431
2 changed files with 27 additions and 21 deletions
|
|
@ -70,18 +70,6 @@ export class ProfileAvatarController extends Controller {
|
|||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
||||
await this.avatarRepository.save(data);
|
||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
|
||||
let fileName = `profile-${data.id}`;
|
||||
|
||||
data.isActive = true;
|
||||
data.avatar = avatar;
|
||||
data.avatarName = fileName;
|
||||
await this.avatarRepository.save(data);
|
||||
profile.avatar = avatar;
|
||||
profile.avatarName = fileName;
|
||||
await this.profileRepository.save(profile);
|
||||
|
||||
const _profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileId },
|
||||
relations: ["profileAvatars"],
|
||||
|
|
@ -97,6 +85,18 @@ export class ProfileAvatarController extends Controller {
|
|||
}),
|
||||
);
|
||||
|
||||
await this.avatarRepository.save(data);
|
||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
|
||||
let fileName = `profile-${data.id}`;
|
||||
|
||||
data.isActive = true;
|
||||
data.avatar = avatar;
|
||||
data.avatarName = fileName;
|
||||
await this.avatarRepository.save(data);
|
||||
profile.avatar = avatar;
|
||||
profile.avatarName = fileName;
|
||||
await this.profileRepository.save(profile);
|
||||
|
||||
return new HttpSuccess({ avatar: avatar, avatarName: fileName });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,21 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
||||
const _profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileEmployeeId },
|
||||
relations: ["profileAvatars"],
|
||||
});
|
||||
|
||||
if (!_profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await Promise.all(
|
||||
_profile.profileAvatars.map(async (item: any) => {
|
||||
item.isActive = false;
|
||||
await this.avatarRepository.save(item);
|
||||
}),
|
||||
);
|
||||
|
||||
await this.avatarRepository.save(data);
|
||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
|
||||
let fileName = `profile-${data.id}`;
|
||||
|
|
@ -85,15 +100,6 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
profile.avatarName = fileName;
|
||||
await this.profileRepository.save(profile);
|
||||
|
||||
const _profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileEmployeeId },
|
||||
relations: ["profileAvatars"],
|
||||
});
|
||||
|
||||
if (!_profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
return new HttpSuccess({ avatar: avatar, avatarName: fileName });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue