hrms-api-org/src/controllers/DPISController.ts
Suphonchai Phoonsawat 4852131651 add dpis controller
2024-10-07 14:53:27 +07:00

253 lines
11 KiB
TypeScript

import {
Controller,
Example,
Get,
Path,
Response,
Route,
Security,
SuccessResponse,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { Profile } from "../entities/Profile";
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
@Route("api/v1/dpis")
@Tags("DPIS")
@Security("bearerAuth")
@Response(
HttpStatus.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
)
@SuccessResponse(HttpStatus.OK, "สำเร็จ")
export class DPISController extends Controller {
private profileRepo = AppDataSource.getRepository(Profile);
/**
* 1. API Get Profile จาก เลขประจำตัวประชาชน
*
* @summary 1. API Get Profile จาก เลขประจำตัวประชาชน
*
* @param {string} citizenId เลขประจำตัวประชาชน
*
* @returns ข้อมูลขปงข้าราชการที่ค้นหาพบในระบบ
*/
@Get("{citizenId}")
@Example({
id: "08dc4c9f-2710-4e98-8340-c9f2a65467db",
avatar: null,
avatarName: null,
rank: null,
prefix: "นาย",
firstName: "สุรศักดิ์",
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: "หญิง",
relationship: "โสด",
religion: "พุทธ",
bloodGroup: null,
registrationAddress: "21/1 หมู่ที่ 2",
registrationProvinceId: "24bf701c-33d6-436e-ad49-6f82bb3ae029",
registrationDistrictId: "34bf701c-33d6-436e-ad49-6f82bb3b0642",
registrationSubDistrictId: "44bf701c-33d6-436e-ad49-6f82bb3b3427",
registrationZipCode: "22110",
currentAddress: "21/1 หมู่ที่ 2",
currentProvinceId: "24bf701c-33d6-436e-ad49-6f82bb3ae029",
currentSubDistrictId: "44bf701c-33d6-436e-ad49-6f82bb3b3427",
currentZipCode: "22110",
dutyTimeId: null,
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",
position: "เจ้าพนักงานสาธารณสุข",
positionLine: "ปฏิบัติงานสาธารณสุข",
positionPathSide: null,
positionExecutive: null,
positionType: "ทั่วไป",
positionLevel: "ปฏิบัติงาน",
amount: 11860,
positionSalaryAmount: 0,
mouthSalaryAmount: 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",
position:
"เจ้าพนักงานสาธารณสุขปฏิบัติงาน ฝ่ายสิ่งแวดล้อมและสุขาภิบาล สำนักงานเขตพระนคร\n(ทดลองปฏิบัติหน้าที่ราชการ)",
positionLine: null,
positionPathSide: null,
positionExecutive: null,
positionType: "ทั่วไป",
positionLevel: "ปฏิบัติงาน",
amount: 11860,
positionSalaryAmount: 0,
mouthSalaryAmount: 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",
position:
"เจ้าพนักงานสาธารณสุขปฏิบัติงาน ฝ่ายสิ่งแวดล้อมและสุขาภิบาล สำนักงานเขตพระนคร\n(ทดลองปฏิบัติหน้าที่ราชการ)",
positionLine: null,
positionPathSide: null,
positionExecutive: null,
positionType: "ทั่วไป",
positionLevel: "ปฏิบัติงาน",
amount: 11500,
positionSalaryAmount: 0,
mouthSalaryAmount: 0,
refCommandNo: null,
templateDoc:
"บรรจุและแต่งตั้งผู้สอบแข่งขันได้ คำสั่ง ขพน.ที่ 374/2565 ลว. 29 พ.ย. 2565 โดยมีเงื่อนไขว่าต้องปฏิบัติงานให้กรุงเทพมหานครเป็นระยะเวลาไม่น้อยกว่า 5 ปี นับแต่วันที่ได้รับการบรรจุและแต่งตั้ง \nโดยห้ามโอนไปหน่วยงานหรือส่วนราชการอื่น เว้นแต่ลาออกจากราชการ\n",
order: 1,
},
],
profileInsignia: [],
})
async GetProfileCitizenIdAsync(@Path() citizenId: string) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
profileSalary: true,
profileInsignias: true,
profileEducations: true,
},
where: { citizenId: citizenId },
order: {
profileSalary: {
date: "DESC",
},
profileInsignias: {
receiveDate: "DESC",
},
profileEducations: {
degree: "ASC",
},
},
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const mapProfile = {
citizenId: profile.citizenId,
prefix: profile.prefix,
firstName: profile.firstName,
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,
relationship: profile.relationship,
religion: profile.religion,
bloodGroup: profile.bloodGroup,
registrationAddress: profile.registrationAddress,
registrationProvinceId: profile.registrationProvinceId,
registrationDistrictId: profile.registrationDistrictId,
registrationSubDistrictId: profile.registrationSubDistrictId,
registrationZipCode: profile.registrationZipCode,
currentAddress: profile.currentAddress,
currentProvinceId: profile.currentProvinceId,
currentSubDistrictId: profile.currentSubDistrictId,
currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
posLevel: profile.posLevel ? profile.posLevel : null,
posType: profile.posType ? profile.posType : null,
profileSalary: profile.profileSalary,
profileInsignia: profile.profileInsignias,
profileEducation: profile.profileEducations,
};
return new HttpSuccess(mapProfile);
}
}