diff --git a/src/controllers/InsigniaController.ts b/src/controllers/InsigniaController.ts index 79a76aec..15a25eff 100644 --- a/src/controllers/InsigniaController.ts +++ b/src/controllers/InsigniaController.ts @@ -309,6 +309,7 @@ export class InsigniaController extends Controller { }); const sortLevel = insignia.map((data) => ({ + ...data, id: data.id, level: requestBody.id.indexOf(data.id) + 1, })); diff --git a/src/controllers/ProfileEducationsController.ts b/src/controllers/ProfileEducationsController.ts index d2f1c48f..8e8713be 100644 --- a/src/controllers/ProfileEducationsController.ts +++ b/src/controllers/ProfileEducationsController.ts @@ -12,7 +12,7 @@ import { Patch, Put, } from "tsoa"; -import { Not } from "typeorm" +import { Not } from "typeorm"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; @@ -119,14 +119,14 @@ export class ProfileEducationsController extends Controller { await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); if (body.isEducation) { await this.profileEducationRepo.update( - { profileId: body.profileId, isEducation: true }, - { isEducation: false } + { profileId: body.profileId, isEducation: true }, + { isEducation: false }, ); } if (body.isHigh) { await this.profileEducationRepo.update( - { profileId: body.profileId, isHigh: true }, - { isHigh: false } + { profileId: body.profileId, isHigh: true }, + { isHigh: false }, ); } const before = null; @@ -170,14 +170,14 @@ export class ProfileEducationsController extends Controller { await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId); if (body.isEducation) { await this.profileEducationRepo.update( - { profileId: record.profileId, isEducation: true, id: Not(educationId) }, - { isEducation: false } + { profileId: record.profileId, isEducation: true, id: Not(educationId) }, + { isEducation: false }, ); } if (body.isHigh) { await this.profileEducationRepo.update( - { profileId: record.profileId, isHigh: true, id: Not(educationId) }, - { isHigh: false } + { profileId: record.profileId, isHigh: true, id: Not(educationId) }, + { isHigh: false }, ); } const before = structuredClone(record); @@ -265,6 +265,7 @@ export class ProfileEducationsController extends Controller { }); const sortLevel = education.map((data) => ({ + ...data, id: data.id, level: requestBody.data.findIndex((x) => x.id == data.id) + 1, isUse: requestBody.data.find((x) => x.id == data.id)?.isUse ?? false, diff --git a/src/controllers/ProfileEducationsEmployeeController.ts b/src/controllers/ProfileEducationsEmployeeController.ts index 34d92475..a10e6479 100644 --- a/src/controllers/ProfileEducationsEmployeeController.ts +++ b/src/controllers/ProfileEducationsEmployeeController.ts @@ -12,7 +12,7 @@ import { Patch, Put, } from "tsoa"; -import { Not } from "typeorm" +import { Not } from "typeorm"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; @@ -127,14 +127,14 @@ export class ProfileEducationsEmployeeController extends Controller { await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id); if (body.isEducation) { await this.profileEducationRepo.update( - { profileEmployeeId: body.profileEmployeeId, isEducation: true }, - { isEducation: false } + { profileEmployeeId: body.profileEmployeeId, isEducation: true }, + { isEducation: false }, ); } if (body.isHigh) { await this.profileEducationRepo.update( - { profileEmployeeId: body.profileEmployeeId, isHigh: true }, - { isHigh: false } + { profileEmployeeId: body.profileEmployeeId, isHigh: true }, + { isHigh: false }, ); } const before = null; @@ -182,14 +182,14 @@ export class ProfileEducationsEmployeeController extends Controller { ); if (body.isEducation) { await this.profileEducationRepo.update( - { profileEmployeeId: record.profileEmployeeId, isEducation: true, id: Not(educationId) }, - { isEducation: false } + { profileEmployeeId: record.profileEmployeeId, isEducation: true, id: Not(educationId) }, + { isEducation: false }, ); } if (body.isHigh) { await this.profileEducationRepo.update( - { profileEmployeeId: record.profileEmployeeId, isHigh: true, id: Not(educationId) }, - { isHigh: false } + { profileEmployeeId: record.profileEmployeeId, isHigh: true, id: Not(educationId) }, + { isHigh: false }, ); } const before = structuredClone(record); @@ -283,6 +283,7 @@ export class ProfileEducationsEmployeeController extends Controller { }); const sortLevel = education.map((data) => ({ + ...data, id: data.id, level: requestBody.data.findIndex((x) => x.id == data.id) + 1, isUse: requestBody.data.find((x) => x.id == data.id)?.isUse ?? false, diff --git a/src/controllers/ProfileEducationsEmployeeTempController.ts b/src/controllers/ProfileEducationsEmployeeTempController.ts index 7d6d4117..64b75789 100644 --- a/src/controllers/ProfileEducationsEmployeeTempController.ts +++ b/src/controllers/ProfileEducationsEmployeeTempController.ts @@ -12,7 +12,7 @@ import { Patch, Put, } from "tsoa"; -import { Not } from "typeorm" +import { Not } from "typeorm"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; @@ -117,18 +117,18 @@ export class ProfileEducationsEmployeeTempController extends Controller { } if (body.isEducation) { await this.profileEducationRepo.update( - { profileEmployeeId: body.profileEmployeeId, isEducation: true }, - { isEducation: false } + { profileEmployeeId: body.profileEmployeeId, isEducation: true }, + { isEducation: false }, ); } if (body.isHigh) { const existing = await this.profileEducationRepo.find({ where: { profileId: body.profileEmployeeId, isHigh: true }, }); - console.log("isHigh ",existing) + console.log("isHigh ", existing); await this.profileEducationRepo.update( - { profileEmployeeId: body.profileEmployeeId, isHigh: true }, - { isHigh: false } + { profileEmployeeId: body.profileEmployeeId, isHigh: true }, + { isHigh: false }, ); } const before = null; @@ -172,14 +172,14 @@ export class ProfileEducationsEmployeeTempController extends Controller { if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (body.isEducation) { await this.profileEducationRepo.update( - { profileEmployeeId: record.profileEmployeeId, isEducation: true, id: Not(educationId) }, - { isEducation: false } + { profileEmployeeId: record.profileEmployeeId, isEducation: true, id: Not(educationId) }, + { isEducation: false }, ); } if (body.isHigh) { await this.profileEducationRepo.update( - { profileEmployeeId: record.profileEmployeeId, isHigh: true, id: Not(educationId) }, - { isHigh: false } + { profileEmployeeId: record.profileEmployeeId, isHigh: true, id: Not(educationId) }, + { isHigh: false }, ); } const before = structuredClone(record); @@ -266,6 +266,7 @@ export class ProfileEducationsEmployeeTempController extends Controller { }); const sortLevel = education.map((data) => ({ + ...data, id: data.id, level: requestBody.data.findIndex((x) => x.id == data.id) + 1, isUse: requestBody.data.find((x) => x.id == data.id)?.isUse ?? false,