fix:delete profileAvatar
All checks were successful
Build & Deploy on Dev / build (push) Successful in 53s

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-01-30 14:47:46 +07:00
parent e461f43604
commit 633ccd4906
4 changed files with 67 additions and 0 deletions

View file

@ -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, "ไม่พบข้อมูล");