api getProfile (No token)
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m15s

This commit is contained in:
harid 2026-02-11 11:31:09 +07:00
parent 073da70a68
commit a3d9d40a52
2 changed files with 707 additions and 30 deletions

View file

@ -2345,8 +2345,6 @@ export class OrganizationDotnetController extends Controller {
relations: [
"posLevel",
"posType",
"profileSalary",
"profileInsignias",
"current_holders",
"current_holders.orgRevision",
"current_holders.orgRoot",
@ -2356,14 +2354,6 @@ export class OrganizationDotnetController extends Controller {
"current_holders.orgChild4",
],
where: { id: profileId },
order: {
profileSalary: {
commandDateAffect: "DESC",
},
profileInsignias: {
receiveDate: "DESC",
},
},
});
if (!profile) {
@ -2371,8 +2361,6 @@ export class OrganizationDotnetController extends Controller {
relations: [
"posLevel",
"posType",
"profileSalary",
"profileInsignias",
"current_holders",
"current_holders.orgRevision",
"current_holders.orgRoot",
@ -2382,17 +2370,20 @@ export class OrganizationDotnetController extends Controller {
"current_holders.orgChild4",
],
where: { id: profileId },
order: {
profileSalary: {
commandDateAffect: "DESC",
},
profileInsignias: {
receiveDate: "DESC",
},
},
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const [latestSalary, latestInsignia] = await Promise.all([
this.salaryRepo.findOne({
where: { profileEmployeeId: profile.id },
order: { commandDateAffect: "DESC" },
}),
this.insigniaRepo.findOne({
where: { profileEmployeeId: profile.id },
order: { receiveDate: "DESC" },
}),
]);
const org = {
root:
profile?.current_holders?.find(
@ -2426,7 +2417,7 @@ export class OrganizationDotnetController extends Controller {
)?.orgChild4?.id ?? null,
};
let fullname = "";
let pos = await this.posMasterRepository.findOne({
let pos = await this.empPosMasterRepository.findOne({
relations: ["current_holder"],
where: {
current_holder: Not(IsNull()),
@ -2450,7 +2441,7 @@ export class OrganizationDotnetController extends Controller {
" " +
pos.current_holder.lastName;
} else {
let pos = await this.posMasterRepository.findOne({
let pos = await this.empPosMasterRepository.findOne({
relations: ["current_holder"],
where: {
current_holder: Not(IsNull()),
@ -2473,7 +2464,7 @@ export class OrganizationDotnetController extends Controller {
" " +
pos.current_holder.lastName;
} else {
let pos = await this.posMasterRepository.findOne({
let pos = await this.empPosMasterRepository.findOne({
relations: ["current_holder"],
where: {
current_holder: Not(IsNull()),
@ -2496,7 +2487,7 @@ export class OrganizationDotnetController extends Controller {
" " +
pos.current_holder.lastName;
} else {
let pos = await this.posMasterRepository.findOne({
let pos = await this.empPosMasterRepository.findOne({
relations: ["current_holder"],
where: {
current_holder: Not(IsNull()),
@ -2519,7 +2510,7 @@ export class OrganizationDotnetController extends Controller {
" " +
pos.current_holder.lastName;
} else {
let pos = await this.posMasterRepository.findOne({
let pos = await this.empPosMasterRepository.findOne({
relations: ["current_holder"],
where: {
current_holder: Not(IsNull()),
@ -2689,14 +2680,25 @@ export class OrganizationDotnetController extends Controller {
? ""
: profile.posType?.posTypeShortName + " ") + (profile.posLevel?.posLevelName ?? ""),
posType: profile.posType?.posTypeName ?? null,
profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null,
profileInsignia: profile.profileInsignias.length > 0 ? profile.profileInsignias[0] : null,
profileSalary: latestSalary ?? null,
profileInsignia: latestInsignia ?? null,
profileType: "EMPLOYEE",
};
return new HttpSuccess(mapProfile);
}
const [latestSalary, latestInsignia] = await Promise.all([
this.salaryRepo.findOne({
where: { profileId: profile.id },
order: { commandDateAffect: "DESC" },
}),
this.insigniaRepo.findOne({
where: { profileId: profile.id },
order: { receiveDate: "DESC" },
}),
]);
const org = {
root:
profile?.current_holders?.find(
@ -2991,13 +2993,14 @@ export class OrganizationDotnetController extends Controller {
commander: fullname,
posLevel: profile.posLevel?.posLevelName ?? null,
posType: profile.posType?.posTypeName ?? null,
profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null,
profileInsignia: profile.profileInsignias.length > 0 ? profile.profileInsignias[0] : null,
profileSalary: latestSalary ?? null,
profileInsignia: latestInsignia ?? null,
profileType: "OFFICER",
};
return new HttpSuccess(mapProfile);
}
/**
* 3. API Get Profile citizen Id
*