ปรับ Response DPIS Controller
This commit is contained in:
parent
354d29e93b
commit
09a90aeab5
1 changed files with 165 additions and 198 deletions
|
|
@ -1,24 +1,68 @@
|
||||||
import {
|
import { Controller, Example, Get, Path, Response, Route, SuccessResponse, Tags } from "tsoa";
|
||||||
Controller,
|
|
||||||
Example,
|
|
||||||
Get,
|
|
||||||
Path,
|
|
||||||
Response,
|
|
||||||
Route,
|
|
||||||
Security,
|
|
||||||
SuccessResponse,
|
|
||||||
Tags,
|
|
||||||
} from "tsoa";
|
|
||||||
|
|
||||||
|
import { DateTime } from "@elastic/elasticsearch/lib/api/types";
|
||||||
|
import { Double } from "typeorm";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
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";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
|
||||||
|
interface DPISResponse {
|
||||||
|
status: number;
|
||||||
|
message: string;
|
||||||
|
result?: DPISResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DPISResult {
|
||||||
|
citizenId: string;
|
||||||
|
prefix: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
gender: string;
|
||||||
|
physicalStatus: string;
|
||||||
|
QualityWorkforce: boolean;
|
||||||
|
birthDate: DateTime;
|
||||||
|
dateAppoint: DateTime;
|
||||||
|
dateStart: DateTime;
|
||||||
|
dateRetire: DateTime;
|
||||||
|
isLeave: boolean;
|
||||||
|
isProbation: boolean;
|
||||||
|
leaveReason: string;
|
||||||
|
positionLevel: string;
|
||||||
|
positionType: string;
|
||||||
|
educations: ProfileEducationResult[];
|
||||||
|
leaves: ProfileLeaveResult[];
|
||||||
|
salaries: ProfileSalaryResult[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProfileLeaveResult {
|
||||||
|
dateLeaveStart: DateTime;
|
||||||
|
dateLeaveEnd: DateTime;
|
||||||
|
leaveType: string;
|
||||||
|
totalLeave: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProfileEducationResult {
|
||||||
|
country: string;
|
||||||
|
degree: string;
|
||||||
|
field: string;
|
||||||
|
institute: string;
|
||||||
|
educationLevel: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProfileSalaryResult {
|
||||||
|
posNo: string;
|
||||||
|
position: string;
|
||||||
|
positionType: string;
|
||||||
|
positionLevel: string;
|
||||||
|
amount: Double;
|
||||||
|
positionSalaryAmount: Double;
|
||||||
|
monthSalaryAmount: Double;
|
||||||
|
}
|
||||||
|
|
||||||
@Route("api/v1/dpis")
|
@Route("api/v1/dpis")
|
||||||
@Tags("DPIS")
|
@Tags("DPIS")
|
||||||
@Security("bearerAuth")
|
// @Security("bearerAuth")
|
||||||
@Response(
|
@Response(
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||||
|
|
@ -28,179 +72,86 @@ export class DPISController extends Controller {
|
||||||
private profileRepo = AppDataSource.getRepository(Profile);
|
private profileRepo = AppDataSource.getRepository(Profile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. API Get Profile จาก เลขประจำตัวประชาชน
|
* แสดงข้อมูลข้าราชการจากเลขประจำตัวประชาชน
|
||||||
*
|
*
|
||||||
* @summary 1. API Get Profile จาก เลขประจำตัวประชาชน
|
* @summary แสดงข้อมูลข้าราชการจากเลขประจำตัวประชาชน
|
||||||
*
|
*
|
||||||
* @param {string} citizenId เลขประจำตัวประชาชน
|
* @param {string} citizenId เลขประจำตัวประชาชน
|
||||||
*
|
*
|
||||||
* @returns ข้อมูลขปงข้าราชการที่ค้นหาพบในระบบ
|
* @returns ข้อมูลของข้าราชการที่ค้นหาพบในระบบ
|
||||||
*/
|
*/
|
||||||
@Get("{citizenId}")
|
@Get("{citizenId}")
|
||||||
@Example({
|
@Example({
|
||||||
id: "08dc4c9f-2710-4e98-8340-c9f2a65467db",
|
status: 200,
|
||||||
avatar: null,
|
message: "Success",
|
||||||
avatarName: null,
|
result: {
|
||||||
rank: null,
|
citizenId: "1103700765894",
|
||||||
prefix: "นาย",
|
prefix: "นาย",
|
||||||
firstName: "สุรศักดิ์",
|
firstName: "สุรศักดิ์",
|
||||||
lastName: "จันทร์ศรี",
|
lastName: "จันทร์ศรี",
|
||||||
citizenId: "1103700765894",
|
|
||||||
position: "เจ้าพนักงานสาธารณสุข",
|
|
||||||
posLevelId: "1526d9d3-d8b1-43ab-81b5-a84dfbe08262",
|
|
||||||
email: "userUat43@test.test",
|
|
||||||
phone: null,
|
|
||||||
keycloak: "bac99314-8163-4671-9af6-cf994167e939",
|
|
||||||
isProbation: false,
|
|
||||||
isLeave: false,
|
|
||||||
leaveReason: null,
|
|
||||||
dateRetire: "2055-05-06T17:00:00.000Z",
|
|
||||||
dateAppoint: "2022-11-24T17:00:00.000Z",
|
|
||||||
dateRetireLaw: "2055-09-29T17:00:00.000Z",
|
|
||||||
dateStart: "2022-11-24T17:00:00.000Z",
|
|
||||||
govAgeAbsent: 0,
|
|
||||||
govAgePlus: 0,
|
|
||||||
birthDate: "1995-05-06T17:00:00.000Z",
|
|
||||||
reasonSameDate: null,
|
|
||||||
telephoneNumber: "990686659",
|
|
||||||
nationality: "ไทย",
|
|
||||||
gender: "หญิง",
|
gender: "หญิง",
|
||||||
relationship: "โสด",
|
physicalStatus: "ปกติ",
|
||||||
religion: "พุทธ",
|
QualityWorkforce: true,
|
||||||
bloodGroup: null,
|
birthDate: "1995-05-06T17:00:00.000Z",
|
||||||
registrationAddress: "21/1 หมู่ที่ 2",
|
dateAppoint: "2022-11-24T17:00:00.000Z",
|
||||||
registrationProvinceId: "24bf701c-33d6-436e-ad49-6f82bb3ae029",
|
dateStart: "2022-11-24T17:00:00.000Z",
|
||||||
registrationDistrictId: "34bf701c-33d6-436e-ad49-6f82bb3b0642",
|
dateRetire: "2055-05-06T17:00:00.000Z",
|
||||||
registrationSubDistrictId: "44bf701c-33d6-436e-ad49-6f82bb3b3427",
|
isLeave: false,
|
||||||
registrationZipCode: "22110",
|
isProbation: false,
|
||||||
currentAddress: "21/1 หมู่ที่ 2",
|
leaveReason: null,
|
||||||
currentProvinceId: "24bf701c-33d6-436e-ad49-6f82bb3ae029",
|
positionLevel: "ปฏิบัติงาน",
|
||||||
currentSubDistrictId: "44bf701c-33d6-436e-ad49-6f82bb3b3427",
|
positionType: "ทั่วไป",
|
||||||
currentZipCode: "22110",
|
educations: [],
|
||||||
dutyTimeId: null,
|
salaries: [
|
||||||
dutyTimeEffectiveDate: null,
|
|
||||||
posLevel: {
|
|
||||||
id: "1526d9d3-d8b1-43ab-81b5-a84dfbe08262",
|
|
||||||
createdAt: "2024-01-26T05:42:53.761Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-01-26T05:42:53.761Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
posLevelName: "ปฏิบัติงาน",
|
|
||||||
posLevelRank: 1,
|
|
||||||
posLevelAuthority: null,
|
|
||||||
posTypeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe08061",
|
|
||||||
},
|
|
||||||
posType: {
|
|
||||||
id: "1526d9d3-d8b1-43ab-81b5-a84dfbe08061",
|
|
||||||
createdAt: "2024-01-26T05:42:53.761Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-08-25T09:41:14.000Z",
|
|
||||||
lastUpdateUserId: "01378019-5286-4e1d-ae43-826b648af4aa",
|
|
||||||
createdFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
lastUpdateFullName: "Super Admin",
|
|
||||||
posTypeName: "ทั่วไป",
|
|
||||||
posTypeRank: 1,
|
|
||||||
},
|
|
||||||
profileSalary: [
|
|
||||||
{
|
{
|
||||||
id: "eef6d0b6-ef64-4389-b497-c74a62e5f334",
|
|
||||||
createdAt: "2024-08-22T02:23:57.193Z",
|
|
||||||
createdUserId: "94ba986d-f871-46a2-be92-46c0cbf0bc56",
|
|
||||||
lastUpdatedAt: "2024-08-22T02:23:57.193Z",
|
|
||||||
lastUpdateUserId: "94ba986d-f871-46a2-be92-46c0cbf0bc56",
|
|
||||||
createdFullName: "กานต์พิชชา นาคศรี",
|
|
||||||
lastUpdateFullName: "กานต์พิชชา นาคศรี",
|
|
||||||
profileId: "08dc4c9f-2710-4e98-8340-c9f2a65467db",
|
|
||||||
profileEmployeeId: null,
|
|
||||||
date: "2024-08-22T09:23:18.000Z",
|
|
||||||
posNo: "ขพน.65",
|
posNo: "ขพน.65",
|
||||||
position: "เจ้าพนักงานสาธารณสุข",
|
position: "เจ้าพนักงานสาธารณสุข",
|
||||||
positionLine: "ปฏิบัติงานสาธารณสุข",
|
|
||||||
positionPathSide: null,
|
|
||||||
positionExecutive: null,
|
|
||||||
positionType: "ทั่วไป",
|
positionType: "ทั่วไป",
|
||||||
positionLevel: "ปฏิบัติงาน",
|
positionLevel: "ปฏิบัติงาน",
|
||||||
amount: 11860,
|
amount: 11860,
|
||||||
positionSalaryAmount: 0,
|
positionSalaryAmount: 0,
|
||||||
mouthSalaryAmount: 0,
|
monthSalaryAmount: 0,
|
||||||
refCommandNo: null,
|
|
||||||
templateDoc: "ปรับโครงสร้าง",
|
|
||||||
order: 3,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "916fcf0c-f0d5-4efb-af46-0f1942de5c19",
|
|
||||||
createdAt: "2024-06-27T22:01:25.959Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-06-27T23:24:50.219Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "โกศล สิงหนาท",
|
|
||||||
lastUpdateFullName: "โกศล สิงหนาท",
|
|
||||||
profileId: "08dc4c9f-2710-4e98-8340-c9f2a65467db",
|
|
||||||
profileEmployeeId: null,
|
|
||||||
date: "2023-03-31T17:00:00.000Z",
|
|
||||||
posNo: "ขพน.65",
|
posNo: "ขพน.65",
|
||||||
position:
|
position:
|
||||||
"เจ้าพนักงานสาธารณสุขปฏิบัติงาน ฝ่ายสิ่งแวดล้อมและสุขาภิบาล สำนักงานเขตพระนคร\n(ทดลองปฏิบัติหน้าที่ราชการ)",
|
"เจ้าพนักงานสาธารณสุขปฏิบัติงาน ฝ่ายสิ่งแวดล้อมและสุขาภิบาล สำนักงานเขตพระนคร\n(ทดลองปฏิบัติหน้าที่ราชการ)",
|
||||||
positionLine: null,
|
|
||||||
positionPathSide: null,
|
|
||||||
positionExecutive: null,
|
|
||||||
positionType: "ทั่วไป",
|
positionType: "ทั่วไป",
|
||||||
positionLevel: "ปฏิบัติงาน",
|
positionLevel: "ปฏิบัติงาน",
|
||||||
amount: 11860,
|
amount: 11860,
|
||||||
positionSalaryAmount: 0,
|
positionSalaryAmount: 0,
|
||||||
mouthSalaryAmount: 0,
|
monthSalaryAmount: 0,
|
||||||
refCommandNo: null,
|
|
||||||
templateDoc: "เลื่อนขั้นเงินเดือน คำสั่ง ขพน.ที่ 159/2566 ลว. 6 มิ.ย. 2566",
|
|
||||||
order: 2,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "161bea25-0451-4eff-bbfd-709e88a1700f",
|
|
||||||
createdAt: "2024-06-27T22:01:25.881Z",
|
|
||||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
lastUpdatedAt: "2024-06-27T23:24:50.219Z",
|
|
||||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
|
||||||
createdFullName: "โกศล สิงหนาท",
|
|
||||||
lastUpdateFullName: "โกศล สิงหนาท",
|
|
||||||
profileId: "08dc4c9f-2710-4e98-8340-c9f2a65467db",
|
|
||||||
profileEmployeeId: null,
|
|
||||||
date: "2022-11-24T17:00:00.000Z",
|
|
||||||
posNo: "ขพน.65",
|
posNo: "ขพน.65",
|
||||||
position:
|
position:
|
||||||
"เจ้าพนักงานสาธารณสุขปฏิบัติงาน ฝ่ายสิ่งแวดล้อมและสุขาภิบาล สำนักงานเขตพระนคร\n(ทดลองปฏิบัติหน้าที่ราชการ)",
|
"เจ้าพนักงานสาธารณสุขปฏิบัติงาน ฝ่ายสิ่งแวดล้อมและสุขาภิบาล สำนักงานเขตพระนคร\n(ทดลองปฏิบัติหน้าที่ราชการ)",
|
||||||
positionLine: null,
|
|
||||||
positionPathSide: null,
|
|
||||||
positionExecutive: null,
|
|
||||||
positionType: "ทั่วไป",
|
positionType: "ทั่วไป",
|
||||||
positionLevel: "ปฏิบัติงาน",
|
positionLevel: "ปฏิบัติงาน",
|
||||||
amount: 11500,
|
amount: 11500,
|
||||||
positionSalaryAmount: 0,
|
positionSalaryAmount: 0,
|
||||||
mouthSalaryAmount: 0,
|
monthSalaryAmount: 0,
|
||||||
refCommandNo: null,
|
|
||||||
templateDoc:
|
|
||||||
"บรรจุและแต่งตั้งผู้สอบแข่งขันได้ คำสั่ง ขพน.ที่ 374/2565 ลว. 29 พ.ย. 2565 โดยมีเงื่อนไขว่าต้องปฏิบัติงานให้กรุงเทพมหานครเป็นระยะเวลาไม่น้อยกว่า 5 ปี นับแต่วันที่ได้รับการบรรจุและแต่งตั้ง \nโดยห้ามโอนไปหน่วยงานหรือส่วนราชการอื่น เว้นแต่ลาออกจากราชการ\n",
|
|
||||||
order: 1,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
profileInsignia: [],
|
leaves: [],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
async GetProfileCitizenIdAsync(@Path() citizenId: string) {
|
async GetProfileCitizenIdAsync(@Path() citizenId: string): Promise<DPISResponse> {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
relations: {
|
relations: {
|
||||||
posLevel: true,
|
posLevel: true,
|
||||||
posType: true,
|
posType: true,
|
||||||
profileSalary: true,
|
profileSalary: true,
|
||||||
profileInsignias: true,
|
|
||||||
profileEducations: true,
|
profileEducations: true,
|
||||||
|
profileLeaves: true,
|
||||||
},
|
},
|
||||||
where: { citizenId: citizenId },
|
where: { citizenId: citizenId },
|
||||||
order: {
|
order: {
|
||||||
profileSalary: {
|
profileSalary: {
|
||||||
date: "DESC",
|
date: "DESC",
|
||||||
},
|
},
|
||||||
profileInsignias: {
|
profileLeaves: {
|
||||||
receiveDate: "DESC",
|
dateLeaveStart: "ASC",
|
||||||
},
|
},
|
||||||
profileEducations: {
|
profileEducations: {
|
||||||
degree: "ASC",
|
degree: "ASC",
|
||||||
|
|
@ -209,45 +160,61 @@ export class DPISController extends Controller {
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
||||||
const mapProfile = {
|
const mapProfile: DPISResult = {
|
||||||
citizenId: profile.citizenId,
|
citizenId: profile.citizenId,
|
||||||
prefix: profile.prefix,
|
prefix: profile.prefix,
|
||||||
firstName: profile.firstName,
|
firstName: profile.firstName,
|
||||||
lastName: profile.lastName,
|
lastName: profile.lastName,
|
||||||
rank: profile.rank,
|
|
||||||
position: profile.position,
|
|
||||||
isProbation: profile.isProbation,
|
|
||||||
isLeave: profile.isLeave,
|
|
||||||
leaveReason: profile.leaveReason,
|
|
||||||
dateRetire: profile.dateRetire,
|
|
||||||
dateAppoint: profile.dateAppoint,
|
|
||||||
dateRetireLaw: profile.dateRetireLaw,
|
|
||||||
dateStart: profile.dateStart,
|
|
||||||
birthDate: profile.birthDate,
|
|
||||||
telephoneNumber: profile.telephoneNumber,
|
|
||||||
nationality: profile.nationality,
|
|
||||||
gender: profile.gender,
|
gender: profile.gender,
|
||||||
relationship: profile.relationship,
|
physicalStatus: "ปกติ",
|
||||||
religion: profile.religion,
|
QualityWorkforce: true,
|
||||||
bloodGroup: profile.bloodGroup,
|
birthDate: profile.birthDate,
|
||||||
registrationAddress: profile.registrationAddress,
|
dateAppoint: profile.dateAppoint,
|
||||||
registrationProvinceId: profile.registrationProvinceId,
|
dateStart: profile.dateStart,
|
||||||
registrationDistrictId: profile.registrationDistrictId,
|
dateRetire: profile.dateRetire,
|
||||||
registrationSubDistrictId: profile.registrationSubDistrictId,
|
isLeave: profile.isLeave,
|
||||||
registrationZipCode: profile.registrationZipCode,
|
isProbation: profile.isProbation,
|
||||||
currentAddress: profile.currentAddress,
|
leaveReason: profile.leaveReason,
|
||||||
currentProvinceId: profile.currentProvinceId,
|
positionLevel: profile.posLevel ? profile.posLevel.posLevelName : "",
|
||||||
currentSubDistrictId: profile.currentSubDistrictId,
|
positionType: profile.posType ? profile.posType.posTypeName : "",
|
||||||
currentZipCode: profile.currentZipCode,
|
|
||||||
dutyTimeId: profile.dutyTimeId,
|
// educations
|
||||||
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
|
educations: profile.profileEducations.map((item) => {
|
||||||
posLevel: profile.posLevel ? profile.posLevel : null,
|
return {
|
||||||
posType: profile.posType ? profile.posType : null,
|
country: item.country,
|
||||||
profileSalary: profile.profileSalary,
|
degree: item.degree,
|
||||||
profileInsignia: profile.profileInsignias,
|
field: item.field,
|
||||||
profileEducation: profile.profileEducations,
|
institute: item.institute,
|
||||||
|
educationLevel: item.educationLevel,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
|
salaries: profile.profileSalary.map((item) => {
|
||||||
|
return {
|
||||||
|
posNo: item.posNo,
|
||||||
|
position: item.position,
|
||||||
|
positionType: item.positionType,
|
||||||
|
positionLevel: item.positionLevel,
|
||||||
|
amount: item.amount,
|
||||||
|
positionSalaryAmount: item.positionSalaryAmount,
|
||||||
|
monthSalaryAmount: item.mouthSalaryAmount,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
|
leaves: profile.profileLeaves.map((item) => {
|
||||||
|
return {
|
||||||
|
dateLeaveStart: item.dateLeaveStart,
|
||||||
|
dateLeaveEnd: item.dateLeaveEnd,
|
||||||
|
leaveType: item.leaveType ? item.leaveType.name : "",
|
||||||
|
totalLeave: item.totalLeave,
|
||||||
|
};
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
return new HttpSuccess(mapProfile);
|
return {
|
||||||
|
status: 200,
|
||||||
|
message: "Success",
|
||||||
|
result: mapProfile,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue