fix report kk1/kp7 : add field imgUrl

This commit is contained in:
Bright 2024-09-23 11:48:10 +07:00
parent 917ca75eb2
commit 2d5f719fe2
3 changed files with 59 additions and 4 deletions

View file

@ -133,7 +133,15 @@ export class ProfileController extends Controller {
}
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
let ImgUrl: any
if(profile?.avatar != null && profile?.avatarName != null) {
await new CallAPI()
.GetData2(req, `/salary/file/${profile?.avatar}/${profile?.avatarName}`)
.then(async (x) => {
ImgUrl = x.downloadUrl
})
.catch();
}
const province = await this.provinceRepository.findOneBy({
id: profile.registrationProvinceId,
});
@ -241,6 +249,7 @@ export class ProfileController extends Controller {
: "-",
PositionName: profile.position != null ? profile.position : "-",
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
ImgUrl: ImgUrl ? ImgUrl : null
};
return new HttpSuccess(mapData);
@ -272,6 +281,16 @@ export class ProfileController extends Controller {
relations: ["currentSubDistrict", "currentDistrict", "currentProvince"],
where: { id: id },
});
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
let ImgUrl: any
if(profiles?.avatar != null && profiles?.avatarName != null) {
await new CallAPI()
.GetData2(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
.then(async (x) => {
ImgUrl = x.downloadUrl
})
.catch();
}
const profileOc = await this.profileRepo.findOne({
relations: [
"current_holders",
@ -283,7 +302,6 @@ export class ProfileController extends Controller {
],
where: { id: id },
});
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
if (!profileOc) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const orgRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true },
@ -432,6 +450,7 @@ export class ProfileController extends Controller {
? Extension.ToThaiNumber(profiles.currentProvince.name)
: "",
// AvatarId: profiles?.avatar ?? null,
ImgUrl: ImgUrl ? ImgUrl : null
};
const certs = await this.certificateRepository.find({

View file

@ -139,7 +139,15 @@ export class ProfileEmployeeController extends Controller {
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id);
let ImgUrl: any
if(profile?.avatar != null && profile?.avatarName != null) {
await new CallAPI()
.GetData2(req, `/salary/file/${profile?.avatar}/${profile?.avatarName}`)
.then(async (x) => {
ImgUrl = x.downloadUrl
})
.catch();
}
const province = await this.provinceRepository.findOneBy({
id: profile.registrationProvinceId,
});
@ -247,6 +255,7 @@ export class ProfileEmployeeController extends Controller {
: "-",
PositionName: profile.position != null ? profile.position : "-",
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
ImgUrl: ImgUrl ? ImgUrl : null
};
return new HttpSuccess(mapData);
@ -280,6 +289,16 @@ export class ProfileEmployeeController extends Controller {
if (profiles) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profiles.id);
}
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
let ImgUrl: any
if(profiles?.avatar != null && profiles?.avatarName != null) {
await new CallAPI()
.GetData2(req, `/salary/file/${profiles?.avatar}/${profiles?.avatarName}`)
.then(async (x) => {
ImgUrl = x.downloadUrl
})
.catch();
}
const profileOc = await this.profileRepo.findOne({
relations: [
"current_holders",
@ -291,7 +310,6 @@ export class ProfileEmployeeController extends Controller {
],
where: { id: id },
});
if (!profiles) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
if (!profileOc) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const orgRevision = await this.orgRevisionRepo.findOne({
@ -441,6 +459,7 @@ export class ProfileEmployeeController extends Controller {
? Extension.ToThaiNumber(profiles.currentProvince.name)
: "",
// AvatarId: profiles?.avatar ?? null,
ImgUrl: ImgUrl ? ImgUrl : null
};
const certs = await this.certificateRepository.find({

View file

@ -31,6 +31,23 @@ class CallAPI {
throw error;
}
}
//Get (response.data)
public async GetData2(request: any, @Path() path: any) {
const token = request.headers.authorization;
const url = process.env.API_URL + path;
try {
const response = await axios.get(url, {
headers: {
Authorization: `${token}`,
"Content-Type": "application/json",
api_key: process.env.API_KEY,
},
});
return response.data;
} catch (error) {
throw error;
}
}
//Post
public async PostData(request: any, @Path() path: any, sendData: any) {
const token = request.headers.authorization;