diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index ece19088..5c801315 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -6679,7 +6679,7 @@ export class CommandController extends Controller { profileEdu.profileId = profile.id; const educationLevel = await this.profileEducationRepo.findOne({ select: ["id", "level", "profileId"], - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { level: "DESC" }, }); profileEdu.level = educationLevel == null ? 1 : educationLevel.level + 1; @@ -6871,7 +6871,7 @@ export class CommandController extends Controller { // Insignia if (_oldInsigniaIds.length > 0) { const _insignias = await this.insigniaRepo.find({ - where: { id: In(_oldInsigniaIds), isDeleted: false }, + where: { id: In(_oldInsigniaIds) }, order: { createdAt: "ASC" }, }); for (const oldInsignia of _insignias) { diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 1c71f9b0..99e931ea 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -2475,8 +2475,8 @@ export class ImportDataController extends Controller { }); const educationLevel = await this.profileEducationRepo.findOne({ - select: ["id", "level", "profileId", "isDeleted"], - where: { profileId: _item.id, isDeleted: false }, + select: ["id", "level", "profileId"], + where: { profileId: _item.id }, order: { level: "DESC" }, }); @@ -2607,8 +2607,8 @@ export class ImportDataController extends Controller { }); const educationLevel = await this.profileEducationRepo.findOne({ - select: ["id", "level", "profileEmployeeId", "isDeleted"], - where: { profileEmployeeId: _item.id, isDeleted: false }, + select: ["id", "level", "profileEmployeeId"], + where: { profileEmployeeId: _item.id }, order: { level: "DESC" }, }); @@ -2740,8 +2740,8 @@ export class ImportDataController extends Controller { }); const educationLevel = await this.profileEducationRepo.findOne({ - select: ["id", "level", "profileEmployeeId", "isDeleted"], - where: { profileEmployeeId: _item.id, isDeleted: false }, + select: ["id", "level", "profileEmployeeId"], + where: { profileEmployeeId: _item.id }, order: { level: "DESC" }, }); @@ -5799,7 +5799,7 @@ export class ImportDataController extends Controller { }, }); const eduLevel = await this.profileEducationRepo.findOne({ - where: { profileId: _item.id, isDeleted: false }, + where: { profileId: _item.id }, order: { startDate: "DESC", }, diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index b0a007f5..813e268c 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -8167,10 +8167,6 @@ export class OrganizationController extends Controller { }); toUpdate.push(current); - if (draftPos.next_holderId === null) { - await SavePosMasterHistoryOfficer(queryRunner, draftPos.ancestorDNA, null, null); - } - // Track mapping for position sync posMasterMapping.set(draftPos.id, [current.id, draftPos.next_holderId]); } else { @@ -8516,6 +8512,107 @@ export class OrganizationController extends Controller { }; } + /** + * Helper function: Sync positions for a PosMaster + * Handles DELETE/UPDATE/INSERT for positions associated with a posMaster + * + * @deprecated Kept as fallback - use syncAllPositionsBatch for better performance + */ + private async syncPositionsForPosMaster( + queryRunner: any, + draftPosMasterId: string, + currentPosMasterId: string, + _draftRevisionId: string, + _currentRevisionId: string, + nextHolderId: string | null | undefined, + ): Promise<{ deleted: number; updated: number; inserted: number }> { + // Fetch draft and current positions for this posMaster + const [draftPositions, currentPositions] = await Promise.all([ + queryRunner.manager.find(Position, { + where: { + posMasterId: draftPosMasterId, + }, + order: { orderNo: "ASC" }, + }), + queryRunner.manager.find(Position, { + where: { + posMasterId: currentPosMasterId, + }, + }), + ]); + + // If no draft positions, delete all current positions + if (draftPositions.length === 0) { + if (currentPositions.length > 0) { + await queryRunner.manager.delete( + Position, + currentPositions.map((p: any) => p.id), + ); + } + return { deleted: currentPositions.length, updated: 0, inserted: 0 }; + } + + // Build maps for tracking + const currentByOrderNo = new Map(currentPositions.map((p: any) => [p.orderNo, p])); + + // DELETE: Current positions not in draft (by orderNo) + const draftOrderNos = new Set(draftPositions.map((p: any) => p.orderNo)); + const toDelete = currentPositions.filter((p: any) => !draftOrderNos.has(p.orderNo)); + + if (toDelete.length > 0) { + await queryRunner.manager.delete( + Position, + toDelete.map((p: any) => p.id), + ); + } + + // UPDATE and INSERT + let updatedCount = 0; + let insertedCount = 0; + for (const draftPos of draftPositions) { + const current: any = currentByOrderNo.get(draftPos.orderNo); + + if (current) { + // UPDATE existing position + await queryRunner.manager.update(Position, current.id, { + positionName: draftPos.positionName, + positionField: draftPos.positionField, + posTypeId: draftPos.posTypeId, + posLevelId: draftPos.posLevelId, + posExecutiveId: draftPos.posExecutiveId, + positionExecutiveField: draftPos.positionExecutiveField, + positionArea: draftPos.positionArea, + isSpecial: draftPos.isSpecial, + orderNo: draftPos.orderNo, + positionIsSelected: draftPos.positionIsSelected, + lastUpdateFullName: draftPos.lastUpdateFullName, + lastUpdatedAt: new Date(), + }); + updatedCount++; + } else { + // INSERT new position + const newPosition = queryRunner.manager.create(Position, { + ...draftPos, + id: undefined, + posMasterId: currentPosMasterId, + }); + await queryRunner.manager.save(newPosition); + insertedCount++; + } + + // update profile + if (nextHolderId != null && draftPos.positionIsSelected) { + await queryRunner.manager.update(Profile, nextHolderId, { + position: draftPos.positionName, + posTypeId: draftPos.posTypeId, + posLevelId: draftPos.posLevelId, + }); + } + } + + return { deleted: toDelete.length, updated: updatedCount, inserted: insertedCount }; + } + /** * Batch version: Sync positions for ALL posMasters in a single operation * This significantly reduces database round trips for large organizations @@ -8577,7 +8674,6 @@ export class OrganizationController extends Controller { // Collect all operations const allToDelete: string[] = []; - const allToDeleteHistory: string[] = []; const allToUpdate: Array<{ id: string; data: any }> = []; const allToInsert: Array = []; const profileUpdates: Map = new Map(); @@ -8600,7 +8696,6 @@ export class OrganizationController extends Controller { // If no draft positions, mark all current positions for deletion if (draftPositions.length === 0) { allToDelete.push(...currentPositions.map((p: any) => p.id)); - allToDeleteHistory.push(...currentPositions.map((p: any) => p.ancestorDNA)); continue; } @@ -8612,7 +8707,6 @@ export class OrganizationController extends Controller { for (const currentPos of currentPositions) { if (!draftOrderNos.has(currentPos.orderNo)) { allToDelete.push(currentPos.id); - allToDeleteHistory.push(currentPos.ancestorDNA); } } @@ -8648,6 +8742,10 @@ export class OrganizationController extends Controller { }); } + if (nextHolderId === null) { + await SavePosMasterHistoryOfficer(queryRunner, draftPos.ancestorDNA, null, null); + } + // Collect profile update for the selected position if (nextHolderId != null && draftPos.positionIsSelected) { profileUpdates.set(nextHolderId, { @@ -8655,8 +8753,10 @@ export class OrganizationController extends Controller { posTypeId: draftPos.posTypeId, posLevelId: draftPos.posLevelId, }); + } - // Collect history data for the selected position + // Collect history data for the selected position + if (nextHolderId != null && draftPos.positionIsSelected) { const draftPosMaster = draftPosMasterMap.get(draftPosMasterId) as any; if (draftPosMaster && draftPosMaster.ancestorDNA) { // Find the selected position from draft positions @@ -8705,11 +8805,6 @@ export class OrganizationController extends Controller { // Bulk DELETE if (allToDelete.length > 0) { await queryRunner.manager.delete(Position, allToDelete); - await Promise.all( - allToDeleteHistory.map(async (ancestorDNA) => { - await SavePosMasterHistoryOfficer(queryRunner, ancestorDNA, null, null); - }), - ); deletedCount = allToDelete.length; } diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 8f5dd6ac..16566685 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -1359,7 +1359,7 @@ export class OrganizationDotnetController extends Controller { order: { commandDateAffect: "DESC" }, }), this.insigniaRepo.findOne({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { receiveDate: "DESC" }, }), ]); @@ -1542,7 +1542,7 @@ export class OrganizationDotnetController extends Controller { order: { commandDateAffect: "DESC" }, }), this.insigniaRepo.findOne({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { receiveDate: "DESC" }, }), ]); @@ -2379,7 +2379,7 @@ export class OrganizationDotnetController extends Controller { order: { commandDateAffect: "DESC" }, }), this.insigniaRepo.findOne({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { receiveDate: "DESC" }, }), ]); @@ -2694,7 +2694,7 @@ export class OrganizationDotnetController extends Controller { order: { commandDateAffect: "DESC" }, }), this.insigniaRepo.findOne({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { receiveDate: "DESC" }, }), ]); @@ -7441,7 +7441,7 @@ export class OrganizationDotnetController extends Controller { : []; const profileEducations = await this.educationRepo.find({ - where: { profileEmployeeId: profile!.id, isDeleted: false }, + where: { profileEmployeeId: profile!.id }, order: { level: "ASC" }, }); _educations = profileEducations.length > 0 @@ -7581,7 +7581,7 @@ export class OrganizationDotnetController extends Controller { : []; const profileEducations = await this.educationRepo.find({ - where: { profileId: profile!.id, isDeleted: false }, + where: { profileId: profile!.id }, order: { level: "ASC" }, }); _educations = profileEducations.length > 0 diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index deaa1f35..d2ec617d 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -423,7 +423,6 @@ export class OrganizationUnauthorizeController extends Controller { year: body.year.toString(), pointSum: MoreThanOrEqual(90), period: body.period.toLocaleUpperCase(), - isDeleted: false } } ); @@ -885,7 +884,6 @@ export class OrganizationUnauthorizeController extends Controller { year: body.year.toString(), pointSum: MoreThanOrEqual(90), period: body.period.toLocaleUpperCase(), - isDeleted: false } } ); @@ -1090,7 +1088,7 @@ export class OrganizationUnauthorizeController extends Controller { order: { commandDateAffect: "DESC" }, }), this.insigniaRepo.findOne({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { receiveDate: "DESC" }, }), ]); @@ -1405,7 +1403,7 @@ export class OrganizationUnauthorizeController extends Controller { order: { commandDateAffect: "DESC" }, }), this.insigniaRepo.findOne({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { receiveDate: "DESC" }, }), ]); diff --git a/src/controllers/PosMasterActController.ts b/src/controllers/PosMasterActController.ts index 81a61bf4..7c63ede5 100644 --- a/src/controllers/PosMasterActController.ts +++ b/src/controllers/PosMasterActController.ts @@ -598,7 +598,6 @@ export class PosMasterActController extends Controller { "lastUpdateFullName", "lastUpdatedAt", "dateEnd", - "isDeleted" ], where: { profileId, status: true, isDeleted: false }, }); diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index c8012057..0fd2c117 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -40,7 +40,7 @@ export class ProfileAbilityController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAbilityId = await this.profileAbilityRepo.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { @@ -55,7 +55,7 @@ export class ProfileAbilityController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const getProfileAbilityId = await this.profileAbilityRepo.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { diff --git a/src/controllers/ProfileAbilityEmployeeController.ts b/src/controllers/ProfileAbilityEmployeeController.ts index d7ba3ae9..3ac38706 100644 --- a/src/controllers/ProfileAbilityEmployeeController.ts +++ b/src/controllers/ProfileAbilityEmployeeController.ts @@ -40,7 +40,7 @@ export class ProfileAbilityEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAbilityId = await this.profileAbilityRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { @@ -58,7 +58,7 @@ export class ProfileAbilityEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileAbilityId = await this.profileAbilityRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { diff --git a/src/controllers/ProfileAbilityEmployeeTempController.ts b/src/controllers/ProfileAbilityEmployeeTempController.ts index 624c8ded..0c0b3723 100644 --- a/src/controllers/ProfileAbilityEmployeeTempController.ts +++ b/src/controllers/ProfileAbilityEmployeeTempController.ts @@ -40,7 +40,7 @@ export class ProfileAbilityEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAbilityId = await this.profileAbilityRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { @@ -57,7 +57,7 @@ export class ProfileAbilityEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const getProfileAbilityId = await this.profileAbilityRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { diff --git a/src/controllers/ProfileAssessmentsController.ts b/src/controllers/ProfileAssessmentsController.ts index 53906cb2..f8ca30e0 100644 --- a/src/controllers/ProfileAssessmentsController.ts +++ b/src/controllers/ProfileAssessmentsController.ts @@ -41,7 +41,7 @@ export class ProfileAssessmentsController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAssessments = await this.profileAssessmentsRepository.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { @@ -59,7 +59,7 @@ export class ProfileAssessmentsController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const getProfileAssessments = await this.profileAssessmentsRepository.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { diff --git a/src/controllers/ProfileAssessmentsEmployeeController.ts b/src/controllers/ProfileAssessmentsEmployeeController.ts index 0f7f3d81..26127f3e 100644 --- a/src/controllers/ProfileAssessmentsEmployeeController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeController.ts @@ -41,7 +41,7 @@ export class ProfileAssessmentsEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAssessments = await this.profileAssessmentsRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { @@ -61,7 +61,6 @@ export class ProfileAssessmentsEmployeeController extends Controller { const getProfileAssessments = await this.profileAssessmentsRepository.find({ where: { profileEmployeeId: profileEmployeeId, - isDeleted: false }, order: { createdAt: "ASC" }, }); diff --git a/src/controllers/ProfileAssessmentsEmployeeTempController.ts b/src/controllers/ProfileAssessmentsEmployeeTempController.ts index b6bc45e6..2aa62ff7 100644 --- a/src/controllers/ProfileAssessmentsEmployeeTempController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeTempController.ts @@ -41,7 +41,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAssessments = await this.profileAssessmentsRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { @@ -60,7 +60,6 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { const getProfileAssessments = await this.profileAssessmentsRepository.find({ where: { profileEmployeeId: profileEmployeeId, - isDeleted: false }, order: { createdAt: "ASC" }, }); diff --git a/src/controllers/ProfileAssistanceController.ts b/src/controllers/ProfileAssistanceController.ts index 3690f5e6..abff2a9f 100644 --- a/src/controllers/ProfileAssistanceController.ts +++ b/src/controllers/ProfileAssistanceController.ts @@ -40,7 +40,7 @@ export class ProfileAssistanceController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAssistanceId = await this.profileAssistanceRepo.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAssistanceId) { @@ -55,7 +55,7 @@ export class ProfileAssistanceController extends Controller { // if (_workflow == false) // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const getProfileAssistanceId = await this.profileAssistanceRepo.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); if (!getProfileAssistanceId) { diff --git a/src/controllers/ProfileAssistanceEmployeeController.ts b/src/controllers/ProfileAssistanceEmployeeController.ts index 88617322..cbd816b9 100644 --- a/src/controllers/ProfileAssistanceEmployeeController.ts +++ b/src/controllers/ProfileAssistanceEmployeeController.ts @@ -40,7 +40,7 @@ export class ProfileAssistanceEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAssistanceId = await this.profileAssistanceRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAssistanceId) { @@ -58,7 +58,7 @@ export class ProfileAssistanceEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileAssistanceId = await this.profileAssistanceRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); if (!getProfileAssistanceId) { diff --git a/src/controllers/ProfileAssistanceEmployeeTempController.ts b/src/controllers/ProfileAssistanceEmployeeTempController.ts index da37c3a5..534dafa2 100644 --- a/src/controllers/ProfileAssistanceEmployeeTempController.ts +++ b/src/controllers/ProfileAssistanceEmployeeTempController.ts @@ -40,7 +40,7 @@ export class ProfileAssistanceEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileAssistanceId = await this.profileAssistanceRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); if (!getProfileAssistanceId) { @@ -57,7 +57,7 @@ export class ProfileAssistanceEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const getProfileAssistanceId = await this.profileAssistanceRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); if (!getProfileAssistanceId) { diff --git a/src/controllers/ProfileCertificateController.ts b/src/controllers/ProfileCertificateController.ts index 5cbc019a..88d5c492 100644 --- a/src/controllers/ProfileCertificateController.ts +++ b/src/controllers/ProfileCertificateController.ts @@ -40,7 +40,7 @@ export class ProfileCertificateController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const record = await this.certificateRepo.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -52,7 +52,7 @@ export class ProfileCertificateController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.certificateRepo.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileCertificateEmployeeController.ts b/src/controllers/ProfileCertificateEmployeeController.ts index 6bb4c1df..fb6474e0 100644 --- a/src/controllers/ProfileCertificateEmployeeController.ts +++ b/src/controllers/ProfileCertificateEmployeeController.ts @@ -40,7 +40,7 @@ export class ProfileCertificateEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const record = await this.certificateRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -52,7 +52,7 @@ export class ProfileCertificateEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.certificateRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileCertificateEmployeeTempController.ts b/src/controllers/ProfileCertificateEmployeeTempController.ts index f5619023..20ec902b 100644 --- a/src/controllers/ProfileCertificateEmployeeTempController.ts +++ b/src/controllers/ProfileCertificateEmployeeTempController.ts @@ -40,7 +40,7 @@ export class ProfileCertificateEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const record = await this.certificateRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -51,7 +51,7 @@ export class ProfileCertificateEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.certificateRepo.find({ - where: { profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index 5b772f12..92ce5350 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -41,7 +41,7 @@ export class ProfileChangeNameController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.changeNameRepository.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -53,7 +53,7 @@ export class ProfileChangeNameController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.changeNameRepository.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileChangeNameEmployeeController.ts b/src/controllers/ProfileChangeNameEmployeeController.ts index 547368e1..51ff0b8e 100644 --- a/src/controllers/ProfileChangeNameEmployeeController.ts +++ b/src/controllers/ProfileChangeNameEmployeeController.ts @@ -41,7 +41,7 @@ export class ProfileChangeNameEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.changeNameRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -53,7 +53,7 @@ export class ProfileChangeNameEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const lists = await this.changeNameRepository.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileChangeNameEmployeeTempController.ts b/src/controllers/ProfileChangeNameEmployeeTempController.ts index f7a141f7..152279d6 100644 --- a/src/controllers/ProfileChangeNameEmployeeTempController.ts +++ b/src/controllers/ProfileChangeNameEmployeeTempController.ts @@ -41,7 +41,7 @@ export class ProfileChangeNameEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.changeNameRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -52,7 +52,7 @@ export class ProfileChangeNameEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.changeNameRepository.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileChildrenController.ts b/src/controllers/ProfileChildrenController.ts index 577b6781..27075758 100644 --- a/src/controllers/ProfileChildrenController.ts +++ b/src/controllers/ProfileChildrenController.ts @@ -41,7 +41,7 @@ export class ProfileChildrenController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.childrenRepository.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -53,7 +53,7 @@ export class ProfileChildrenController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.childrenRepository.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileChildrenEmployeeController.ts b/src/controllers/ProfileChildrenEmployeeController.ts index 7a0cd772..a8792e7b 100644 --- a/src/controllers/ProfileChildrenEmployeeController.ts +++ b/src/controllers/ProfileChildrenEmployeeController.ts @@ -41,7 +41,7 @@ export class ProfileChildrenEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.childrenRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -53,7 +53,7 @@ export class ProfileChildrenEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const lists = await this.childrenRepository.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileChildrenEmployeeTempController.ts b/src/controllers/ProfileChildrenEmployeeTempController.ts index 2134e954..4ee31e5f 100644 --- a/src/controllers/ProfileChildrenEmployeeTempController.ts +++ b/src/controllers/ProfileChildrenEmployeeTempController.ts @@ -41,7 +41,7 @@ export class ProfileChildrenEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.childrenRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -52,7 +52,7 @@ export class ProfileChildrenEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.childrenRepository.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 14a77d7f..41fe95e7 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -322,8 +322,8 @@ export class ProfileController extends Controller { ]; const educations = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], - where: { profileId: id, isDeleted: false }, + select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], + where: { profileId: id }, order: { level: "ASC" }, }); const Education = @@ -575,8 +575,8 @@ export class ProfileController extends Controller { let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ - select: ["certificateType", "issuer", "certificateNo", "issueDate", "isDeleted"], - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, + select: ["certificateType", "issuer", "certificateNo", "issueDate"], order: { createdAt: "ASC" }, }); const certs = @@ -596,8 +596,8 @@ export class ProfileController extends Controller { }, ]; const training_raw = await this.trainingRepository.find({ - select: ["startDate", "endDate", "place", "department", "name", "isDeleted"], - where: { profileId: id, isDeleted: false }, + select: ["startDate", "endDate", "place", "department", "name"], + where: { profileId: id }, order: { createdAt: "ASC" }, }); const trainings = @@ -633,8 +633,8 @@ export class ProfileController extends Controller { ]; const discipline_raw = await this.disciplineRepository.find({ - select: ["refCommandDate", "refCommandNo", "detail", "isDeleted"], - where: { profileId: id, isDeleted: false }, + select: ["refCommandDate", "refCommandNo", "detail"], + where: { profileId: id }, order: { createdAt: "ASC" }, }); const disciplines = @@ -655,8 +655,8 @@ export class ProfileController extends Controller { ]; const education_raw = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], - where: { profileId: id, isDeleted: false }, + select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], + where: { profileId: id }, // order: { lastUpdatedAt: "DESC" }, order: { level: "ASC" }, }); @@ -756,7 +756,7 @@ export class ProfileController extends Controller { insigniaType: true, }, }, - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, order: { receiveDate: "ASC" }, }); const insignias = @@ -796,7 +796,7 @@ export class ProfileController extends Controller { const leave_raw = await this.profileLeaveRepository.find({ relations: { leaveType: true }, - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, order: { dateLeaveStart: "ASC" }, }); const leaves = @@ -1052,8 +1052,8 @@ export class ProfileController extends Controller { let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ - select: ["certificateType", "issuer", "certificateNo", "issueDate", "expireDate", "isDeleted"], - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, + select: ["certificateType", "issuer", "certificateNo", "issueDate", "expireDate"], order: { createdAt: "ASC" }, }); const certs = @@ -1087,8 +1087,8 @@ export class ProfileController extends Controller { }, ]; const training_raw = await this.trainingRepository.find({ - select: ["place", "department", "name", "duration", "isDeleted"], - where: { profileId: id, isDeleted: false }, + select: ["place", "department", "name", "duration"], + where: { profileId: id }, order: { createdAt: "ASC" }, }); const trainings = @@ -1109,8 +1109,8 @@ export class ProfileController extends Controller { ]; const discipline_raw = await this.disciplineRepository.find({ - select: ["refCommandDate", "refCommandNo", "detail", "level", "isDeleted"], - where: { profileId: id, isDeleted: false }, + select: ["refCommandDate", "refCommandNo", "detail", "level"], + where: { profileId: id }, order: { createdAt: "ASC" }, }); const disciplines = @@ -1135,7 +1135,6 @@ export class ProfileController extends Controller { const education_raw = await this.profileEducationRepo .createQueryBuilder("education") .where("education.profileId = :profileId", { profileId: id }) - .andWhere("education.isDeleted = :isDeleted", { isDeleted: false }) .orderBy("CASE WHEN education.isEducation = true THEN 1 ELSE 2 END", "ASC") .addOrderBy("education.level", "ASC") .getMany(); @@ -1246,14 +1245,13 @@ export class ProfileController extends Controller { "page", "refCommandDate", "note", - "isDeleted" ], relations: { insignia: { insigniaType: true, }, }, - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, order: { receiveDate: "ASC" }, }); const insignias = @@ -1296,7 +1294,6 @@ export class ProfileController extends Controller { .createQueryBuilder("profileLeave") .leftJoinAndSelect("profileLeave.leaveType", "leaveType") .select([ - "profileLeave.isDeleted", "profileLeave.leaveTypeId", "leaveType.name as name", "leaveType.code as code", @@ -1306,7 +1303,6 @@ export class ProfileController extends Controller { ]) .addSelect("SUM(profileLeave.leaveDays)", "totalLeaveDays") .where("profileLeave.profileId = :profileId", { profileId: id }) - .andWhere("profileLeave.isDeleted = :isDeleted", { isDeleted: false }) .andWhere("profileLeave.status = :status", { status: "approve" }) .groupBy("profileLeave.leaveTypeId") .orderBy("code", "ASC") @@ -1358,7 +1354,6 @@ export class ProfileController extends Controller { .createQueryBuilder("profileLeave") .leftJoinAndSelect("profileLeave.leaveType", "leaveType") .select([ - "profileLeave.isDeleted AS isDeleted", "profileLeave.dateLeaveStart AS dateLeaveStart", "profileLeave.dateLeaveEnd AS dateLeaveEnd", "profileLeave.leaveDays AS leaveDays", @@ -1366,7 +1361,6 @@ export class ProfileController extends Controller { "leaveType.name as name", ]) .where("profileLeave.profileId = :profileId", { profileId: id }) - .andWhere("profileLeave.isDeleted = :isDeleted", { isDeleted: false }) .andWhere("leaveType.code IN (:...codes)", { codes: ["LV-008", "LV-009", "LV-010"] }) .andWhere("profileLeave.status = :status", { status: "approve" }) .orderBy("leaveType.code", "ASC") @@ -1393,7 +1387,7 @@ export class ProfileController extends Controller { }, ]; const children_raw = await this.profileChildrenRepository.find({ - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, }); const children = children_raw.length > 0 @@ -1416,7 +1410,7 @@ export class ProfileController extends Controller { }, ]; const changeName_raw = await this.changeNameRepository.find({ - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, order: { createdAt: "ASC" }, }); const changeName = @@ -1510,13 +1504,13 @@ export class ProfileController extends Controller { ]; const actposition_raw = await this.profileActpositionRepo.find({ - select: ["dateStart", "dateEnd", "position", "isDeleted"], + select: ["dateStart", "dateEnd", "position"], where: { profileId: id, isDeleted: false }, order: { createdAt: "ASC" }, }); const assistance_raw = await this.profileAssistanceRepository.find({ - select: ["dateStart", "dateEnd", "commandName", "agency", "document", "isDeleted"], - where: { profileId: id, isDeleted: false }, + select: ["dateStart", "dateEnd", "commandName", "agency", "document"], + where: { profileId: id }, order: { createdAt: "ASC" }, }); @@ -1572,7 +1566,7 @@ export class ProfileController extends Controller { ]; const actposition = [..._actposition, ..._assistance]; const duty_raw = await this.dutyRepository.find({ - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, order: { createdAt: "ASC" }, }); const duty = @@ -1599,7 +1593,7 @@ export class ProfileController extends Controller { }, ]; const assessments_raw = await this.profileAssessmentsRepository.find({ - where: { profileId: id, isDeleted: false }, + where: { profileId: id }, order: { createdAt: "ASC" }, }); const assessments = @@ -9099,7 +9093,7 @@ export class ProfileController extends Controller { )?.posMasterNo; const latestProfileEducation = await this.profileEducationRepo.findOne({ - where: { profileId: item.id, isDeleted: false }, + where: { profileId: item.id }, order: { level: "ASC" }, }); @@ -11112,7 +11106,7 @@ export class ProfileController extends Controller { } const latestProfileEducation = await this.profileEducationRepo.findOne({ - where: { profileId: item.id, isDeleted: false }, + where: { profileId: item.id }, order: { level: "ASC" }, }); diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index e7ec5a94..9edfd89d 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -40,7 +40,7 @@ export class ProfileDisciplineController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.disciplineRepository.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -52,7 +52,7 @@ export class ProfileDisciplineController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.disciplineRepository.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -63,7 +63,7 @@ export class ProfileDisciplineController extends Controller { let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); const lists = await this.disciplineRepository.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileDisciplineEmployeeController.ts b/src/controllers/ProfileDisciplineEmployeeController.ts index 22dd3f24..efb3842b 100644 --- a/src/controllers/ProfileDisciplineEmployeeController.ts +++ b/src/controllers/ProfileDisciplineEmployeeController.ts @@ -40,7 +40,7 @@ export class ProfileDisciplineEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.disciplineRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -52,7 +52,7 @@ export class ProfileDisciplineEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.disciplineRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -63,7 +63,7 @@ export class ProfileDisciplineEmployeeController extends Controller { let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const lists = await this.disciplineRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileDisciplineEmployeeTempController.ts b/src/controllers/ProfileDisciplineEmployeeTempController.ts index b1100ab2..b408dfe1 100644 --- a/src/controllers/ProfileDisciplineEmployeeTempController.ts +++ b/src/controllers/ProfileDisciplineEmployeeTempController.ts @@ -40,7 +40,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.disciplineRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -51,7 +51,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.disciplineRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -62,7 +62,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const lists = await this.disciplineRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileDutyController.ts b/src/controllers/ProfileDutyController.ts index 43161383..36aee9ea 100644 --- a/src/controllers/ProfileDutyController.ts +++ b/src/controllers/ProfileDutyController.ts @@ -36,7 +36,7 @@ export class ProfileDutyController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.dutyRepository.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -48,7 +48,7 @@ export class ProfileDutyController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.dutyRepository.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileDutyEmployeeController.ts b/src/controllers/ProfileDutyEmployeeController.ts index 82a3e9b4..811ce550 100644 --- a/src/controllers/ProfileDutyEmployeeController.ts +++ b/src/controllers/ProfileDutyEmployeeController.ts @@ -36,7 +36,7 @@ export class ProfileDutyEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.dutyRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -48,7 +48,7 @@ export class ProfileDutyEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.dutyRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileDutyEmployeeTempController.ts b/src/controllers/ProfileDutyEmployeeTempController.ts index 09f8f843..31e83d27 100644 --- a/src/controllers/ProfileDutyEmployeeTempController.ts +++ b/src/controllers/ProfileDutyEmployeeTempController.ts @@ -36,7 +36,7 @@ export class ProfileDutyEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.dutyRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -47,7 +47,7 @@ export class ProfileDutyEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.dutyRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileEducationsController.ts b/src/controllers/ProfileEducationsController.ts index e9013eea..43843960 100644 --- a/src/controllers/ProfileEducationsController.ts +++ b/src/controllers/ProfileEducationsController.ts @@ -42,7 +42,7 @@ export class ProfileEducationsController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileEducation = await this.profileEducationRepo.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { level: "ASC" }, }); if (!getProfileEducation) { @@ -57,7 +57,7 @@ export class ProfileEducationsController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const getProfileEducation = await this.profileEducationRepo.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { level: "ASC" }, }); if (!getProfileEducation) { diff --git a/src/controllers/ProfileEducationsEmployeeController.ts b/src/controllers/ProfileEducationsEmployeeController.ts index c81a7309..cde8c6ec 100644 --- a/src/controllers/ProfileEducationsEmployeeController.ts +++ b/src/controllers/ProfileEducationsEmployeeController.ts @@ -42,7 +42,7 @@ export class ProfileEducationsEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileEducation = await this.profileEducationRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { level: "ASC" }, }); if (!getProfileEducation) { @@ -60,7 +60,7 @@ export class ProfileEducationsEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileEducation = await this.profileEducationRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { level: "ASC" }, }); if (!getProfileEducation) { diff --git a/src/controllers/ProfileEducationsEmployeeTempController.ts b/src/controllers/ProfileEducationsEmployeeTempController.ts index a63c88f7..e90dfc1c 100644 --- a/src/controllers/ProfileEducationsEmployeeTempController.ts +++ b/src/controllers/ProfileEducationsEmployeeTempController.ts @@ -42,7 +42,7 @@ export class ProfileEducationsEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const getProfileEducation = await this.profileEducationRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { level: "ASC" }, }); if (!getProfileEducation) { @@ -59,7 +59,7 @@ export class ProfileEducationsEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const getProfileEducation = await this.profileEducationRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { level: "ASC" }, }); if (!getProfileEducation) { diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 6b2e6688..e87adcac 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -317,8 +317,8 @@ export class ProfileEmployeeController extends Controller { ]; const educations = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], + where: { profileEmployeeId: id }, order: { level: "ASC" }, }); const Education = @@ -571,8 +571,8 @@ export class ProfileEmployeeController extends Controller { let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ - select: ["certificateType", "issuer", "certificateNo", "issueDate", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, + select: ["certificateType", "issuer", "certificateNo", "issueDate"], order: { createdAt: "ASC" }, }); const certs = @@ -592,8 +592,8 @@ export class ProfileEmployeeController extends Controller { }, ]; const training_raw = await this.trainingRepository.find({ - select: ["startDate", "endDate", "place", "department", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["startDate", "endDate", "place", "department"], + where: { profileEmployeeId: id }, order: { createdAt: "ASC" }, }); const trainings = @@ -629,8 +629,8 @@ export class ProfileEmployeeController extends Controller { ]; const discipline_raw = await this.disciplineRepository.find({ - select: ["refCommandDate", "refCommandNo", "detail", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["refCommandDate", "refCommandNo", "detail"], + where: { profileEmployeeId: id }, order: { createdAt: "ASC" }, }); const disciplines = @@ -651,8 +651,8 @@ export class ProfileEmployeeController extends Controller { ]; const education_raw = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], + where: { profileEmployeeId: id }, // order: { lastUpdatedAt: "DESC" }, order: { level: "ASC" }, }); @@ -752,7 +752,7 @@ export class ProfileEmployeeController extends Controller { insigniaType: true, }, }, - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, order: { receiveDate: "ASC" }, }); const insignias = @@ -792,7 +792,7 @@ export class ProfileEmployeeController extends Controller { const leave_raw = await this.profileLeaveRepository.find({ relations: { leaveType: true }, - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, order: { dateLeaveStart: "ASC" }, }); const leaves = @@ -1048,8 +1048,8 @@ export class ProfileEmployeeController extends Controller { let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ - select: ["certificateType", "issuer", "certificateNo", "issueDate", "expireDate", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, + select: ["certificateType", "issuer", "certificateNo", "issueDate", "expireDate"], order: { createdAt: "ASC" }, }); const certs = @@ -1083,8 +1083,8 @@ export class ProfileEmployeeController extends Controller { }, ]; const training_raw = await this.trainingRepository.find({ - select: ["place", "department", "name", "duration", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["place", "department", "name", "duration"], + where: { profileEmployeeId: id }, order: { createdAt: "ASC" }, }); const trainings = @@ -1105,8 +1105,8 @@ export class ProfileEmployeeController extends Controller { ]; const discipline_raw = await this.disciplineRepository.find({ - select: ["refCommandDate", "refCommandNo", "detail", "level", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["refCommandDate", "refCommandNo", "detail", "level"], + where: { profileEmployeeId: id }, order: { createdAt: "ASC" }, }); const disciplines = @@ -1131,7 +1131,6 @@ export class ProfileEmployeeController extends Controller { const education_raw = await this.profileEducationRepo .createQueryBuilder("education") .where("education.profileEmployeeId = :profileId", { profileId: id }) - .andWhere("education.isDeleted = :isDeleted", { isDeleted: false }) .orderBy("CASE WHEN education.isEducation = true THEN 1 ELSE 2 END", "ASC") .addOrderBy("education.level", "ASC") .getMany(); @@ -1242,14 +1241,13 @@ export class ProfileEmployeeController extends Controller { "page", "refCommandDate", "note", - "isDeleted" ], relations: { insignia: { insigniaType: true, }, }, - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, order: { receiveDate: "ASC" }, }); const insignias = @@ -1292,7 +1290,6 @@ export class ProfileEmployeeController extends Controller { .createQueryBuilder("profileLeave") .leftJoinAndSelect("profileLeave.leaveType", "leaveType") .select([ - "profileLeave.isDeleted", "profileLeave.leaveTypeId", "leaveType.name as name", "leaveType.code as code", @@ -1302,7 +1299,6 @@ export class ProfileEmployeeController extends Controller { ]) .addSelect("SUM(profileLeave.leaveDays)", "totalLeaveDays") .where("profileLeave.profileEmployeeId = :profileId", { profileId: id }) - .andWhere("profileLeave.isDeleted = :isDeleted", { isDeleted: false }) .andWhere("profileLeave.status = :status", { status: "approve" }) .groupBy("profileLeave.leaveTypeId") .orderBy("code", "ASC") @@ -1354,7 +1350,6 @@ export class ProfileEmployeeController extends Controller { .createQueryBuilder("profileLeave") .leftJoinAndSelect("profileLeave.leaveType", "leaveType") .select([ - "profileLeave.isDeleted AS isDeleted", "profileLeave.dateLeaveStart AS dateLeaveStart", "profileLeave.dateLeaveEnd AS dateLeaveEnd", "profileLeave.leaveDays AS leaveDays", @@ -1362,7 +1357,6 @@ export class ProfileEmployeeController extends Controller { "leaveType.name as name", ]) .where("profileLeave.profileEmployeeId = :profileId", { profileId: id }) - .andWhere("profileLeave.isDeleted = :isDeleted", { isDeleted: false }) .andWhere("leaveType.code IN (:...codes)", { codes: ["LV-008", "LV-009", "LV-010"] }) .andWhere("profileLeave.status = :status", { status: "approve" }) .orderBy("leaveType.code", "ASC") @@ -1389,7 +1383,7 @@ export class ProfileEmployeeController extends Controller { }, ]; const children_raw = await this.profileChildrenRepository.find({ - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, }); const children = children_raw.length > 0 @@ -1412,7 +1406,7 @@ export class ProfileEmployeeController extends Controller { }, ]; const changeName_raw = await this.changeNameRepository.find({ - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, order: { createdAt: "ASC" }, }); const changeName = @@ -1506,13 +1500,13 @@ export class ProfileEmployeeController extends Controller { ]; const actposition_raw = await this.profileActpositionRepo.find({ - select: ["dateStart", "dateEnd", "position", "isDeleted"], + select: ["dateStart", "dateEnd", "position"], where: { profileEmployeeId: id, isDeleted: false }, order: { createdAt: "ASC" }, }); const assistance_raw = await this.profileAssistanceRepository.find({ - select: ["dateStart", "dateEnd", "commandName", "agency", "document", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["dateStart", "dateEnd", "commandName", "agency", "document"], + where: { profileEmployeeId: id }, order: { createdAt: "ASC" }, }); @@ -1568,7 +1562,7 @@ export class ProfileEmployeeController extends Controller { ]; const actposition = [..._actposition, ..._assistance]; const duty_raw = await this.dutyRepository.find({ - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, order: { createdAt: "ASC" }, }); const duty = @@ -1595,7 +1589,7 @@ export class ProfileEmployeeController extends Controller { }, ]; const assessments_raw = await this.profileAssessmentsRepository.find({ - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, order: { createdAt: "ASC" }, }); const assessments = @@ -3860,7 +3854,7 @@ export class ProfileEmployeeController extends Controller { )?.posMasterNo; const latestProfileEducation = await this.profileEducationRepo.findOne({ - where: { profileEmployeeId: item.id, isDeleted: false }, + where: { profileEmployeeId: item.id }, order: { level: "ASC" }, }); @@ -5959,7 +5953,7 @@ export class ProfileEmployeeController extends Controller { } const latestProfileEducation = await this.profileEducationRepo.findOne({ - where: { profileEmployeeId: item.id, isDeleted: false }, + where: { profileEmployeeId: item.id }, order: { level: "ASC" }, }); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 096b3190..efe59ca2 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -289,8 +289,8 @@ export class ProfileEmployeeTempController extends Controller { }, ]; const educations = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], + where: { profileEmployeeId: id }, order: { level: "ASC" }, }); const Education = @@ -547,8 +547,8 @@ export class ProfileEmployeeTempController extends Controller { let _child4 = child4?.orgChild4Name; const cert_raw = await this.certificateRepository.find({ - select: ["certificateType", "issuer", "certificateNo", "issueDate", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, + select: ["certificateType", "issuer", "certificateNo", "issueDate"], order: { createdAt: "ASC" }, }); const certs = @@ -627,8 +627,8 @@ export class ProfileEmployeeTempController extends Controller { ]; const education_raw = await this.profileEducationRepo.find({ - select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute", "isDeleted"], - where: { profileEmployeeId: id, isDeleted: false }, + select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"], + where: { profileEmployeeId: id }, // order: { lastUpdatedAt: "DESC" }, order: { level: "ASC" }, }); @@ -734,7 +734,7 @@ export class ProfileEmployeeTempController extends Controller { insigniaType: true, }, }, - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, order: { receiveDate: "ASC" }, }); const insignias = @@ -774,7 +774,7 @@ export class ProfileEmployeeTempController extends Controller { const leave_raw = await this.profileLeaveRepository.find({ relations: { leaveType: true }, - where: { profileEmployeeId: id, isDeleted: false }, + where: { profileEmployeeId: id }, order: { dateLeaveStart: "ASC" }, }); const leaves = @@ -2370,7 +2370,7 @@ export class ProfileEmployeeTempController extends Controller { )?.posMasterNo; const latestProfileEducation = await this.profileEducationRepo.findOne({ - where: { profileEmployeeId: item.id, isDeleted: false }, + where: { profileEmployeeId: item.id }, order: { level: "ASC" }, }); @@ -4043,7 +4043,7 @@ export class ProfileEmployeeTempController extends Controller { )?.posMasterNo; const latestProfileEducation = await this.profileEducationRepo.findOne({ - where: { profileEmployeeId: item.id, isDeleted: false }, + where: { profileEmployeeId: item.id }, order: { level: "ASC" }, }); diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index 057f6ad0..114c76b3 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -36,7 +36,7 @@ export class ProfileHonorController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const record = await this.honorRepo.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -48,7 +48,7 @@ export class ProfileHonorController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.honorRepo.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileHonorEmployeeController.ts b/src/controllers/ProfileHonorEmployeeController.ts index bacb5ca5..11e6ddf8 100644 --- a/src/controllers/ProfileHonorEmployeeController.ts +++ b/src/controllers/ProfileHonorEmployeeController.ts @@ -40,7 +40,7 @@ export class ProfileHonorEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const record = await this.honorRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -52,7 +52,7 @@ export class ProfileHonorEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.honorRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileHonorEmployeeTempController.ts b/src/controllers/ProfileHonorEmployeeTempController.ts index dbf1ceb3..e163aa05 100644 --- a/src/controllers/ProfileHonorEmployeeTempController.ts +++ b/src/controllers/ProfileHonorEmployeeTempController.ts @@ -40,7 +40,7 @@ export class ProfileHonorEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const record = await this.honorRepo.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -51,7 +51,7 @@ export class ProfileHonorEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileEmployeeId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.honorRepo.find({ - where: { profileEmployeeId: profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId: profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index af871c69..47e267f4 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -50,7 +50,7 @@ export class ProfileInsigniaController extends Controller { insigniaType: true, }, }, - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -67,7 +67,7 @@ export class ProfileInsigniaController extends Controller { insigniaType: true, }, }, - where: { profileId, isDeleted: false }, + where: { profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileInsigniaEmployeeController.ts b/src/controllers/ProfileInsigniaEmployeeController.ts index e0d3ad82..1921a5fd 100644 --- a/src/controllers/ProfileInsigniaEmployeeController.ts +++ b/src/controllers/ProfileInsigniaEmployeeController.ts @@ -47,7 +47,7 @@ export class ProfileInsigniaEmployeeController extends Controller { insigniaType: true, }, }, - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -64,7 +64,7 @@ export class ProfileInsigniaEmployeeController extends Controller { insigniaType: true, }, }, - where: { profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileInsigniaEmployeeTempController.ts b/src/controllers/ProfileInsigniaEmployeeTempController.ts index 6f11cec3..c0f3ef71 100644 --- a/src/controllers/ProfileInsigniaEmployeeTempController.ts +++ b/src/controllers/ProfileInsigniaEmployeeTempController.ts @@ -47,7 +47,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller { insigniaType: true, }, }, - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -63,7 +63,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller { insigniaType: true, }, }, - where: { profileEmployeeId, isDeleted: false }, + where: { profileEmployeeId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index a6624bbb..f5601c02 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -120,7 +120,7 @@ export class ProfileLeaveController extends Controller { } const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -136,7 +136,6 @@ export class ProfileLeaveController extends Controller { where: { profileId: profileId, // status: Not("cancel") - isDeleted: false }, order: { createdAt: "ASC" }, }); @@ -149,7 +148,7 @@ export class ProfileLeaveController extends Controller { if (_workflow == false) await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileId, isDeleted: false }, + where: { profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index ade4a5c4..feb6891e 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -43,7 +43,7 @@ export class ProfileLeaveEmployeeController extends Controller { } const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -56,7 +56,7 @@ export class ProfileLeaveEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -68,7 +68,7 @@ export class ProfileLeaveEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileLeaveEmployeeTempController.ts b/src/controllers/ProfileLeaveEmployeeTempController.ts index 85960fa5..39506d32 100644 --- a/src/controllers/ProfileLeaveEmployeeTempController.ts +++ b/src/controllers/ProfileLeaveEmployeeTempController.ts @@ -43,7 +43,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { } const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -55,7 +55,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); @@ -67,7 +67,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE"); const record = await this.leaveRepo.find({ relations: { leaveType: true }, - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(record); diff --git a/src/controllers/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index d0760d13..491aaae5 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -36,7 +36,7 @@ export class ProfileNopaidController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.nopaidRepository.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -48,7 +48,7 @@ export class ProfileNopaidController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.nopaidRepository.find({ - where: { profileId, isDeleted: false }, + where: { profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileNopaidEmployeeController.ts b/src/controllers/ProfileNopaidEmployeeController.ts index e5849e8e..fd5b7353 100644 --- a/src/controllers/ProfileNopaidEmployeeController.ts +++ b/src/controllers/ProfileNopaidEmployeeController.ts @@ -40,7 +40,7 @@ export class ProfileNopaidEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.nopaidRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -51,7 +51,7 @@ export class ProfileNopaidEmployeeController extends Controller { let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_EMP"); const lists = await this.nopaidRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileNopaidEmployeeTempController.ts b/src/controllers/ProfileNopaidEmployeeTempController.ts index fe6edab3..37dec407 100644 --- a/src/controllers/ProfileNopaidEmployeeTempController.ts +++ b/src/controllers/ProfileNopaidEmployeeTempController.ts @@ -40,7 +40,7 @@ export class ProfileNopaidEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.nopaidRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -51,7 +51,7 @@ export class ProfileNopaidEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.nopaidRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileOtherController.ts b/src/controllers/ProfileOtherController.ts index 430af83e..79ae8c8f 100644 --- a/src/controllers/ProfileOtherController.ts +++ b/src/controllers/ProfileOtherController.ts @@ -37,7 +37,7 @@ export class ProfileOtherController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.otherRepository.find({ - where: { profileId: profile.id, isDeleted: false }, + where: { profileId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -49,7 +49,7 @@ export class ProfileOtherController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.otherRepository.find({ - where: { profileId: profileId, isDeleted: false }, + where: { profileId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileOtherEmployeeController.ts b/src/controllers/ProfileOtherEmployeeController.ts index c8894afe..0a6622b6 100644 --- a/src/controllers/ProfileOtherEmployeeController.ts +++ b/src/controllers/ProfileOtherEmployeeController.ts @@ -40,7 +40,7 @@ export class ProfileOtherEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.otherRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -52,7 +52,7 @@ export class ProfileOtherEmployeeController extends Controller { if (_workflow == false) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.otherRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ProfileOtherEmployeeTempController.ts b/src/controllers/ProfileOtherEmployeeTempController.ts index c20914fe..38962384 100644 --- a/src/controllers/ProfileOtherEmployeeTempController.ts +++ b/src/controllers/ProfileOtherEmployeeTempController.ts @@ -40,7 +40,7 @@ export class ProfileOtherEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const lists = await this.otherRepository.find({ - where: { profileEmployeeId: profile.id, isDeleted: false }, + where: { profileEmployeeId: profile.id }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); @@ -51,7 +51,7 @@ export class ProfileOtherEmployeeTempController extends Controller { let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_TEMP"); if (_workflow == false) await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.otherRepository.find({ - where: { profileEmployeeId: profileId, isDeleted: false }, + where: { profileEmployeeId: profileId }, order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 3966fb21..2e72fc6b 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -3659,9 +3659,8 @@ export class ReportController extends Controller { if (profileIds.length > 0) { educationsData = await this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...profileIds)", { profileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -3845,9 +3844,8 @@ export class ReportController extends Controller { this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...child1ProfileIds)", { child1ProfileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -4027,9 +4025,8 @@ export class ReportController extends Controller { this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...child2ProfileIds)", { child2ProfileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -4209,9 +4206,8 @@ export class ReportController extends Controller { this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...child3ProfileIds)", { child3ProfileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -4389,9 +4385,8 @@ export class ReportController extends Controller { this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...child4ProfileIds)", { child4ProfileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -8960,9 +8955,8 @@ export class ReportController extends Controller { if (profileIds.length > 0) { educationsData = await this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...profileIds)", { profileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -9152,9 +9146,8 @@ export class ReportController extends Controller { this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...child1ProfileIds)", { child1ProfileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -9340,9 +9333,8 @@ export class ReportController extends Controller { this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...child2ProfileIds)", { child2ProfileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -9529,9 +9521,8 @@ export class ReportController extends Controller { this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...child3ProfileIds)", { child3ProfileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, @@ -9717,9 +9708,8 @@ export class ReportController extends Controller { this.profileEducationRepository .createQueryBuilder("pe") - .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level", "pe.isDeleted"]) + .select(["pe.profileId", "pe.finishDate", "pe.degree", "pe.level"]) .where("pe.profileId IN (:...child4ProfileIds)", { child4ProfileIds }) - .andWhere("pe.isDeleted = :isDeleted", { isDeleted: false }) .andWhere( `(pe.profileId, COALESCE(pe.finishDate, '1900-01-01'), pe.level) IN ( SELECT pe2.profileId, diff --git a/src/entities/ProfileAbility.ts b/src/entities/ProfileAbility.ts index dcba7ee1..d2ea83d4 100644 --- a/src/entities/ProfileAbility.ts +++ b/src/entities/ProfileAbility.ts @@ -82,13 +82,6 @@ export class ProfileAbility extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany( () => ProfileAbilityHistory, (profileAbilityHistory) => profileAbilityHistory.histories, diff --git a/src/entities/ProfileAbilityHistory.ts b/src/entities/ProfileAbilityHistory.ts index 01aff27b..16b0de99 100644 --- a/src/entities/ProfileAbilityHistory.ts +++ b/src/entities/ProfileAbilityHistory.ts @@ -66,13 +66,6 @@ export class ProfileAbilityHistory extends EntityBase { }) profileAbilityId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => ProfileAbility, (profileAbility) => profileAbility.profileAbilityHistorys) @JoinColumn({ name: "profileAbilityId" }) histories: ProfileAbility; diff --git a/src/entities/ProfileAssessment.ts b/src/entities/ProfileAssessment.ts index f08ad25e..6ae060ed 100644 --- a/src/entities/ProfileAssessment.ts +++ b/src/entities/ProfileAssessment.ts @@ -100,13 +100,6 @@ export class ProfileAssessment extends EntityBase { }) pointSumTotal: number; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany( () => ProfileAssessmentHistory, (profileAssessmentHistory) => profileAssessmentHistory.histories, diff --git a/src/entities/ProfileAssessmentHistory.ts b/src/entities/ProfileAssessmentHistory.ts index 5bfe8524..224ea49c 100644 --- a/src/entities/ProfileAssessmentHistory.ts +++ b/src/entities/ProfileAssessmentHistory.ts @@ -96,13 +96,6 @@ export class ProfileAssessmentHistory extends EntityBase { }) profileAssessmentId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne( () => ProfileAssessment, (profileAssessment) => profileAssessment.profileAssessmentHistorys, diff --git a/src/entities/ProfileAssistance.ts b/src/entities/ProfileAssistance.ts index 06cd9ffb..ad01f585 100644 --- a/src/entities/ProfileAssistance.ts +++ b/src/entities/ProfileAssistance.ts @@ -94,13 +94,6 @@ export class ProfileAssistance extends EntityBase { }) commandId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => Command, (command) => command.profileSalarys) @JoinColumn({ name: "commandId" }) command: Command; diff --git a/src/entities/ProfileAssistanceHistory.ts b/src/entities/ProfileAssistanceHistory.ts index 8a106203..344c6dc0 100644 --- a/src/entities/ProfileAssistanceHistory.ts +++ b/src/entities/ProfileAssistanceHistory.ts @@ -62,13 +62,6 @@ export class ProfileAssistanceHistory extends EntityBase { }) profileAssistanceId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne( () => ProfileAssistance, (profileAssistance) => profileAssistance.profileAssistanceHistorys, diff --git a/src/entities/ProfileCertificate.ts b/src/entities/ProfileCertificate.ts index 867c7797..730bde73 100644 --- a/src/entities/ProfileCertificate.ts +++ b/src/entities/ProfileCertificate.ts @@ -74,13 +74,6 @@ export class ProfileCertificate extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany( () => ProfileCertificateHistory, (profileCertificateHistory) => profileCertificateHistory.histories, diff --git a/src/entities/ProfileCertificateHistory.ts b/src/entities/ProfileCertificateHistory.ts index 0e9a0834..022d1e17 100644 --- a/src/entities/ProfileCertificateHistory.ts +++ b/src/entities/ProfileCertificateHistory.ts @@ -58,13 +58,6 @@ export class ProfileCertificateHistory extends EntityBase { }) profileCertificateId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne( () => ProfileCertificate, (profileCertificate) => profileCertificate.profileCertificateHistories, diff --git a/src/entities/ProfileChangeName.ts b/src/entities/ProfileChangeName.ts index b02117fc..74767fa2 100644 --- a/src/entities/ProfileChangeName.ts +++ b/src/entities/ProfileChangeName.ts @@ -77,13 +77,6 @@ export class ProfileChangeName extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany( () => ProfileChangeNameHistory, (profileChangeNameHistory) => profileChangeNameHistory.histories, diff --git a/src/entities/ProfileChangeNameHistory.ts b/src/entities/ProfileChangeNameHistory.ts index 5d296161..619344dd 100644 --- a/src/entities/ProfileChangeNameHistory.ts +++ b/src/entities/ProfileChangeNameHistory.ts @@ -60,13 +60,6 @@ export class ProfileChangeNameHistory extends EntityBase { }) profileChangeNameId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne( () => ProfileChangeName, (profileChangeName) => profileChangeName.profileChangeNameHistories, diff --git a/src/entities/ProfileChildren.ts b/src/entities/ProfileChildren.ts index d4f07c72..23f3b507 100644 --- a/src/entities/ProfileChildren.ts +++ b/src/entities/ProfileChildren.ts @@ -72,13 +72,6 @@ export class ProfileChildren extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => Profile, (Profile) => Profile.profileChildrens) @JoinColumn({ name: "profileId" }) profile: Profile; diff --git a/src/entities/ProfileChildrenHistory.ts b/src/entities/ProfileChildrenHistory.ts index a402c41e..39e34b74 100644 --- a/src/entities/ProfileChildrenHistory.ts +++ b/src/entities/ProfileChildrenHistory.ts @@ -55,13 +55,6 @@ export class ProfileChildrenHistory extends EntityBase { }) profileChildrenId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - // @ManyToOne(() => ProfileChildren, (profileChildren) => profileChildren.profileChildrenHistories) // @JoinColumn({ name: "profileChildrenId" }) // histories: ProfileChildren; diff --git a/src/entities/ProfileDiscipline.ts b/src/entities/ProfileDiscipline.ts index 0065528b..6220b712 100644 --- a/src/entities/ProfileDiscipline.ts +++ b/src/entities/ProfileDiscipline.ts @@ -82,13 +82,6 @@ export class ProfileDiscipline extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany( () => ProfileDisciplineHistory, (profileDisciplineHistory) => profileDisciplineHistory.histories, diff --git a/src/entities/ProfileDisciplineHistory.ts b/src/entities/ProfileDisciplineHistory.ts index e7dfee58..f265a825 100644 --- a/src/entities/ProfileDisciplineHistory.ts +++ b/src/entities/ProfileDisciplineHistory.ts @@ -65,13 +65,6 @@ export class ProfileDisciplineHistory extends EntityBase { }) isUpload: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne( () => ProfileDiscipline, (profileDiscipline) => profileDiscipline.profileDisciplineHistories, diff --git a/src/entities/ProfileDuty.ts b/src/entities/ProfileDuty.ts index 7c2d8338..5684f650 100644 --- a/src/entities/ProfileDuty.ts +++ b/src/entities/ProfileDuty.ts @@ -82,13 +82,6 @@ export class ProfileDuty extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany(() => ProfileDutyHistory, (profileDutyHistory) => profileDutyHistory.histories) profileDutyHistories: ProfileDutyHistory[]; diff --git a/src/entities/ProfileDutyHistory.ts b/src/entities/ProfileDutyHistory.ts index 24c61a5c..e00f4d5f 100644 --- a/src/entities/ProfileDutyHistory.ts +++ b/src/entities/ProfileDutyHistory.ts @@ -66,13 +66,6 @@ export class ProfileDutyHistory extends EntityBase { }) profileDutyId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => ProfileDuty, (profileDuty) => profileDuty.profileDutyHistories) @JoinColumn({ name: "profileDutyId" }) histories: ProfileDuty; diff --git a/src/entities/ProfileEducation.ts b/src/entities/ProfileEducation.ts index 0b7c6f6e..351aeec0 100644 --- a/src/entities/ProfileEducation.ts +++ b/src/entities/ProfileEducation.ts @@ -196,13 +196,6 @@ export class ProfileEducation extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany( () => ProfileEducationHistory, (profileEducationHistory) => profileEducationHistory.histories, diff --git a/src/entities/ProfileEducationHistory.ts b/src/entities/ProfileEducationHistory.ts index 6ffb118c..7a8d5497 100644 --- a/src/entities/ProfileEducationHistory.ts +++ b/src/entities/ProfileEducationHistory.ts @@ -166,13 +166,6 @@ export class ProfileEducationHistory extends EntityBase { }) profileEducationId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne( () => ProfileEducation, (profileEducation) => profileEducation.profileEducationHistories, diff --git a/src/entities/ProfileHonor.ts b/src/entities/ProfileHonor.ts index 73ec072f..481e195f 100644 --- a/src/entities/ProfileHonor.ts +++ b/src/entities/ProfileHonor.ts @@ -89,13 +89,6 @@ export class ProfileHonor extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany(() => ProfileHonorHistory, (profileHonorHistory) => profileHonorHistory.histories) profileHonorHistories: ProfileHonorHistory[]; diff --git a/src/entities/ProfileHonorHistory.ts b/src/entities/ProfileHonorHistory.ts index d22137ab..59338365 100644 --- a/src/entities/ProfileHonorHistory.ts +++ b/src/entities/ProfileHonorHistory.ts @@ -73,13 +73,6 @@ export class ProfileHonorHistory extends EntityBase { }) isUpload: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => ProfileHonor, (profileHonor) => profileHonor.profileHonorHistories) @JoinColumn({ name: "profileHonorId" }) histories: ProfileHonor; diff --git a/src/entities/ProfileInsignia.ts b/src/entities/ProfileInsignia.ts index d09e71ee..b7fa824d 100644 --- a/src/entities/ProfileInsignia.ts +++ b/src/entities/ProfileInsignia.ts @@ -137,13 +137,6 @@ export class ProfileInsignia extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => Insignia, (v) => v.profileInsignias) insignia: Insignia; diff --git a/src/entities/ProfileInsigniaHistory.ts b/src/entities/ProfileInsigniaHistory.ts index 4381b900..cc4fa5d7 100644 --- a/src/entities/ProfileInsigniaHistory.ts +++ b/src/entities/ProfileInsigniaHistory.ts @@ -65,13 +65,6 @@ export class ProfileInsigniaHistory extends EntityBase { }) profileInsigniaId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => ProfileInsignia, (profileInsignia) => profileInsignia.profileInsigniaHistories) @JoinColumn({ name: "profileInsigniaId" }) histories: ProfileInsignia; diff --git a/src/entities/ProfileLeave.ts b/src/entities/ProfileLeave.ts index f037e303..2728b32b 100644 --- a/src/entities/ProfileLeave.ts +++ b/src/entities/ProfileLeave.ts @@ -100,13 +100,6 @@ export class ProfileLeave extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany(() => ProfileLeaveHistory, (v) => v.profileLeave) histories: ProfileLeaveHistory[]; @@ -131,13 +124,6 @@ export class ProfileLeaveHistory extends ProfileLeave { }) profileLeaveId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean = false; - @ManyToOne(() => ProfileLeave, (v) => v.histories) profileLeave: ProfileLeave; } diff --git a/src/entities/ProfileNopaid.ts b/src/entities/ProfileNopaid.ts index 7eb2e82f..1f90025f 100644 --- a/src/entities/ProfileNopaid.ts +++ b/src/entities/ProfileNopaid.ts @@ -74,13 +74,6 @@ export class ProfileNopaid extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany(() => ProfileNopaidHistory, (profileNopaidHistory) => profileNopaidHistory.histories) profileNopaidHistories: ProfileNopaidHistory[]; diff --git a/src/entities/ProfileNopaidHistory.ts b/src/entities/ProfileNopaidHistory.ts index 6bb14d0b..905395ef 100644 --- a/src/entities/ProfileNopaidHistory.ts +++ b/src/entities/ProfileNopaidHistory.ts @@ -58,13 +58,6 @@ export class ProfileNopaidHistory extends EntityBase { }) profileNopaidId: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => ProfileNopaid, (profileNopaid) => profileNopaid.profileNopaidHistories) @JoinColumn({ name: "profileNopaidId" }) histories: ProfileNopaid; diff --git a/src/entities/ProfileOther.ts b/src/entities/ProfileOther.ts index 497886be..b64171ed 100644 --- a/src/entities/ProfileOther.ts +++ b/src/entities/ProfileOther.ts @@ -44,13 +44,6 @@ export class ProfileOther extends EntityBase { }) isEntry: boolean; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @OneToMany(() => ProfileOtherHistory, (profileOtherHistory) => profileOtherHistory.histories) profileOtherHistories: ProfileOtherHistory[]; diff --git a/src/entities/ProfileOtherHistory.ts b/src/entities/ProfileOtherHistory.ts index 654425a7..15ea3588 100644 --- a/src/entities/ProfileOtherHistory.ts +++ b/src/entities/ProfileOtherHistory.ts @@ -28,13 +28,6 @@ export class ProfileOtherHistory extends EntityBase { }) date: Date; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => ProfileOther, (profileOther) => profileOther.profileOtherHistories) @JoinColumn({ name: "profileOtherId" }) histories: ProfileOther; diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 1ab7acab..ddbe184b 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -287,13 +287,6 @@ export class ProfileSalary extends EntityBase { }) positionArea: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => Command, (command) => command.profileSalarys) @JoinColumn({ name: "commandId" }) command: Command; diff --git a/src/entities/ProfileSalaryBackup.ts b/src/entities/ProfileSalaryBackup.ts index 1274e319..29cdd325 100644 --- a/src/entities/ProfileSalaryBackup.ts +++ b/src/entities/ProfileSalaryBackup.ts @@ -292,11 +292,4 @@ export class ProfileSalaryBackup extends EntityBase { }) positionArea: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - } \ No newline at end of file diff --git a/src/entities/ProfileSalaryHistory.ts b/src/entities/ProfileSalaryHistory.ts index b5482c29..ea6af033 100644 --- a/src/entities/ProfileSalaryHistory.ts +++ b/src/entities/ProfileSalaryHistory.ts @@ -228,13 +228,6 @@ export class ProfileSalaryHistory extends EntityBase { }) posNumCodeSitAbb: string; - @Column({ - nullable: false, - comment: "สถานะลบข้อมูล", - default: false, - }) - isDeleted: boolean; - @ManyToOne(() => Command, (command) => command.profileSalaryHistorys) @JoinColumn({ name: "commandId" }) command: Command; diff --git a/src/migration/1770870836370-add_fields_isDeleted.ts b/src/migration/1770870836370-add_fields_isDeleted.ts deleted file mode 100644 index 6d04805c..00000000 --- a/src/migration/1770870836370-add_fields_isDeleted.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddFieldsIsDeleted1770870836370 implements MigrationInterface { - name = 'AddFieldsIsDeleted1770870836370' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileCertificate\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileInsignia\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileHonor\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileAssessment\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileLeave\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileDuty\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileNopaid\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileChangeName\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileEducation\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileAbility\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileOther\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileChildren\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileAssistanceHistory\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileAssistance\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - await queryRunner.query(`ALTER TABLE \`profileSalaryBackup\` ADD \`isDeleted\` tinyint NOT NULL COMMENT 'สถานะลบข้อมูล' DEFAULT 0`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`profileSalaryBackup\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileAssistance\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileAssistanceHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileChildren\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileOther\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileAbility\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileEducation\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileChangeName\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileNopaid\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileDuty\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileLeave\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileAssessment\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileHonor\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileInsignia\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileCertificate\` DROP COLUMN \`isDeleted\``); - await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` DROP COLUMN \`isDeleted\``); - } - -}