add org search
This commit is contained in:
parent
f770b9214a
commit
6ab149f7a3
1 changed files with 59 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import { Controller, Example, Get, Path, Response, Route, SuccessResponse, Tags
|
||||||
import { DateTime } from "@elastic/elasticsearch/lib/api/types";
|
import { DateTime } from "@elastic/elasticsearch/lib/api/types";
|
||||||
import { Double } from "typeorm";
|
import { Double } from "typeorm";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { Profile } from "../entities/Profile";
|
import { Profile } from "../entities/Profile";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
|
@ -12,7 +13,15 @@ interface DPISResponse {
|
||||||
* สถานะ
|
* สถานะ
|
||||||
*/
|
*/
|
||||||
status: number;
|
status: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ข้อความตอบกลับ
|
||||||
|
*/
|
||||||
message: string;
|
message: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ผลลัพธ์การค้นหา
|
||||||
|
*/
|
||||||
result?: DPISResult;
|
result?: DPISResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,6 +45,7 @@ interface DPISResult {
|
||||||
educations: ProfileEducationResult[];
|
educations: ProfileEducationResult[];
|
||||||
leaves: ProfileLeaveResult[];
|
leaves: ProfileLeaveResult[];
|
||||||
salaries: ProfileSalaryResult[];
|
salaries: ProfileSalaryResult[];
|
||||||
|
organization: ProfileOrgResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProfileLeaveResult {
|
interface ProfileLeaveResult {
|
||||||
|
|
@ -45,6 +55,33 @@ interface ProfileLeaveResult {
|
||||||
totalLeave: number;
|
totalLeave: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ProfileOrgResult {
|
||||||
|
/**
|
||||||
|
* ผลลัพธ์การค้นหา
|
||||||
|
*/
|
||||||
|
orgRootName: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* กองระดับ 1
|
||||||
|
*/
|
||||||
|
orgChild1Name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* กองระดับ 2
|
||||||
|
*/
|
||||||
|
orgChild2Name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* กองระดับ 3
|
||||||
|
*/
|
||||||
|
orgChild3Name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* กองระดับ 4
|
||||||
|
*/
|
||||||
|
orgChild4Name: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface ProfileEducationResult {
|
interface ProfileEducationResult {
|
||||||
country: string;
|
country: string;
|
||||||
degree: string;
|
degree: string;
|
||||||
|
|
@ -73,6 +110,7 @@ interface ProfileSalaryResult {
|
||||||
@SuccessResponse(HttpStatus.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatus.OK, "สำเร็จ")
|
||||||
export class DPISController extends Controller {
|
export class DPISController extends Controller {
|
||||||
private profileRepo = AppDataSource.getRepository(Profile);
|
private profileRepo = AppDataSource.getRepository(Profile);
|
||||||
|
private orgRevisionRepo = AppDataSource.getRepository(OrgRevision);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* แสดงข้อมูลข้าราชการจากเลขประจำตัวประชาชน
|
* แสดงข้อมูลข้าราชการจากเลขประจำตัวประชาชน
|
||||||
|
|
@ -104,6 +142,13 @@ export class DPISController extends Controller {
|
||||||
leaveReason: null,
|
leaveReason: null,
|
||||||
positionLevel: "ปฏิบัติงาน",
|
positionLevel: "ปฏิบัติงาน",
|
||||||
positionType: "ทั่วไป",
|
positionType: "ทั่วไป",
|
||||||
|
organization: {
|
||||||
|
orgRootName: "",
|
||||||
|
orgChild1Name: "",
|
||||||
|
orgChild2Name: "",
|
||||||
|
orgChild3Name: "",
|
||||||
|
orgChild4Name: "",
|
||||||
|
},
|
||||||
educations: [],
|
educations: [],
|
||||||
salaries: [
|
salaries: [
|
||||||
{
|
{
|
||||||
|
|
@ -147,8 +192,10 @@ export class DPISController extends Controller {
|
||||||
profileSalary: true,
|
profileSalary: true,
|
||||||
profileEducations: true,
|
profileEducations: true,
|
||||||
profileLeaves: true,
|
profileLeaves: true,
|
||||||
|
current_holders: true,
|
||||||
},
|
},
|
||||||
where: { citizenId: citizenId },
|
where: { citizenId: citizenId },
|
||||||
|
//relations: ["current_holders", "current_holders.orgRoot"],
|
||||||
order: {
|
order: {
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
date: "DESC",
|
date: "DESC",
|
||||||
|
|
@ -162,6 +209,10 @@ export class DPISController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true },
|
||||||
|
});
|
||||||
|
var current_holder = profile.current_holders?.find((x) => x.orgRevisionId == findRevision?.id);
|
||||||
|
|
||||||
const mapProfile: DPISResult = {
|
const mapProfile: DPISResult = {
|
||||||
citizenId: profile.citizenId,
|
citizenId: profile.citizenId,
|
||||||
|
|
@ -181,6 +232,14 @@ export class DPISController extends Controller {
|
||||||
positionLevel: profile.posLevel ? profile.posLevel.posLevelName : "",
|
positionLevel: profile.posLevel ? profile.posLevel.posLevelName : "",
|
||||||
positionType: profile.posType ? profile.posType.posTypeName : "",
|
positionType: profile.posType ? profile.posType.posTypeName : "",
|
||||||
|
|
||||||
|
organization: {
|
||||||
|
orgRootName: current_holder?.orgRoot?.orgRootName || "",
|
||||||
|
orgChild1Name: current_holder?.orgChild1?.orgChild1Name || "",
|
||||||
|
orgChild2Name: current_holder?.orgChild2?.orgChild2Name || "",
|
||||||
|
orgChild3Name: current_holder?.orgChild3?.orgChild3Name || "",
|
||||||
|
orgChild4Name: current_holder?.orgChild4?.orgChild4Name || "",
|
||||||
|
},
|
||||||
|
|
||||||
// educations
|
// educations
|
||||||
educations: profile.profileEducations.map((item) => {
|
educations: profile.profileEducations.map((item) => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue