diff --git a/.env.example b/.env.example index 61695b0c..9efa9164 100644 --- a/.env.example +++ b/.env.example @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ef7ded4f..7c4cb1c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/controllers/BloodGroupController.ts b/src/controllers/BloodGroupController.ts index a4f86be2..d407bdb3 100644 --- a/src/controllers/BloodGroupController.ts +++ b/src/controllers/BloodGroupController.ts @@ -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(); } diff --git a/src/controllers/DPISController.ts b/src/controllers/DPISController.ts new file mode 100644 index 00000000..644bd612 --- /dev/null +++ b/src/controllers/DPISController.ts @@ -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); + } +} diff --git a/src/controllers/DevelopmentRequestController.ts b/src/controllers/DevelopmentRequestController.ts index 8901c103..e9745e79 100644 --- a/src/controllers/DevelopmentRequestController.ts +++ b/src/controllers/DevelopmentRequestController.ts @@ -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) { diff --git a/src/controllers/DistrictController.ts b/src/controllers/DistrictController.ts index 18929d05..dc67548c 100644 --- a/src/controllers/DistrictController.ts +++ b/src/controllers/DistrictController.ts @@ -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(); } diff --git a/src/controllers/EducationLevelController.ts b/src/controllers/EducationLevelController.ts index b3e6e868..bda53464 100644 --- a/src/controllers/EducationLevelController.ts +++ b/src/controllers/EducationLevelController.ts @@ -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(); } diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index 1cdc2f9d..c5cc5299 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -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); diff --git a/src/controllers/GenderController.ts b/src/controllers/GenderController.ts index 75d809b1..06cc820e 100644 --- a/src/controllers/GenderController.ts +++ b/src/controllers/GenderController.ts @@ -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(); } } diff --git a/src/controllers/InsigniaController.ts b/src/controllers/InsigniaController.ts index 0150f118..b85f9d3b 100644 --- a/src/controllers/InsigniaController.ts +++ b/src/controllers/InsigniaController.ts @@ -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({ diff --git a/src/controllers/InsigniaTypeController.ts b/src/controllers/InsigniaTypeController.ts index 288ece85..07d85b66 100644 --- a/src/controllers/InsigniaTypeController.ts +++ b/src/controllers/InsigniaTypeController.ts @@ -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); diff --git a/src/controllers/OrgChild1Controller.ts b/src/controllers/OrgChild1Controller.ts index 8c5e5c21..8d7399d9 100644 --- a/src/controllers/OrgChild1Controller.ts +++ b/src/controllers/OrgChild1Controller.ts @@ -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: { diff --git a/src/controllers/OrgChild2Controller.ts b/src/controllers/OrgChild2Controller.ts index 0a6c8ab9..eb71d2df 100644 --- a/src/controllers/OrgChild2Controller.ts +++ b/src/controllers/OrgChild2Controller.ts @@ -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(); } diff --git a/src/controllers/OrgChild3Controller.ts b/src/controllers/OrgChild3Controller.ts index e4be3c15..ab7df30b 100644 --- a/src/controllers/OrgChild3Controller.ts +++ b/src/controllers/OrgChild3Controller.ts @@ -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 }); diff --git a/src/controllers/OrgRootController.ts b/src/controllers/OrgRootController.ts index 96e038da..b31bac50 100644 --- a/src/controllers/OrgRootController.ts +++ b/src/controllers/OrgRootController.ts @@ -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({ @@ -374,7 +374,7 @@ export class OrgRootController extends Controller { const empPositions = await this.empPositionRepository.find({ where: [{ posMasterId: In(empPosMasters.map((x) => x.id)) }], }); - + await this.empPositionRepository.remove(empPositions, { data: request }); await this.empPosMasterRepository.remove(empPosMasters, { data: request }); await this.positionRepository.remove(positions, { data: request }); diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 88052384..1ed97e24 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -142,8 +142,9 @@ export class OrganizationDotnetController extends Controller { profileEmp.map((item: ProfileEmployee) => { const rootName = item.current_holders.length == 0 - ? null - : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot?.orgRootName; + ? null + : 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_); } @@ -902,15 +903,15 @@ export class OrganizationDotnetController extends Controller { const profile = await this.profileRepo.find({ where: { keycloak: Not(IsNull()) || Not("") }, relations: [ - "posType", - "posLevel", - "current_holders", - "current_holders.orgRoot", + "posType", + "posLevel", + "current_holders", + "current_holders.orgRoot", "current_holders.orgChild1", "current_holders.orgChild2", "current_holders.orgChild3", "current_holders.orgChild4", - "profileSalary" + "profileSalary", ], order: { profileSalary: { @@ -922,13 +923,14 @@ export class OrganizationDotnetController extends Controller { const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true }, }); - + const profile_ = await Promise.all( profile.map((item: Profile) => { const rootName = item.current_holders.length == 0 - ? null - : item.current_holders.find((x) => x.orgRevisionId == findRevision?.id)?.orgRoot?.orgRootName; + ? null + : 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,14 +1010,12 @@ 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_); } diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 8f1c3fc1..9ec76ed1 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -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(); } diff --git a/src/controllers/PrefixController.ts b/src/controllers/PrefixController.ts index 9165cfee..92f6f96a 100644 --- a/src/controllers/PrefixController.ts +++ b/src/controllers/PrefixController.ts @@ -96,7 +96,7 @@ export class PrefixController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "āļŠāļ·āđˆāļ­āļ™āļĩāđ‰āļĄāļĩāļ­āļĒāļđāđˆāđƒāļ™āļĢāļ°āļšāļšāđāļĨāđ‰āļ§"); } - const before = null; + const before = null; _prefix.createdUserId = request.user.sub; _prefix.createdFullName = request.user.name; _prefix.lastUpdateUserId = request.user.sub; @@ -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(); } } diff --git a/src/controllers/ProfileAssessmentsController.ts b/src/controllers/ProfileAssessmentsController.ts index 0c1dfe82..b0338f9a 100644 --- a/src/controllers/ProfileAssessmentsController.ts +++ b/src/controllers/ProfileAssessmentsController.ts @@ -79,7 +79,7 @@ export class ProfileAssessmentsController extends Controller { if (_record) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } - + const record = await this.profileAssessmentsHistoryRepository.find({ where: { profileAssessmentId: assessmentId, @@ -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(); } diff --git a/src/controllers/ProfileAssessmentsEmployeeController.ts b/src/controllers/ProfileAssessmentsEmployeeController.ts index 97774c79..96d1339e 100644 --- a/src/controllers/ProfileAssessmentsEmployeeController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeController.ts @@ -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(); } diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index e92f96cc..a5a11da9 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -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(); } diff --git a/src/controllers/ProfileAvatarEmployeeController.ts b/src/controllers/ProfileAvatarEmployeeController.ts index 12fb923c..9fb0d8a2 100644 --- a/src/controllers/ProfileAvatarEmployeeController.ts +++ b/src/controllers/ProfileAvatarEmployeeController.ts @@ -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 }); } @@ -153,8 +153,8 @@ export class ProfileAvatarEmployeeController 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(); } diff --git a/src/controllers/ProfileAvatarEmployeeTempController.ts b/src/controllers/ProfileAvatarEmployeeTempController.ts index ea61a024..829fc32a 100644 --- a/src/controllers/ProfileAvatarEmployeeTempController.ts +++ b/src/controllers/ProfileAvatarEmployeeTempController.ts @@ -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(); } diff --git a/src/controllers/ProfileCertificateEmployeeTempController.ts b/src/controllers/ProfileCertificateEmployeeTempController.ts index e7a073fe..26879ac8 100644 --- a/src/controllers/ProfileCertificateEmployeeTempController.ts +++ b/src/controllers/ProfileCertificateEmployeeTempController.ts @@ -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,11 +152,11 @@ 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(); } diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index 8a4bc4df..addc0e40 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -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({ @@ -163,7 +163,7 @@ export class ProfileChangeNameController extends Controller { }, }); if (!chkLastRecord) throw new HttpError(HttpStatus.NOT_FOUND, "āđ„āļĄāđˆāļžāļšāļ‚āđ‰āļ­āļĄāļđāļĨ"); - + const profile = await this.profileRepository.findOneBy({ id: record.profileId }); const before_profile = structuredClone(profile); if (profile && chkLastRecord.id === record.id) { @@ -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 diff --git a/src/controllers/ProfileChangeNameEmployeeTempController.ts b/src/controllers/ProfileChangeNameEmployeeTempController.ts index 966afb6e..84a77f1d 100644 --- a/src/controllers/ProfileChangeNameEmployeeTempController.ts +++ b/src/controllers/ProfileChangeNameEmployeeTempController.ts @@ -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); diff --git a/src/controllers/ProfileChildrenEmployeeController.ts b/src/controllers/ProfileChildrenEmployeeController.ts index 5d01f683..3088c7e4 100644 --- a/src/controllers/ProfileChildrenEmployeeController.ts +++ b/src/controllers/ProfileChildrenEmployeeController.ts @@ -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(); } diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 4109927b..e24a7cad 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2537,7 +2537,7 @@ export class ProfileController extends Controller { // } } const record = await this.profileRepo.findOneBy({ id }); - const before = structuredClone(record); + const before = structuredClone(record); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "āđ„āļĄāđˆāļžāļšāļ‚āđ‰āļ­āļĄāļđāļĨāđ‚āļ›āļĢāđ„āļŸāļĨāđŒāļ™āļĩāđ‰"); @@ -5758,7 +5758,7 @@ export class ProfileController extends Controller { } await this.profileRepo.save(profile, { data: request }); setLogDataDiff(request, { before, after: profile }); - + return new HttpSuccess(); } diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 5c138701..614df3f6 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -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(); diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index fb47a767..0a1d3265 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -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(); } } diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index 0b4a9952..904ea180 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -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(); } diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index b0cb8693..29aae9fe 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -67,7 +67,7 @@ export class ProfileInsigniaController extends Controller { }); return new HttpSuccess(record); } - + @Get("admin/history/{InsigniaId}") public async getInsigniaAdminHistory( @Path() InsigniaId: string, @@ -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(); diff --git a/src/controllers/ProfileInsigniaEmployeeController.ts b/src/controllers/ProfileInsigniaEmployeeController.ts index 5c37a189..d8fa2524 100644 --- a/src/controllers/ProfileInsigniaEmployeeController.ts +++ b/src/controllers/ProfileInsigniaEmployeeController.ts @@ -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 }); diff --git a/src/controllers/ProfileInsigniaEmployeeTempController.ts b/src/controllers/ProfileInsigniaEmployeeTempController.ts index 78e19973..72a4b186 100644 --- a/src/controllers/ProfileInsigniaEmployeeTempController.ts +++ b/src/controllers/ProfileInsigniaEmployeeTempController.ts @@ -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(); } diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index 36cfa1bd..a6fc4a34 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -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 }), ]); diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index 7ded7aed..7cb80d86 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -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 }), ]); diff --git a/src/controllers/ProfileLeaveEmployeeTempController.ts b/src/controllers/ProfileLeaveEmployeeTempController.ts index ccba6411..88e75c3a 100644 --- a/src/controllers/ProfileLeaveEmployeeTempController.ts +++ b/src/controllers/ProfileLeaveEmployeeTempController.ts @@ -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(); diff --git a/src/controllers/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index 6d351eb1..eaf132b6 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -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 }), ]); diff --git a/src/controllers/ProfileNopaidEmployeeTempController.ts b/src/controllers/ProfileNopaidEmployeeTempController.ts index 011e7043..21153965 100644 --- a/src/controllers/ProfileNopaidEmployeeTempController.ts +++ b/src/controllers/ProfileNopaidEmployeeTempController.ts @@ -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(); } diff --git a/src/controllers/ProfileOtherController.ts b/src/controllers/ProfileOtherController.ts index e5253a94..dbf3b038 100644 --- a/src/controllers/ProfileOtherController.ts +++ b/src/controllers/ProfileOtherController.ts @@ -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" }, diff --git a/src/controllers/ProfileOtherEmployeeController.ts b/src/controllers/ProfileOtherEmployeeController.ts index 93b62f2d..abbfd254 100644 --- a/src/controllers/ProfileOtherEmployeeController.ts +++ b/src/controllers/ProfileOtherEmployeeController.ts @@ -72,7 +72,7 @@ export class ProfileOtherEmployeeController extends Controller { }); return new HttpSuccess(record); } - + @Get("history/{otherId}") public async otherHistory(@Path() otherId: string) { const record = await this.otherHistoryRepository.find({ diff --git a/src/controllers/ProfileSalaryEmployeeTempController.ts b/src/controllers/ProfileSalaryEmployeeTempController.ts index 0e80775b..ba9d3935 100644 --- a/src/controllers/ProfileSalaryEmployeeTempController.ts +++ b/src/controllers/ProfileSalaryEmployeeTempController.ts @@ -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(); diff --git a/src/controllers/ProfileTrainingController.ts b/src/controllers/ProfileTrainingController.ts index 3ac8da7d..adc72cee 100644 --- a/src/controllers/ProfileTrainingController.ts +++ b/src/controllers/ProfileTrainingController.ts @@ -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 }), ]); diff --git a/src/controllers/ProfileTrainingEmployeeController.ts b/src/controllers/ProfileTrainingEmployeeController.ts index 943b323b..88fd61d7 100644 --- a/src/controllers/ProfileTrainingEmployeeController.ts +++ b/src/controllers/ProfileTrainingEmployeeController.ts @@ -118,8 +118,8 @@ export class ProfileTrainingEmployeeController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(history, { ...data, id: undefined }); - await this.trainingRepo.save(data, { data: req }); - setLogDataDiff( req, { before, after: data} ) + await this.trainingRepo.save(data, { data: req }); + setLogDataDiff(req, { before, after: data }); history.profileTrainingId = data.id; await this.trainingHistoryRepo.save(history, { data: req }); @@ -144,7 +144,7 @@ export class ProfileTrainingEmployeeController extends Controller { Object.assign(record, body); Object.assign(history, { ...record, id: undefined }); - + history.profileTrainingId = trainingId; record.lastUpdateUserId = req.user.sub; record.lastUpdateFullName = req.user.name; @@ -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 }), ]); diff --git a/src/controllers/ProvinceController.ts b/src/controllers/ProvinceController.ts index 18dbd36a..92169272 100644 --- a/src/controllers/ProvinceController.ts +++ b/src/controllers/ProvinceController.ts @@ -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(); } diff --git a/src/controllers/RankController.ts b/src/controllers/RankController.ts index fdf345ed..c5b0e6cb 100644 --- a/src/controllers/RankController.ts +++ b/src/controllers/RankController.ts @@ -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(); } diff --git a/src/controllers/RelationshipController.ts b/src/controllers/RelationshipController.ts index e09b517f..1dd9ff5c 100644 --- a/src/controllers/RelationshipController.ts +++ b/src/controllers/RelationshipController.ts @@ -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(); } diff --git a/src/database/data-source.ts b/src/database/data-source.ts index aa285548..67ff5b79 100644 --- a/src/database/data-source.ts +++ b/src/database/data-source.ts @@ -5,8 +5,8 @@ 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; if (req?.app?.locals.logData?.sequence) { diff --git a/src/entities/AmphurImport.ts b/src/entities/AmphurImport.ts index 62e1ec2d..74d90fd1 100644 --- a/src/entities/AmphurImport.ts +++ b/src/entities/AmphurImport.ts @@ -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, diff --git a/src/entities/EducationLevel.ts b/src/entities/EducationLevel.ts index 13ed34f2..631c5a9d 100644 --- a/src/entities/EducationLevel.ts +++ b/src/entities/EducationLevel.ts @@ -1,4 +1,4 @@ -import { Entity, Column} from "typeorm"; +import { Entity, Column } from "typeorm"; import { EntityBase } from "./base/Base"; @Entity("educationLevel") diff --git a/src/entities/EducationMis.ts b/src/entities/EducationMis.ts index 6c2864f2..c0378904 100644 --- a/src/entities/EducationMis.ts +++ b/src/entities/EducationMis.ts @@ -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, diff --git a/src/entities/PosDict.ts b/src/entities/PosDict.ts index 4035f95b..f88b7e3b 100644 --- a/src/entities/PosDict.ts +++ b/src/entities/PosDict.ts @@ -40,7 +40,7 @@ export class PosDict extends EntityBase { comment: "āļ•āļģāđāļŦāļ™āđˆāļ‡āļ—āļēāļ‡āļāļēāļĢāļšāļĢāļīāļŦāļēāļĢ", default: null, }) - posExecutiveId?: string|null; + posExecutiveId?: string | null; @Column({ nullable: true, @@ -101,7 +101,7 @@ export class CreatePosDict { @Column() isSpecial: boolean; - + @Column() positionIsSelected?: boolean | null; } diff --git a/src/entities/Prefixe.ts b/src/entities/Prefixe.ts index 96faa92f..fe92aae8 100644 --- a/src/entities/Prefixe.ts +++ b/src/entities/Prefixe.ts @@ -1,4 +1,4 @@ -import { Entity, Column} from "typeorm"; +import { Entity, Column } from "typeorm"; import { EntityBase } from "./base/Base"; @Entity("prefixe") diff --git a/src/entities/ProfileChangePosition.ts b/src/entities/ProfileChangePosition.ts index 38ea5dfb..1e8a507f 100644 --- a/src/entities/ProfileChangePosition.ts +++ b/src/entities/ProfileChangePosition.ts @@ -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 { @@ -226,7 +239,7 @@ export class ProfileItem { organizationOld: string | null; organizationPositionOld?: string | null; amountOld: number | null; - educationOld: string | null; + educationOld: string | null; rootOld: string | null; rootOldId: string | null; rootShortNameOld: string | null; @@ -253,11 +266,11 @@ export class ProfileItem { export type UpdateProfileChangePosition = { educationOld: string; posMasterNoOld: number; - positionTypeOld: string; + positionTypeOld: string; positionLevelOld: string; organizationPositionOld: string; amountOld: number; - dateCurrent : Date; + dateCurrent: Date; reason: string | null; }; @@ -275,4 +288,4 @@ export type SelectProfileChangePosition = { posTypeName: string; posLevelId: string | null; posLevelName: string; -}; \ No newline at end of file +}; diff --git a/src/entities/ProfileChildren.ts b/src/entities/ProfileChildren.ts index 50cb5c8f..d369e7ee 100644 --- a/src/entities/ProfileChildren.ts +++ b/src/entities/ProfileChildren.ts @@ -87,7 +87,7 @@ export class ProfileChildren extends EntityBase { export type CreateProfileChildren = { profileId: string; childrenCareer: string | null; - childrenFirstName: string | null; + childrenFirstName: string | null; childrenLastName: string | null; childrenPrefix: string | null; childrenLive: boolean | null; diff --git a/src/entities/ProfileEmployeeEmployment.ts b/src/entities/ProfileEmployeeEmployment.ts index 901f0b6e..046f15f9 100644 --- a/src/entities/ProfileEmployeeEmployment.ts +++ b/src/entities/ProfileEmployeeEmployment.ts @@ -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 { @@ -27,14 +27,13 @@ export class ProfileEmployeeEmployment extends EntityBase { default: null, }) profileEmployeeId: string; - + @ManyToOne(() => ProfileEmployee, (v) => v.profileEmployeeEmployment) @JoinColumn({ name: "profileEmployeeId" }) profileEmployee: ProfileEmployee; @OneToMany(() => ProfileEmployeeEmploymentHistory, (v) => v.profileEmployeeEmployment) histories: ProfileEmployeeEmploymentHistory[]; - } export class CreateEmploymentProfileEmployee { @@ -45,4 +44,4 @@ export class CreateEmploymentProfileEmployee { export class UpdateEmploymentProfileEmployee { date: Date | null; command: string | null; -} \ No newline at end of file +} diff --git a/src/entities/ProfileEmployeeEmploymentHistory.ts b/src/entities/ProfileEmployeeEmploymentHistory.ts index 2d0cf02e..5bcae934 100644 --- a/src/entities/ProfileEmployeeEmploymentHistory.ts +++ b/src/entities/ProfileEmployeeEmploymentHistory.ts @@ -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 { @@ -18,7 +18,7 @@ export class ProfileEmployeeEmploymentHistory extends EntityBase { default: null, }) command: string; - + @Column({ nullable: true, length: 40, @@ -30,5 +30,4 @@ export class ProfileEmployeeEmploymentHistory extends EntityBase { @ManyToOne(() => ProfileEmployeeEmployment, (v) => v.histories) @JoinColumn({ name: "profileEmployeeEmploymentId" }) profileEmployeeEmployment: ProfileEmployeeEmployment; - -} \ No newline at end of file +} diff --git a/src/entities/ProfileEmployeeInformationHistory.ts b/src/entities/ProfileEmployeeInformationHistory.ts index 200bdcca..cb205641 100644 --- a/src/entities/ProfileEmployeeInformationHistory.ts +++ b/src/entities/ProfileEmployeeInformationHistory.ts @@ -4,70 +4,69 @@ import { ProfileEmployee } from "./ProfileEmployee"; @Entity("profileEmployeeInformationHistory") export class ProfileEmployeeInformationHistory extends EntityBase { - @Column({ nullable: true, comment: "āļāļĨāļļāđˆāļĄāļ‡āļēāļ™", default: null, }) positionEmployeeGroupId: string; - + @Column({ nullable: true, comment: "āļŠāļēāļĒāļ‡āļēāļ™", default: null, }) positionEmployeeLineId: string; - + @Column({ nullable: true, comment: "āļŠāļ·āđˆāļ­āļ•āļģāđāļŦāļ™āđˆāļ‡āļ—āļēāļ‡āļŠāļēāļĒāļ‡āļēāļ™", default: null, }) positionEmployeePositionId: string; - + @Column({ nullable: true, comment: "āļŠāļąāļ‡āļāļąāļ”", default: null, }) employeeOc: string; - + @Column({ nullable: true, comment: "āļ›āļĢāļ°āđ€āļ āļ—āļšāļļāļ„āļ„āļĨ", default: null, }) employeeTypeIndividual: string; - + @Column({ nullable: true, comment: "āļ„āđˆāļēāļˆāđ‰āļēāļ‡", default: null, }) employeeWage: string; - + @Column({ nullable: true, comment: "āđ€āļ‡āļīāļ™āđ€āļžāļīāđˆāļĄāļāļēāļĢāļ„āļĢāļ­āļ‡āļŠāļĩāļžāļŠāļąāđˆāļ§āļ„āļĢāļēāļ§", default: null, }) employeeMoneyIncrease: string; - + @Column({ nullable: true, comment: "āđ€āļ‡āļīāļ™āļŠāđˆāļ§āļĒāđ€āļŦāļĨāļ·āļ­āļāļēāļĢāļ„āļĢāļ­āļ‡āļŠāļĩāļžāļŠāļąāđˆāļ§āļ„āļĢāļēāļ§", default: null, }) employeeMoneyAllowance: string; - + @Column({ nullable: true, comment: "āđ€āļ‡āļīāļ™āļŠāļĄāļ—āļšāļ›āļĢāļ°āļāļąāļ™āļŠāļąāļ‡āļ„āļĄ(āļĨāļđāļāļˆāđ‰āļēāļ‡)", default: null, }) employeeMoneyEmployee: string; - + @Column({ nullable: true, comment: "āđ€āļ‡āļīāļ™āļŠāļĄāļ—āļšāļ›āļĢāļ°āļāļąāļ™āļŠāļąāļ‡āļ„āļĄ(āļ™āļēāļĒāļˆāđ‰āļēāļ‡)", diff --git a/src/entities/ProfileFamilyCouple.ts b/src/entities/ProfileFamilyCouple.ts index 74821918..34ecc874 100644 --- a/src/entities/ProfileFamilyCouple.ts +++ b/src/entities/ProfileFamilyCouple.ts @@ -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; diff --git a/src/entities/ProfileFamilyCoupleHistory.ts b/src/entities/ProfileFamilyCoupleHistory.ts index a350fc59..13f682ff 100644 --- a/src/entities/ProfileFamilyCoupleHistory.ts +++ b/src/entities/ProfileFamilyCoupleHistory.ts @@ -61,7 +61,7 @@ export class ProfileFamilyCoupleHistory extends EntityBase { comment: "āļĄāļĩāļŠāļĩāļ§āļīāļ•āļ„āļđāđˆāļŠāļĄāļĢāļŠ", }) coupleLive: boolean; - + @Column({ nullable: true, comment: "āļ„āļ§āļēāļĄāļŠāļąāļĄāļžāļąāļ™āļ˜āđŒ", @@ -69,7 +69,7 @@ export class ProfileFamilyCoupleHistory extends EntityBase { default: null, }) relationship: string; - + @Column({ nullable: true, length: 40, diff --git a/src/entities/ProfileFamilyFather.ts b/src/entities/ProfileFamilyFather.ts index 407afb2d..a842bdb6 100644 --- a/src/entities/ProfileFamilyFather.ts +++ b/src/entities/ProfileFamilyFather.ts @@ -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; diff --git a/src/entities/ProfileFamilyMother.ts b/src/entities/ProfileFamilyMother.ts index 93bd5b4c..3c87ba1b 100644 --- a/src/entities/ProfileFamilyMother.ts +++ b/src/entities/ProfileFamilyMother.ts @@ -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; diff --git a/src/entities/ProfileSalaryHistory.ts b/src/entities/ProfileSalaryHistory.ts index 01abb655..c0af4fbd 100644 --- a/src/entities/ProfileSalaryHistory.ts +++ b/src/entities/ProfileSalaryHistory.ts @@ -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"; diff --git a/src/entities/ProvinceImport.ts b/src/entities/ProvinceImport.ts index 978ebf9b..755c07b0 100644 --- a/src/entities/ProvinceImport.ts +++ b/src/entities/ProvinceImport.ts @@ -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, diff --git a/src/entities/Rank.ts b/src/entities/Rank.ts index 3d31d73e..975a6b08 100644 --- a/src/entities/Rank.ts +++ b/src/entities/Rank.ts @@ -1,4 +1,4 @@ -import { Entity, Column} from "typeorm"; +import { Entity, Column } from "typeorm"; import { EntityBase } from "./base/Base"; @Entity("rank") diff --git a/src/entities/SubDistrict.ts b/src/entities/SubDistrict.ts index 8d7a325d..353b9753 100644 --- a/src/entities/SubDistrict.ts +++ b/src/entities/SubDistrict.ts @@ -43,7 +43,7 @@ export class CreateSubDistrict { @Column() districtId: string; - + @Column() zipCode: string; } diff --git a/src/entities/SubDistrictImport.ts b/src/entities/SubDistrictImport.ts index cdf8660d..bbb2b3e1 100644 --- a/src/entities/SubDistrictImport.ts +++ b/src/entities/SubDistrictImport.ts @@ -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, diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index fc927882..099a237c 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -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") @@ -110,7 +110,7 @@ export async function removeProfileInOrganize(profileId: string, type:string) { .where("posMaster.orgRevisionId = :orgRevisionId", { orgRevisionId: currentRevision?.id }) .andWhere("posMaster.current_holderId = :profileId", { profileId }) .getOne(); - + await AppDataSource.getRepository(PosMaster) .createQueryBuilder() .update(PosMaster) @@ -136,7 +136,7 @@ export async function removeProfileInOrganize(profileId: string, type:string) { .where("id IN (:...ids)", { ids: findPosition.map((item) => item.id) }) .execute(); } - if (type === "EMPLOYEE") { + if (type === "EMPLOYEE") { const findProfileInEmpPosMaster = await AppDataSource.getRepository(EmployeePosMaster) .createQueryBuilder("employeePosMaster") .where("employeePosMaster.orgRevisionId = :orgRevisionId", { diff --git a/src/keycloak/index.ts b/src/keycloak/index.ts index 205c83cd..7384e0f8 100644 --- a/src/keycloak/index.ts +++ b/src/keycloak/index.ts @@ -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; - - } diff --git a/src/middlewares/auth.ts b/src/middlewares/auth.ts index ea60f6b4..bf62b28a 100644 --- a/src/middlewares/auth.ts +++ b/src/middlewares/auth.ts @@ -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.", ); @@ -60,11 +56,11 @@ export async function expressAuthentication( if (!request.app.locals.logData) { request.app.locals.logData = {}; } - + request.app.locals.logData.userId = payload.sub; request.app.locals.logData.userName = payload.name; request.app.locals.logData.user = payload.preferred_username; - + return payload; } diff --git a/src/middlewares/error.ts b/src/middlewares/error.ts index 2bf192e9..f8d0b56b 100644 --- a/src/middlewares/error.ts +++ b/src/middlewares/error.ts @@ -9,7 +9,7 @@ function error(error: Error, _req: Request, res: Response, _next: NextFunction) logData.status = "error"; logData.description = error.message; } - + if (error instanceof HttpError) { return res.status(error.status).json({ status: error.status, diff --git a/src/middlewares/logs.ts b/src/middlewares/logs.ts index 8c71ce41..43120556 100644 --- a/src/middlewares/logs.ts +++ b/src/middlewares/logs.ts @@ -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"; diff --git a/tsconfig.json b/tsconfig.json index 32199612..f5f96a0d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,6 @@ "experimentalDecorators": true, "emitDecoratorMetadata": true, "resolveJsonModule": true, - "skipLibCheck": true - } + "skipLibCheck": true, + }, } diff --git a/tsoa.json b/tsoa.json index a34af6cb..6cb0cf0d 100644 --- a/tsoa.json +++ b/tsoa.json @@ -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": {