fix:delete profileAvatar
All checks were successful
Build & Deploy on Dev / build (push) Successful in 53s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 53s
This commit is contained in:
parent
e461f43604
commit
633ccd4906
4 changed files with 67 additions and 0 deletions
|
|
@ -8,6 +8,8 @@ import { CreateProfileEmployeeAvatar, ProfileAvatar } from "../entities/ProfileA
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
|
||||
@Route("api/v1/org/profile-employee/avatar")
|
||||
@Tags("ProfileAvatar")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -153,6 +155,18 @@ export class ProfileAvatarEmployeeController extends Controller {
|
|||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
if (_record.isActive) {
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: _record.profileEmployeeId },
|
||||
});
|
||||
if (profile) {
|
||||
profile.avatar = "";
|
||||
profile.avatarName = "";
|
||||
await this.profileRepository.save(profile, { data: req });
|
||||
}
|
||||
}
|
||||
|
||||
await new CallAPI().DeleteFile(req, `${_record?.avatar}/${_record?.avatarName}`);
|
||||
}
|
||||
if (!_record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue