add dpis controller

This commit is contained in:
Suphonchai Phoonsawat 2024-10-07 14:53:27 +07:00
parent 497decefe4
commit 4852131651
74 changed files with 606 additions and 336 deletions

View file

@ -1,18 +1,23 @@
AUTH_REALM_URL=http://192.168.1.200:8080/realms/dev
AUTH_PUBLIC_KEY=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1/QAH75nWgiRzWCTrGJv8q2A7z0qggC2IQ9Sva/Ok1RxeGE/ED2m4ELbF5B9MtugyXYGMUBXaKhooMpTE3wyR1OwsUlv/GtYSmMuKUnsSEXklsP8nIq8gZkCvISOVdvIC4ng5aZ5nBcp9cQ3eVbz4dfZcbLzcqLIIkxQmFBK0m1eFL5IdNj8Ac7U4eH4ylOckOu174f35NnFH6wDva6Iic3EXapMcE2BnXXCTajk2dmlWAzH13ybQBgHDfrOtulrmn1CzQxe9WUJes4qX5z72N05KsHvtUObaeN6cb+mIeH36GdysqgAdd2hhKkgUFXwtLPzldtrEc7xVyf3OLEg1QIDAQAB
AUTH_REALM_URL=https://id.frappet.synology.me/realms/bma-ehr
AUTH_PUBLIC_KEY=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvYg0ZJvH6HgNOzyPp7PCvY3bJwD9WdsNn6gZbuvIfqJQZ8iSH1t0p3fgODO/fqwcj9UFeh1bVFOSjuW+JpnPehROqzt81KNl9zLLNXoN4LimReQHaMM3dU7DCbRylgVCouIDvObyjg8G+Cy5lZvFKWym/DPwGVpSdbvDZJ83qxq2dp7GJXS8PhOvA+MB1K009/jW5pBTUwNArLjoFccr+gIYIiOJDg2rYyIF3fDkwyWkuxr6xRt10+BRJytselwy/18kbDuJxVPaapdgTXI6wLzx7HWcDk30n5EvhJEumnIPpRst8gucqNYmB4MH+vsyoxV5WLuO3qmVRzFbtAppRQIDAQAB
AUTH_PREFERRED_MODE=online
AUTH_ACCOUNT_SECRET=qsFwDb5anVoXKKwoeivrByIn9VYWQNRn
APP_HOST=0.0.0.0
APP_PORT=3000
DB_HOST=192.168.1.200
APP_PORT=13001
DB_HOST=192.168.1.80
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=
DB_NAME=dev
KC_URL=http://192.168.1.50:8080
KC_REALM=dev
KC_SERVICE_ACCOUNT_CLIENT_ID=dev-service
KC_SERVICE_ACCOUNT_SECRET=
MANAGEMENT_ROLE=storage_management
DB_PASSWORD=adminVM123
DB_NAME=bma_ehr_organization_demo
KC_URL=https://id.frappet.synology.me
KC_REALM=bma-ehr
KC_SERVICE_ACCOUNT_CLIENT_ID=bma-ehr-dev
KC_SERVICE_ACCOUNT_SECRET=f2mp7Xj4nz6gbgITve9J7AHXZI8dRhOd
API_URL=https://bma-ehr.frappet.synology.me/api/v1
REDIS_HOST=192.168.1.81
REDIS_PORT=6379
ELASTICSEARCH_INDEX=bma-ehr-log-index
ELASTICSEARCH_PROTOCOL=http
ELASTICSEARCH_HOST=192.168.1.40
ELASTICSEARCH_PORT=9200
API_KEY=fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz

View file

@ -12,7 +12,7 @@ All notable changes to this project will be documented in this file.
### 🐛 Bug Fixes
- แก้ชนิด type ที่ reques
- แก้ชนิด type ที่ reques
### ⚙️ Miscellaneous Tasks
@ -37,13 +37,13 @@ All notable changes to this project will be documented in this file.
### 🚜 Refactor
- *(utils)* Merge 2 statement of same conditions
- *(middlewares)* Add type to function parameter auth role
- _(utils)_ Merge 2 statement of same conditions
- _(middlewares)_ Add type to function parameter auth role
- History in database after first edit only
### ⚙️ Miscellaneous Tasks
- *(tsoa-setting)* Update to recursive path
- _(tsoa-setting)_ Update to recursive path
- Add response example
## [1.0.61] - 2024-03-11

View file

@ -116,7 +116,7 @@ export class BloodGroupController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกรุ๊ปเลือดนี้");
}
await this.bloodGroupRepository.remove(delBloodGroup,{ data: request });
await this.bloodGroupRepository.remove(delBloodGroup, { data: request });
return new HttpSuccess();
}

View file

@ -0,0 +1,253 @@
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);
}
}

View file

@ -265,7 +265,7 @@ export class DevelopmentRequestController extends Controller {
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
await this.developmentRequestRepository.save(record, {data: req});
await this.developmentRequestRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
await this.developmentProjectRepository.delete({ developmentRequestId: record.id });
if (body.developmentProjects != null) {

View file

@ -109,7 +109,7 @@ export class DistrictController extends Controller {
_district.lastUpdateUserId = request.user.sub;
_district.lastUpdateFullName = request.user.name;
_district.lastUpdatedAt = new Date();
await this.districtRepository.save(_district, { data: request});
await this.districtRepository.save(_district, { data: request });
setLogDataDiff(request, { before, after: _district });
return new HttpSuccess();
}

View file

@ -60,7 +60,7 @@ export class EducationLevelController extends Controller {
educationLevel.lastUpdateFullName = request.user.name;
educationLevel.lastUpdatedAt = new Date();
await this.educationLevelRepository.save(educationLevel, { data: request });
setLogDataDiff( request, { before, after: educationLevel } );
setLogDataDiff(request, { before, after: educationLevel });
return new HttpSuccess();
}
@ -96,7 +96,7 @@ export class EducationLevelController extends Controller {
educationLevel.lastUpdatedAt = new Date();
this.educationLevelRepository.merge(educationLevel, requestBody);
await this.educationLevelRepository.save(educationLevel, { data: request });
setLogDataDiff( request, { before, after: educationLevel } );
setLogDataDiff(request, { before, after: educationLevel });
return new HttpSuccess();
}
@ -108,14 +108,14 @@ export class EducationLevelController extends Controller {
* @param {string} id Id
*/
@Delete("{id}")
async deleteEducationLevel(@Path() id: string , @Request() request: RequestWithUser) {
async deleteEducationLevel(@Path() id: string, @Request() request: RequestWithUser) {
const delEducationLevel = await this.educationLevelRepository.findOne({
where: { id },
});
if (!delEducationLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับการศึกษานี้");
}
await this.educationLevelRepository.remove(delEducationLevel,{ data: request });
await this.educationLevelRepository.remove(delEducationLevel, { data: request });
return new HttpSuccess();
}

View file

@ -609,7 +609,7 @@ export class EmployeePositionController extends Controller {
position.lastUpdateUserId = request.user.sub;
position.lastUpdateFullName = request.user.name;
position.lastUpdatedAt = new Date();
await this.employeePositionRepository.save(position, { data: request});
await this.employeePositionRepository.save(position, { data: request });
}),
);
return new HttpSuccess(posMaster.id);

View file

@ -103,7 +103,7 @@ export class GenderController extends Controller {
_gender.createdAt = new Date();
_gender.lastUpdatedAt = new Date();
await this.genderRepository.save(_gender, { data: request });
setLogDataDiff( request, { before, after: _gender } );
setLogDataDiff(request, { before, after: _gender });
return new HttpSuccess();
}
@ -137,7 +137,7 @@ export class GenderController extends Controller {
_gender.lastUpdatedAt = new Date();
this.genderRepository.merge(_gender, requestBody);
await this.genderRepository.save(_gender, { data: request });
setLogDataDiff( request, { before, after: _gender } );
setLogDataDiff(request, { before, after: _gender });
return new HttpSuccess();
}
@ -156,7 +156,7 @@ export class GenderController extends Controller {
if (!_delGender) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลเพศนี้");
}
await this.genderRepository.remove(_delGender, {data: request});
await this.genderRepository.remove(_delGender, { data: request });
return new HttpSuccess();
}
}

View file

@ -229,20 +229,16 @@ export class InsigniaController extends Controller {
async GetInsigniaPath(@Path() path: string, @Request() request: RequestWithUser) {
path = path.toLocaleUpperCase();
let getPermission: string = "";
if(path == "MANAGE") {
getPermission = "SYS_INSIGNIA_MANAGE"
}
else if(path == "RECORD") {
getPermission = "SYS_INSIGNIA_RECORD"
}
else if(path == "ALLOCATE") {
getPermission = "SYS_INSIGNIA_ALLOCATE"
}
else if(path == "BORROW") {
getPermission = "SYS_INSIGNIA_BORROW"
}
else {
getPermission = "SYS_INSIGNIA_MANAGE"
if (path == "MANAGE") {
getPermission = "SYS_INSIGNIA_MANAGE";
} else if (path == "RECORD") {
getPermission = "SYS_INSIGNIA_RECORD";
} else if (path == "ALLOCATE") {
getPermission = "SYS_INSIGNIA_ALLOCATE";
} else if (path == "BORROW") {
getPermission = "SYS_INSIGNIA_BORROW";
} else {
getPermission = "SYS_INSIGNIA_MANAGE";
}
await new permission().PermissionList(request, getPermission);
const insigniaAll = await this.insigniaRepository.find({

View file

@ -202,22 +202,19 @@ export class InsigniaTypeController extends Controller {
async GetInsigniaTypePath(@Path() path: string, @Request() request: RequestWithUser) {
path = path.toLocaleUpperCase();
let getPermission: string = "";
if(path == "RECORD") {
getPermission = "SYS_INSIGNIA_RECORD"
}
else if(path == "ALLOCATE") {
getPermission = "SYS_INSIGNIA_ALLOCATE"
}
else if(path == "BORROW") {
getPermission = "SYS_INSIGNIA_BORROW"
}
else {
getPermission = "SYS_INSIGNIA_RECORD"
if (path == "RECORD") {
getPermission = "SYS_INSIGNIA_RECORD";
} else if (path == "ALLOCATE") {
getPermission = "SYS_INSIGNIA_ALLOCATE";
} else if (path == "BORROW") {
getPermission = "SYS_INSIGNIA_BORROW";
} else {
getPermission = "SYS_INSIGNIA_RECORD";
}
await new permission().PermissionList(request, getPermission);
const insigniaTypeAll = await this.insigniaTypeRepository.find({
select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"],
where: {isActive : true},
where: { isActive: true },
order: { name: "ASC" },
});
return new HttpSuccess(insigniaTypeAll);

View file

@ -196,7 +196,7 @@ export class OrgChild1Controller {
child1.orgChild1Order =
order == null || order.orgChild1Order == null ? 1 : order.orgChild1Order + 1;
await this.child1Repository.save(child1, { data: request });
setLogDataDiff( request, { before , after: child1});
setLogDataDiff(request, { before, after: child1 });
return new HttpSuccess();
}
@ -308,7 +308,7 @@ export class OrgChild1Controller {
child1.responsibility = child1.responsibility || "";
this.child1Repository.merge(child1, requestBody);
await this.child1Repository.save(child1, { data: request });
setLogDataDiff( request, { before, after: child1 });
setLogDataDiff(request, { before, after: child1 });
const up_Child2 = await this.child2Repository.find({
where: {

View file

@ -162,7 +162,7 @@ export class OrgChild2Controller extends Controller {
child2.orgChild2Order =
order == null || order.orgChild2Order == null ? 1 : order.orgChild2Order + 1;
await this.child2Repository.save(child2, { data: request });
setLogDataDiff( request, { before, after: child2 } );
setLogDataDiff(request, { before, after: child2 });
return new HttpSuccess();
}
@ -238,7 +238,7 @@ export class OrgChild2Controller extends Controller {
child2.orgChild1Id = String(child1IdExits?.id);
this.child2Repository.merge(child2, requestBody);
await this.child2Repository.save(child2, { data: request });
setLogDataDiff( request, { before, after: child2 } );
setLogDataDiff(request, { before, after: child2 });
return new HttpSuccess();
}

View file

@ -260,7 +260,7 @@ export class OrgChild3Controller {
where: [{ posMasterId: In(empPosMasters.map((x) => x.id)) }],
});
await this.empPositionRepository.remove(empPositions, { data: request});
await this.empPositionRepository.remove(empPositions, { data: request });
await this.empPosMasterRepository.remove(empPosMasters, { data: request });
await this.positionRepository.remove(positions, { data: request });
await this.posMasterRepository.remove(posMasters, { data: request });

View file

@ -263,7 +263,7 @@ export class OrgRootController extends Controller {
orgRoot.lastUpdatedAt = new Date();
this.orgRootRepository.merge(orgRoot, requestBody);
await this.orgRootRepository.save(orgRoot, { data: request });
setLogDataDiff(request, {before, after: orgRoot});
setLogDataDiff(request, { before, after: orgRoot });
if (orgRoot.orgRootRankSub == "DISTRICT" || orgRoot.orgRootRankSub == "OFFICE") {
const up_Child1 = await this.child1Repository.find({

View file

@ -143,7 +143,8 @@ export class OrganizationDotnetController extends Controller {
const rootName =
item.current_holders.length == 0
? null
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot?.orgRootName;
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot
?.orgRootName;
const shortName =
item.current_holders.length == 0
? null
@ -152,8 +153,8 @@ export class OrganizationDotnetController extends Controller {
null
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3 !=
null
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild3 != null
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
@ -169,7 +170,7 @@ export class OrganizationDotnetController extends Controller {
?.orgRoot != null
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: null;
return {
return {
oc: rootName,
id: item.id,
createdAt: item.createdAt,
@ -222,9 +223,9 @@ export class OrganizationDotnetController extends Controller {
currentZipCode: item.currentZipCode,
posLevel: item.posLevel,
posType: item.posType,
posNo: shortName
}
})
posNo: shortName,
};
}),
);
return new HttpSuccess(profileEmp_);
}
@ -910,7 +911,7 @@ export class OrganizationDotnetController extends Controller {
"current_holders.orgChild2",
"current_holders.orgChild3",
"current_holders.orgChild4",
"profileSalary"
"profileSalary",
],
order: {
profileSalary: {
@ -928,7 +929,8 @@ export class OrganizationDotnetController extends Controller {
const rootName =
item.current_holders.length == 0
? null
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot?.orgRootName;
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot
?.orgRootName;
const shortName =
item.current_holders.length == 0
? null
@ -937,8 +939,8 @@ export class OrganizationDotnetController extends Controller {
null
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3 !=
null
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
?.orgChild3 != null
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == findRevision?.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)
@ -955,7 +957,7 @@ export class OrganizationDotnetController extends Controller {
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.posMasterNo}`
: null;
return {
return {
oc: rootName,
id: item.id,
createdAt: item.createdAt,
@ -1008,12 +1010,10 @@ export class OrganizationDotnetController extends Controller {
currentZipCode: item.currentZipCode,
dutyTimeId: item.dutyTimeId,
dutyTimeEffectiveDate: item.dutyTimeEffectiveDate,
positionLevel: item.profileSalary.length > 0
? item.profileSalary[0].positionLevel
: null,
posNo: shortName
}
})
positionLevel: item.profileSalary.length > 0 ? item.profileSalary[0].positionLevel : null,
posNo: shortName,
};
}),
);
return new HttpSuccess(profile_);

View file

@ -990,7 +990,7 @@ export class PositionController extends Controller {
posMaster.createdAt = new Date();
posMaster.lastUpdatedAt = new Date();
await this.posMasterRepository.save(posMaster, { data: request });
setLogDataDiff( request, { before, after: posMaster });
setLogDataDiff(request, { before, after: posMaster });
await this.positionRepository.delete({ posMasterId: posMaster.id });
await Promise.all(
@ -3000,7 +3000,7 @@ export class PositionController extends Controller {
dataMaster.isSit = requestBody.isSit;
dataMaster.next_holderId = requestBody.profileId;
await this.posMasterRepository.save(dataMaster, { data: request });
setLogDataDiff( request, { before, after: dataMaster });
setLogDataDiff(request, { before, after: dataMaster });
return new HttpSuccess();
}

View file

@ -104,7 +104,7 @@ export class PrefixController extends Controller {
_prefix.createdAt = new Date();
_prefix.lastUpdatedAt = new Date();
await this.prefixRepository.save(_prefix, { data: request });
setLogDataDiff( request, { before, after: _prefix} )
setLogDataDiff(request, { before, after: _prefix });
return new HttpSuccess();
}
@ -158,7 +158,7 @@ export class PrefixController extends Controller {
if (!_delPrefix) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำนำหน้าชื่อนี้");
}
await this.prefixRepository.remove(_delPrefix,{ data: request });
await this.prefixRepository.remove(_delPrefix, { data: request });
return new HttpSuccess();
}
}

View file

@ -94,9 +94,7 @@ export class ProfileAssessmentsController extends Controller {
}
@Get("history/{assessmentId}")
public async getProfileAssessmentsHistory(
@Path() assessmentId: string,
) {
public async getProfileAssessmentsHistory(@Path() assessmentId: string) {
const record = await this.profileAssessmentsHistoryRepository.find({
where: {
profileAssessmentId: assessmentId,
@ -139,10 +137,10 @@ export class ProfileAssessmentsController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.profileAssessmentsRepository.save(data, { data: req });
setLogDataDiff( req, { before, after: data } );
setLogDataDiff(req, { before, after: data });
history.profileAssessmentId = data.id;
await this.profileAssessmentsHistoryRepository.save(history, { data: req });
setLogDataDiff( req, { before, after: history } );
setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}

View file

@ -75,7 +75,11 @@ export class ProfileAssessmentsEmployeeController extends Controller {
) {
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
_record.profileEmployeeId,
);
}
const record = await this.profileAssessmentsHistoryRepository.find({
where: {
@ -91,9 +95,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
}
@Get("history/{assessmentId}")
public async getProfileAssessmentsHistory(
@Path() assessmentId: string,
) {
public async getProfileAssessmentsHistory(@Path() assessmentId: string) {
const record = await this.profileAssessmentsHistoryRepository.find({
where: {
profileAssessmentId: assessmentId,
@ -136,10 +138,10 @@ export class ProfileAssessmentsEmployeeController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.profileAssessmentsRepository.save(data, { data: req });
setLogDataDiff( req, { before, after: data });
setLogDataDiff(req, { before, after: data });
history.profileAssessmentId = data.id;
await this.profileAssessmentsHistoryRepository.save(history, { data: req });
setLogDataDiff( req, { before, after: history });
setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}

View file

@ -148,8 +148,7 @@ export class ProfileAvatarController extends Controller {
if (!_record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
await this.avatarRepository.remove(_record, {data: req});
await this.avatarRepository.remove(_record, { data: req });
return new HttpSuccess();
}

View file

@ -131,11 +131,11 @@ export class ProfileAvatarEmployeeController extends Controller {
data.isActive = true;
data.avatar = avatar;
data.avatarName = fileName;
await this.avatarRepository.save(data, {data: req});
await this.avatarRepository.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
profile.avatar = avatar;
profile.avatarName = fileName;
await this.profileRepository.save(profile, {data: req});
await this.profileRepository.save(profile, { data: req });
return new HttpSuccess({ avatar: avatar, avatarName: fileName });
}
@ -154,7 +154,7 @@ export class ProfileAvatarEmployeeController extends Controller {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
await this.avatarRepository.remove(_record, {data: req});
await this.avatarRepository.remove(_record, { data: req });
return new HttpSuccess();
}

View file

@ -132,11 +132,11 @@ export class ProfileAvatarEmployeeTempController extends Controller {
data.isActive = true;
data.avatar = avatar;
data.avatarName = fileName;
await this.avatarRepository.save(data, {data: req});
setLogDataDiff( req, {before, after: data});
await this.avatarRepository.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
profile.avatar = avatar;
profile.avatarName = fileName;
await this.profileRepository.save(profile, {data: req});
await this.profileRepository.save(profile, { data: req });
return new HttpSuccess({ avatar: avatar, avatarName: fileName });
}
@ -148,7 +148,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
if (!_record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
await this.avatarRepository.remove(_record, { data: req});
await this.avatarRepository.remove(_record, { data: req });
return new HttpSuccess();
}

View file

@ -57,7 +57,10 @@ export class ProfileCertificateEmployeeTempController extends Controller {
}
@Get("admin/history/{certificateId}")
public async certificateAdminHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
public async certificateAdminHistory(
@Path() certificateId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.certificateHistoryRepo.find({
where: {
@ -111,10 +114,10 @@ export class ProfileCertificateEmployeeTempController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.certificateRepo.save(data, { data: req });
setLogDataDiff( req , {before, after: data});
setLogDataDiff(req, { before, after: data });
history.profileCertificateId = data.id;
await this.certificateHistoryRepo.save(history, { data: req });
setLogDataDiff( req , {before, after: history});
setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}
@ -149,9 +152,9 @@ export class ProfileCertificateEmployeeTempController extends Controller {
await Promise.all([
this.certificateRepo.save(record, { data: req }),
setLogDataDiff( req , {before, after: record}),
setLogDataDiff(req, { before, after: record }),
this.certificateHistoryRepo.save(history, { data: req }),
setLogDataDiff( req , {before: before_null, after: history}),
setLogDataDiff(req, { before: before_null, after: history }),
]);
return new HttpSuccess();

View file

@ -103,11 +103,11 @@ export class ProfileChangeNameController extends Controller {
await this.changeNameRepository.save(data);
history.profileChangeNameId = data.id;
await this.changeNameHistoryRepository.save(history, { data: req });
setLogDataDiff( req, { before, after: history })
setLogDataDiff(req, { before, after: history });
profile.firstName = body.firstName ?? profile.firstName;
profile.lastName = body.lastName ?? profile.lastName;
profile.prefix = body.prefix ?? profile.prefix;
await this.profileRepository.save(profile, { data:req });
await this.profileRepository.save(profile, { data: req });
setLogDataDiff(req, { before, after: profile });
if (profile != null && profile.keycloak != null) {
@ -149,9 +149,9 @@ export class ProfileChangeNameController extends Controller {
await Promise.all([
this.changeNameRepository.save(record, { data: req }),
setLogDataDiff( req , {before, after: record}),
setLogDataDiff(req, { before, after: record }),
this.changeNameHistoryRepository.save(history, { data: req }),
setLogDataDiff( req , {before: before_null, after: history}),
setLogDataDiff(req, { before: before_null, after: history }),
]);
const chkLastRecord = await this.changeNameRepository.findOne({
@ -171,7 +171,7 @@ export class ProfileChangeNameController extends Controller {
profile.lastName = body.lastName ?? profile.lastName;
profile.prefix = body.prefix ?? profile.prefix;
await this.profileRepository.save(profile, { data: req });
setLogDataDiff( req , {before: before_profile, after: profile});
setLogDataDiff(req, { before: before_profile, after: profile });
}
// ปิดไว้ก่อนเพราะ error ต้องใช้ keycloak ที่มีสิทธิ์ในการ update //update 17/07

View file

@ -99,16 +99,16 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.changeNameRepository.save(data, { data: req });
setLogDataDiff( req , {before, after: data});
setLogDataDiff(req, { before, after: data });
history.profileChangeNameId = data.id;
await this.changeNameHistoryRepository.save(history, { data: req });
setLogDataDiff( req , {before, after: history});
setLogDataDiff(req, { before, after: history });
profile.firstName = body.firstName ?? profile.firstName;
profile.lastName = body.lastName ?? profile.lastName;
profile.prefix = body.prefix ?? profile.prefix;
await this.profileEmployeeRepo.save(profile, {data: req});
setLogDataDiff( req, {before, after: profile});
await this.profileEmployeeRepo.save(profile, { data: req });
setLogDataDiff(req, { before, after: profile });
if (profile != null && profile.keycloak != null) {
const result = await updateName(profile.keycloak, profile.firstName, profile.lastName);

View file

@ -106,7 +106,7 @@ export class ProfileChildrenEmployeeController extends Controller {
setLogDataDiff(req, { before, after: data });
history.profileChildrenId = data.id;
await this.childrenHistoryRepository.save(history, { data: req });
setLogDataDiff( req, { before, after: history });
setLogDataDiff(req, { before, after: history });
return new HttpSuccess();
}

View file

@ -405,7 +405,7 @@ export class ProfileGovernmentHistoryController extends Controller {
await Promise.all([
this.profileRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.govRepo.save(history, { data:req })
this.govRepo.save(history, { data: req }),
]);
return new HttpSuccess();

View file

@ -388,7 +388,8 @@ export class ProfileGovernmentEmployeeController extends Controller {
await Promise.all([
this.profileEmployeeRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.govRepo.save(history, { data: req })]);
this.govRepo.save(history, { data: req }),
]);
return new HttpSuccess();
}
}

View file

@ -128,10 +128,10 @@ export class ProfileHonorController extends Controller {
const history = new ProfileHonorHistory();
Object.assign(history, { ...data, id: undefined });
await this.honorRepo.save(data, {data: req});
await this.honorRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileHonorId = data.id;
await this.honorHistoryRepo.save(history, {data: req});
await this.honorHistoryRepo.save(history, { data: req });
return new HttpSuccess();
}

View file

@ -142,7 +142,7 @@ export class ProfileInsigniaController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.insigniaRepo.save(data, { data: req });
setLogDataDiff( req, { before, after: data } );
setLogDataDiff(req, { before, after: data });
history.profileInsigniaId = data.id;
await this.insigniaHistoryRepo.save(history, { data: req });
@ -185,7 +185,7 @@ export class ProfileInsigniaController extends Controller {
await Promise.all([
this.insigniaRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.insigniaHistoryRepo.save(history, { data: req })
this.insigniaHistoryRepo.save(history, { data: req }),
]);
return new HttpSuccess();

View file

@ -69,7 +69,10 @@ export class ProfileInsigniaEmployeeController extends Controller {
}
@Get("admin/history/{InsigniaId}")
public async getInsigniaAdminHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
public async getInsigniaAdminHistory(
@Path() InsigniaId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
if (_record) {
await new permission().PermissionOrgUserGet(
@ -146,7 +149,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.insigniaRepo.save(data, { data: req });
setLogDataDiff( req, { before, after: data } )
setLogDataDiff(req, { before, after: data });
history.profileInsigniaId = data.id;
await this.insigniaHistoryRepo.save(history, { data: req });

View file

@ -69,7 +69,10 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
}
@Get("admin/history/{InsigniaId}")
public async getInsigniaAdminHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
public async getInsigniaAdminHistory(
@Path() InsigniaId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.insigniaHistoryRepo.find({
relations: {
@ -142,7 +145,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
await this.insigniaRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileInsigniaId = data.id;
await this.insigniaHistoryRepo.save(history, { data:req });
await this.insigniaHistoryRepo.save(history, { data: req });
return new HttpSuccess();
}

View file

@ -162,7 +162,7 @@ export class ProfileLeaveController extends Controller {
}
@Get("history/{leaveId}")
public async leaveHistory(@Path() leaveId: string,) {
public async leaveHistory(@Path() leaveId: string) {
const record = await this.leaveHistoryRepo.find({
relations: { leaveType: true },
where: { profileLeaveId: leaveId },
@ -206,7 +206,7 @@ export class ProfileLeaveController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.leaveRepo.save(data, { data: req });
setLogDataDiff( req, { before, after: data });
setLogDataDiff(req, { before, after: data });
history.profileLeaveId = data.id;
await this.leaveHistoryRepo.save(history, { data: req });
@ -248,7 +248,7 @@ export class ProfileLeaveController extends Controller {
await Promise.all([
this.leaveRepo.save(record, { data: req }),
setLogDataDiff( req, { before, after: record }),
setLogDataDiff(req, { before, after: record }),
this.leaveHistoryRepo.save(history, { data: req }),
]);

View file

@ -134,7 +134,7 @@ export class ProfileLeaveEmployeeController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.leaveRepo.save(data, { data: req });
setLogDataDiff( req, { before, after: data } )
setLogDataDiff(req, { before, after: data });
history.profileLeaveId = data.id;
await this.leaveHistoryRepo.save(history, { data: req });
@ -180,7 +180,7 @@ export class ProfileLeaveEmployeeController extends Controller {
await Promise.all([
this.leaveRepo.save(record, { data: req }),
setLogDataDiff( req, { before, after: record } ),
setLogDataDiff(req, { before, after: record }),
this.leaveHistoryRepo.save(history, { data: req }),
]);

View file

@ -169,8 +169,8 @@ export class ProfileLeaveEmployeeTempController extends Controller {
await Promise.all([
this.leaveRepo.save(record),
setLogDataDiff( req, { before, after: record} ),
this.leaveHistoryRepo.save(history)
setLogDataDiff(req, { before, after: record }),
this.leaveHistoryRepo.save(history),
]);
return new HttpSuccess();

View file

@ -93,7 +93,7 @@ export class ProfileNopaidController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.nopaidRepository.save(data, { data: req });
setLogDataDiff( req, { before, after: data } )
setLogDataDiff(req, { before, after: data });
history.profileNopaidId = data.id;
await this.nopaidHistoryRepository.save(history, { data: req });
@ -128,7 +128,7 @@ export class ProfileNopaidController extends Controller {
await Promise.all([
this.nopaidRepository.save(record, { data: req }),
setLogDataDiff( req, { before, after: record } ),
setLogDataDiff(req, { before, after: record }),
this.nopaidHistoryRepository.save(history, { data: req }),
]);

View file

@ -97,10 +97,10 @@ export class ProfileNopaidEmployeeTempController extends Controller {
const history = new ProfileNopaidHistory();
Object.assign(history, { ...data, id: undefined });
await this.nopaidRepository.save(data, {data: req});
setLogDataDiff( req, { before, after: data})
await this.nopaidRepository.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileNopaidId = data.id;
await this.nopaidHistoryRepository.save(history, {data: req});
await this.nopaidHistoryRepository.save(history, { data: req });
return new HttpSuccess();
}

View file

@ -55,7 +55,6 @@ export class ProfileOtherController extends Controller {
@Get("admin/history/{otherId}")
public async otherAdminHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
const _record = await this.otherRepository.findOneBy({ id: otherId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
@ -68,7 +67,7 @@ export class ProfileOtherController extends Controller {
}
@Get("history/{otherId}")
public async otherHistory(@Path() otherId: string,) {
public async otherHistory(@Path() otherId: string) {
const record = await this.otherHistoryRepository.find({
where: { profileOtherId: otherId },
order: { createdAt: "DESC" },

View file

@ -128,7 +128,7 @@ export class ProfileSalaryEmployeeTempController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.salaryRepo.save(data, { data: req });
setLogDataDiff( req, { before, after: data });
setLogDataDiff(req, { before, after: data });
history.profileSalaryId = data.id;
await this.salaryHistoryRepo.save(history, { data: req });
@ -165,7 +165,7 @@ export class ProfileSalaryEmployeeTempController extends Controller {
await Promise.all([
this.salaryRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.salaryHistoryRepo.save(history, { data: req })
this.salaryHistoryRepo.save(history, { data: req }),
]);
return new HttpSuccess();

View file

@ -72,7 +72,7 @@ export class ProfileTrainingController extends Controller {
}
@Get("history/{trainingId}")
public async trainingHistory(@Path() trainingId: string,) {
public async trainingHistory(@Path() trainingId: string) {
const record = await this.trainingHistoryRepo.find({
where: {
profileTrainingId: trainingId,
@ -110,7 +110,7 @@ export class ProfileTrainingController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.trainingRepo.save(data, { data: req });
setLogDataDiff( req, { before, after: data} )
setLogDataDiff(req, { before, after: data });
history.profileTrainingId = data.id;
await this.trainingHistoryRepo.save(history, { data: req });
@ -145,7 +145,7 @@ export class ProfileTrainingController extends Controller {
await Promise.all([
this.trainingRepo.save(record, { data: req }),
setLogDataDiff( req, { before, after: record} ),
setLogDataDiff(req, { before, after: record }),
this.trainingHistoryRepo.save(history, { data: req }),
]);

View file

@ -119,7 +119,7 @@ export class ProfileTrainingEmployeeController extends Controller {
Object.assign(history, { ...data, id: undefined });
await this.trainingRepo.save(data, { data: req });
setLogDataDiff( req, { before, after: data} )
setLogDataDiff(req, { before, after: data });
history.profileTrainingId = data.id;
await this.trainingHistoryRepo.save(history, { data: req });
@ -158,7 +158,7 @@ export class ProfileTrainingEmployeeController extends Controller {
await Promise.all([
this.trainingRepo.save(record, { data: req }),
setLogDataDiff( req, { before, after: record} ),
setLogDataDiff(req, { before, after: record }),
this.trainingHistoryRepo.save(history, { data: req }),
]);

View file

@ -101,7 +101,7 @@ export class ProvinceController extends Controller {
_province.createdAt = new Date();
_province.lastUpdatedAt = new Date();
await this.provinceRepository.save(_province, { data: request });
setLogDataDiff( request, { before, after: _province} )
setLogDataDiff(request, { before, after: _province });
return new HttpSuccess();
}
@ -135,7 +135,7 @@ export class ProvinceController extends Controller {
_province.lastUpdatedAt = new Date();
this.provinceRepository.merge(_province, requestBody);
await this.provinceRepository.save(_province, { data: request });
setLogDataDiff( request, { before, after: _province} )
setLogDataDiff(request, { before, after: _province });
return new HttpSuccess();
}

View file

@ -61,7 +61,7 @@ export class RankController extends Controller {
rank.createdAt = new Date();
rank.lastUpdatedAt = new Date();
await this.rankRepository.save(rank, { data: request });
setLogDataDiff( request, { before, after: rank} )
setLogDataDiff(request, { before, after: rank });
return new HttpSuccess();
}

View file

@ -61,7 +61,7 @@ export class RelationshipController extends Controller {
relationship.createdAt = new Date();
relationship.lastUpdatedAt = new Date();
await this.relationshipRepository.save(relationship, { data: request });
setLogDataDiff( request, { before, after: relationship });
setLogDataDiff(request, { before, after: relationship });
return new HttpSuccess();
}
@ -98,7 +98,7 @@ export class RelationshipController extends Controller {
relationship.lastUpdatedAt = new Date();
this.relationshipRepository.merge(relationship, requestBody);
await this.relationshipRepository.save(relationship, { data: request });
setLogDataDiff( request, { before, after: relationship } )
setLogDataDiff(request, { before, after: relationship });
return new HttpSuccess();
}

View file

@ -5,7 +5,7 @@ import { RequestWithUser } from "../middlewares/user";
import { addLogSequence } from "../interfaces/utils";
export class MyCustomLogger implements Logger {
log(level: "log" | "info" | "warn", message: any, queryRunner?: QueryRunner) { }
log(level: "log" | "info" | "warn", message: any, queryRunner?: QueryRunner) {}
logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner): void {
const req = queryRunner?.data as RequestWithUser;

View file

@ -1,8 +1,8 @@
import { Entity, Column} from "typeorm";
import { Entity, Column } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("amphurImport")
export class AmphurImport extends EntityBase{
export class AmphurImport extends EntityBase {
@Column({
nullable: true,
length: 255,

View file

@ -1,4 +1,4 @@
import { Entity, Column} from "typeorm";
import { Entity, Column } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("educationLevel")

View file

@ -1,8 +1,8 @@
import { Entity, Column} from "typeorm";
import { Entity, Column } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("educationMis")
export class EducationMis extends EntityBase{
export class EducationMis extends EntityBase {
@Column({
nullable: true,
length: 255,

View file

@ -40,7 +40,7 @@ export class PosDict extends EntityBase {
comment: "ตำแหน่งทางการบริหาร",
default: null,
})
posExecutiveId?: string|null;
posExecutiveId?: string | null;
@Column({
nullable: true,

View file

@ -1,4 +1,4 @@
import { Entity, Column} from "typeorm";
import { Entity, Column } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("prefixe")

View file

@ -28,11 +28,21 @@ export class ProfileChangePosition extends EntityBase {
@Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่", default: null })
positionNumberOld: string;
@Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน", type: "double", default: null })
@Column({
nullable: true,
comment: "ข้อมูลหน่วยงานเดิม เงินเดือน",
type: "double",
default: null,
})
amountOld: number;
@Column({ nullable: true, type: "datetime", comment: "ดำรงตำแหน่งในระดับปัจจุบันเมื่อ", default: null })
dateCurrent: Date
@Column({
nullable: true,
type: "datetime",
comment: "ดำรงตำแหน่งในระดับปัจจุบันเมื่อ",
default: null,
})
dateCurrent: Date;
@Column({ nullable: true, comment: "profile Id", default: null })
profileId: string;
@ -133,8 +143,6 @@ export class ProfileChangePosition extends EntityBase {
@Column({ nullable: true, comment: "ชื่อระดับตำแหน่ง", default: null })
posLevelName: string;
@Column({ nullable: true, comment: "ชื่อหน่วยงาน root old", default: null })
rootOld: string;
@ -198,7 +206,12 @@ export class ProfileChangePosition extends EntityBase {
@Column({ nullable: true, comment: "สถานะ", type: "text", default: null })
status: string;
@Column({nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง ChangePosition", default: null })
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ChangePosition",
default: null,
})
changePositionId: string;
@ManyToOne(() => ChangePosition, (v) => v.profileChangePosition)
@ -209,7 +222,7 @@ export class ProfileChangePosition extends EntityBase {
//เพิ่มรายชื่อผู้ที่ย้ายสับเปลี่ยนตำแหน่ง
export class CreateProfileChangePosition {
changePositionId: string;
profiles: ProfileItem[]
profiles: ProfileItem[];
}
export class ProfileItem {
@ -257,7 +270,7 @@ export type UpdateProfileChangePosition = {
positionLevelOld: string;
organizationPositionOld: string;
amountOld: number;
dateCurrent : Date;
dateCurrent: Date;
reason: string | null;
};

View file

@ -1,7 +1,7 @@
import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { ProfileEmployee } from "./ProfileEmployee"
import { ProfileEmployeeEmploymentHistory } from "./ProfileEmployeeEmploymentHistory"
import { ProfileEmployee } from "./ProfileEmployee";
import { ProfileEmployeeEmploymentHistory } from "./ProfileEmployeeEmploymentHistory";
@Entity("profileEmployeeEmployment")
export class ProfileEmployeeEmployment extends EntityBase {
@ -34,7 +34,6 @@ export class ProfileEmployeeEmployment extends EntityBase {
@OneToMany(() => ProfileEmployeeEmploymentHistory, (v) => v.profileEmployeeEmployment)
histories: ProfileEmployeeEmploymentHistory[];
}
export class CreateEmploymentProfileEmployee {

View file

@ -1,6 +1,6 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { ProfileEmployeeEmployment } from "./ProfileEmployeeEmployment"
import { ProfileEmployeeEmployment } from "./ProfileEmployeeEmployment";
@Entity("profileEmployeeEmploymentHistory")
export class ProfileEmployeeEmploymentHistory extends EntityBase {
@ -30,5 +30,4 @@ export class ProfileEmployeeEmploymentHistory extends EntityBase {
@ManyToOne(() => ProfileEmployeeEmployment, (v) => v.histories)
@JoinColumn({ name: "profileEmployeeEmploymentId" })
profileEmployeeEmployment: ProfileEmployeeEmployment;
}

View file

@ -4,7 +4,6 @@ import { ProfileEmployee } from "./ProfileEmployee";
@Entity("profileEmployeeInformationHistory")
export class ProfileEmployeeInformationHistory extends EntityBase {
@Column({
nullable: true,
comment: "กลุ่มงาน",

View file

@ -6,7 +6,6 @@ import { ProfileFamilyCoupleHistory } from "./ProfileFamilyCoupleHistory";
@Entity("profileFamilyCouple")
export class ProfileFamilyCouple extends EntityBase {
@Column({
nullable: true,
default: null,
@ -100,7 +99,6 @@ export class ProfileFamilyCouple extends EntityBase {
@ManyToOne(() => ProfileEmployee, (v) => v.profileFamilyCouple)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}
export type CreateProfileFamilyCouple = {
@ -114,7 +112,7 @@ export type CreateProfileFamilyCouple = {
coupleCitizenId: string | null;
coupleLive: boolean | null;
relationship: string | null;
}
};
export type CreateProfileEmployeeFamilyCouple = {
profileEmployeeId: string;
@ -127,7 +125,7 @@ export type CreateProfileEmployeeFamilyCouple = {
coupleCitizenId: string | null;
coupleLive: boolean | null;
relationship: string | null;
}
};
export type UpdateProfileFamilyCouple = {
// couple?: boolean | null;

View file

@ -6,7 +6,6 @@ import { ProfileFamilyFatherHistory } from "./ProfileFamilyFatherHistory";
@Entity("profileFamilyFather")
export class ProfileFamilyFather extends EntityBase {
@Column({
nullable: true,
default: null,
@ -76,7 +75,6 @@ export class ProfileFamilyFather extends EntityBase {
@ManyToOne(() => ProfileEmployee, (v) => v.profileFamilyFather)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}
export type CreateProfileFamilyFather = {
@ -87,7 +85,7 @@ export type CreateProfileFamilyFather = {
fatherCareer: string | null;
fatherCitizenId: string | null;
fatherLive: boolean | null;
}
};
export type CreateProfileEmployeeFamilyFather = {
profileEmployeeId: string;
@ -97,7 +95,7 @@ export type CreateProfileEmployeeFamilyFather = {
fatherCareer: string | null;
fatherCitizenId: string | null;
fatherLive: boolean | null;
}
};
export type UpdateProfileFamilyFather = {
fatherPrefix?: string | null;

View file

@ -6,7 +6,6 @@ import { ProfileFamilyMotherHistory } from "./ProfileFamilyMotherHistory";
@Entity("profileFamilyMother")
export class ProfileFamilyMother extends EntityBase {
@Column({
nullable: true,
default: null,
@ -76,7 +75,6 @@ export class ProfileFamilyMother extends EntityBase {
@ManyToOne(() => ProfileEmployee, (v) => v.profileFamilyMother)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}
export type CreateProfileFamilyMother = {
@ -87,9 +85,9 @@ export type CreateProfileFamilyMother = {
motherCareer: string | null;
motherCitizenId: string | null;
motherLive: boolean | null;
}
};
export type CreateProfileEmployeeFamilyMother= {
export type CreateProfileEmployeeFamilyMother = {
profileEmployeeId: string;
motherPrefix: string | null;
motherFirstName: string | null;
@ -97,9 +95,9 @@ export type CreateProfileEmployeeFamilyMother= {
motherCareer: string | null;
motherCitizenId: string | null;
motherLive: boolean | null;
}
};
export type UpdateProfileFamilyMother= {
export type UpdateProfileFamilyMother = {
motherPrefix: string | null;
motherFirstName: string | null;
motherLastName: string | null;

View file

@ -1,10 +1,4 @@
import {
Entity,
Column,
JoinColumn,
ManyToOne,
Double,
} from "typeorm";
import { Entity, Column, JoinColumn, ManyToOne, Double } from "typeorm";
import { EntityBase } from "./base/Base";
import { ProfileSalary } from "./ProfileSalary";

View file

@ -1,8 +1,8 @@
import { Entity, Column} from "typeorm";
import { Entity, Column } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("provinceImport")
export class ProvinceImport extends EntityBase{
export class ProvinceImport extends EntityBase {
@Column({
nullable: true,
length: 255,

View file

@ -1,4 +1,4 @@
import { Entity, Column} from "typeorm";
import { Entity, Column } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("rank")

View file

@ -1,8 +1,8 @@
import { Entity, Column} from "typeorm";
import { Entity, Column } from "typeorm";
import { EntityBase } from "./base/Base";
@Entity("subDistrictImport")
export class SubDistrictImport extends EntityBase{
export class SubDistrictImport extends EntityBase {
@Column({
nullable: true,
length: 255,

View file

@ -46,7 +46,7 @@ export function calculateRetireDate(birthDate: Date) {
var year = d.getFullYear();
var month = d.getMonth();
var day = d.getDate();
var c = new Date(year + 60, month, day-1);
var c = new Date(year + 60, month, day - 1);
return c;
}
export function calculateRetireLaw(birthDate: Date) {
@ -94,8 +94,8 @@ export function calculateRetireYear(birthDate: Date) {
return yy + 61;
}
export async function removeProfileInOrganize(profileId: string, type:string) {
const currentRevision = await AppDataSource.getRepository(OrgRevision)
export async function removeProfileInOrganize(profileId: string, type: string) {
const currentRevision = await AppDataSource.getRepository(OrgRevision)
.createQueryBuilder("orgRevision")
.where("orgRevision.orgRevisionIsDraft = false")
.andWhere("orgRevision.orgRevisionIsCurrent = true")

View file

@ -251,11 +251,7 @@ export async function updateName(
*
* @returns user uuid or true if success, false otherwise.
*/
export async function enableStatus(
userId: string,
status: boolean,
) {
export async function enableStatus(userId: string, status: boolean) {
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/users/${userId}`, {
headers: {
authorization: `Bearer ${await getToken()}`,
@ -661,6 +657,4 @@ export async function removeUserGroup(userId: string, groupId: string) {
}
return true;
}

View file

@ -7,11 +7,7 @@ import HttpStatus from "../interfaces/http-status";
if (!process.env.AUTH_PUBLIC_KEY && !process.env.AUTH_REALM_URL) {
throw new Error("Require keycloak AUTH_PUBLIC_KEY or AUTH_REALM_URL.");
}
if (
process.env.AUTH_PUBLIC_KEY &&
process.env.AUTH_REALM_URL &&
!process.env.AUTH_PREFERRED_MODE
) {
if (process.env.AUTH_PUBLIC_KEY && process.env.AUTH_REALM_URL && !process.env.AUTH_PREFERRED_MODE) {
throw new Error(
"AUTH_PREFFERRED must be specified if AUTH_PUBLIC_KEY and AUTH_REALM_URL is provided.",
);

View file

@ -39,7 +39,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
res.on("finish", () => {
if (!req.url.startsWith("/api/")) return;
let system = "organization";
if (req.url.startsWith("/api/v1/org/metadata/")) system="metadata";
if (req.url.startsWith("/api/v1/org/metadata/")) system = "metadata";
if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
if (req.url.startsWith("/api/v1/org/profile/")) system = "registry";
if (req.url.startsWith("/api/v1/org/profile-employee/")) system = "registry";

View file

@ -13,6 +13,6 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"skipLibCheck": true
}
"skipLibCheck": true,
},
}

161
tsoa.json
View file

@ -26,75 +26,98 @@
}
},
"tags": [
{
"name": "Organization", "description": "โครงสร้างส่วนอื่น ๆ"
},
{
"name": "OrgRoot", "description": "โครงสร้างระดับ root"
},
{
"name": "OrgChild1", "description": "โครงสร้างระดับ 1"
},
{
"name": "OrgChild2", "description": "โครงสร้างระดับ 2"
},
{
"name": "OrgChild3", "description": "โครงสร้างระดับ 3"
},
{
"name": "OrgChild4", "description": "โครงสร้างระดับ 4"
},
{
"name": "Position", "description": "ตำแหน่ง"
},
{
"name": "PosType", "description": "ประเภทตำแหน่ง"
},
{
"name": "PosLevel", "description": "ระดับตำแหน่ง"
},
{
"name": "PosExecutive", "description": "ตำแหน่งทางการบริหาร"
},
{
"name": "Prefix", "description": "คำนำหน้า"
},
{
"name": "Rank", "description": "ยศ"
},
{
"name": "BloodGroup", "description": "กลุ่มเลือด"
},
{
"name": "Gender", "description": "เพศ"
},
{
"name": "Religion", "description": "ศาสนา"
},
{
"name": "Relationship", "description": "สถานภาพ"
},
{
"name": "EducationLevel", "description": "ระดับการศึกษา"
},
{
"name": "OrganizationUnauthorize", "description": "โครงสร้างส่วนอื่น ๆ (Unauthorize)"
},
{
"name": "Employee", "description": "ตำแหน่งลูกจ้างประจำ"
},
{
"name": "EmployeePosType", "description": "กลุ่มงานลูกจ้างประจำ"
},
{
"name": "EmployeePosLevel", "description": "ระดับชั้นงานลูกจ้างประจำ"
},
{
"name": "InsigniaType", "description": "ลำดับชั้นเครื่องราชอิสริยาภรณ์"
},
{
"name": "Insignia", "description": "เครื่องราชอิสริยาภรณ์"
}
{
"name": "Organization",
"description": "โครงสร้างส่วนอื่น ๆ"
},
{
"name": "OrgRoot",
"description": "โครงสร้างระดับ root"
},
{
"name": "OrgChild1",
"description": "โครงสร้างระดับ 1"
},
{
"name": "OrgChild2",
"description": "โครงสร้างระดับ 2"
},
{
"name": "OrgChild3",
"description": "โครงสร้างระดับ 3"
},
{
"name": "OrgChild4",
"description": "โครงสร้างระดับ 4"
},
{
"name": "Position",
"description": "ตำแหน่ง"
},
{
"name": "PosType",
"description": "ประเภทตำแหน่ง"
},
{
"name": "PosLevel",
"description": "ระดับตำแหน่ง"
},
{
"name": "PosExecutive",
"description": "ตำแหน่งทางการบริหาร"
},
{
"name": "Prefix",
"description": "คำนำหน้า"
},
{
"name": "Rank",
"description": "ยศ"
},
{
"name": "BloodGroup",
"description": "กลุ่มเลือด"
},
{
"name": "Gender",
"description": "เพศ"
},
{
"name": "Religion",
"description": "ศาสนา"
},
{
"name": "Relationship",
"description": "สถานภาพ"
},
{
"name": "EducationLevel",
"description": "ระดับการศึกษา"
},
{
"name": "OrganizationUnauthorize",
"description": "โครงสร้างส่วนอื่น ๆ (Unauthorize)"
},
{
"name": "Employee",
"description": "ตำแหน่งลูกจ้างประจำ"
},
{
"name": "EmployeePosType",
"description": "กลุ่มงานลูกจ้างประจำ"
},
{
"name": "EmployeePosLevel",
"description": "ระดับชั้นงานลูกจ้างประจำ"
},
{
"name": "InsigniaType",
"description": "ลำดับชั้นเครื่องราชอิสริยาภรณ์"
},
{
"name": "Insignia",
"description": "เครื่องราชอิสริยาภรณ์"
}
]
},
"routes": {