up image emp
This commit is contained in:
parent
b153c73036
commit
9020e5036b
1 changed files with 32 additions and 1 deletions
|
|
@ -303,7 +303,10 @@ export class ProfileEmployeeController extends Controller {
|
|||
// "telephoneNumber",
|
||||
// "avatar",
|
||||
// ],
|
||||
relations: ["currentSubDistrict", "currentDistrict", "currentProvince"],
|
||||
relations: ["currentSubDistrict", "currentDistrict", "currentProvince", "profileAvatars"],
|
||||
order: {
|
||||
profileAvatars: { createdAt: "DESC" },
|
||||
},
|
||||
where: { id: id },
|
||||
});
|
||||
if (profiles) {
|
||||
|
|
@ -313,6 +316,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
}
|
||||
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
let ImgUrl: any;
|
||||
let _ImgUrl: any = [];
|
||||
if (profiles?.avatar != null && profiles?.avatarName != null) {
|
||||
// await new CallAPI()
|
||||
// .GetData(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
|
||||
|
|
@ -322,6 +326,26 @@ export class ProfileEmployeeController extends Controller {
|
|||
// .catch();
|
||||
let req_: any = req;
|
||||
const token_ = "Bearer " + req_.headers.authorization.replace("Bearer ", "");
|
||||
|
||||
await Promise.all(
|
||||
await profiles.profileAvatars.slice(-7).map(async (x, i) => {
|
||||
if (x == null) {
|
||||
_ImgUrl[i] = null;
|
||||
} else {
|
||||
const url = process.env.API_URL + `/salary/file/${x?.avatar}/${x?.avatarName}`;
|
||||
try {
|
||||
const response_ = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `${token_}`,
|
||||
"Content-Type": "application/json",
|
||||
api_key: process.env.API_KEY,
|
||||
},
|
||||
});
|
||||
_ImgUrl[i] = response_.data.downloadUrl;
|
||||
} catch {}
|
||||
}
|
||||
}),
|
||||
);
|
||||
const url = process.env.API_URL + `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`;
|
||||
try {
|
||||
const response_ = await axios.get(url, {
|
||||
|
|
@ -497,6 +521,13 @@ export class ProfileEmployeeController extends Controller {
|
|||
ImgUrl: ImgUrl
|
||||
? ImgUrl
|
||||
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
||||
ImgUrl1: _ImgUrl[0] ? _ImgUrl[0] : null,
|
||||
ImgUrl2: _ImgUrl[1] ? _ImgUrl[1] : null,
|
||||
ImgUrl3: _ImgUrl[2] ? _ImgUrl[2] : null,
|
||||
ImgUrl4: _ImgUrl[3] ? _ImgUrl[3] : null,
|
||||
ImgUrl5: _ImgUrl[4] ? _ImgUrl[4] : null,
|
||||
ImgUrl6: _ImgUrl[5] ? _ImgUrl[5] : null,
|
||||
ImgUrl7: _ImgUrl[6] ? _ImgUrl[6] : null,
|
||||
};
|
||||
|
||||
const certs = await this.certificateRepository.find({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue