ค้นหาคนทดลองงาน
This commit is contained in:
parent
7eef964d48
commit
6c843f649f
3 changed files with 131 additions and 0 deletions
|
|
@ -712,4 +712,115 @@ export class ProfileController extends Controller {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ค้นหาข้อมูลทะเบียนประวัติ ทดลองปฏิบัติหน้าที่ราชการ
|
||||||
|
*
|
||||||
|
* @summary ค้นหาข้อมูลทะเบียนประวัติ ทดลองปฏิบัติหน้าที่ราชการ (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("probation")
|
||||||
|
async getProfileBySearchKeywordProbation(
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
keyword?: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("current_holders.orgRevision", "orgRevision")
|
||||||
|
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
|
.where("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
||||||
|
.orderBy("profile.citizenId", "ASC")
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
const orgRevisionActive = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDataProfile = await Promise.all(
|
||||||
|
findProfile.map(async (item: Profile) => {
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
prefix: item.prefix,
|
||||||
|
firstName: item.firstName,
|
||||||
|
lastName: item.lastName,
|
||||||
|
position: item.position,
|
||||||
|
idcard: item.citizenId,
|
||||||
|
posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName,
|
||||||
|
isProbation: item.isProbation,
|
||||||
|
orgRootName:
|
||||||
|
item.current_holders == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot ==
|
||||||
|
null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot
|
||||||
|
?.orgRootName == null
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgRoot?.orgRootName,
|
||||||
|
orgChild1Name:
|
||||||
|
item.current_holders == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgChild1 == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1
|
||||||
|
?.orgChild1Name == null
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgChild1?.orgChild1Name,
|
||||||
|
orgChild2Name:
|
||||||
|
item.current_holders == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgChild2 == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2
|
||||||
|
?.orgChild2Name == null
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgChild2?.orgChild2Name,
|
||||||
|
orgChild3Name:
|
||||||
|
item.current_holders == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgChild3 == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3
|
||||||
|
?.orgChild3Name == null
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgChild3?.orgChild3Name,
|
||||||
|
orgChild4Name:
|
||||||
|
item.current_holders == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgChild4 == null ||
|
||||||
|
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4
|
||||||
|
?.orgChild4Name == null
|
||||||
|
? null
|
||||||
|
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||||
|
?.orgChild4?.orgChild4Name,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return new HttpSuccess({ data: mapDataProfile, total });
|
||||||
|
} catch (error: any) {
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,12 @@ export class Profile extends EntityBase {
|
||||||
})
|
})
|
||||||
keycloak: string;
|
keycloak: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "ทดลองปฏิบัติหน้าที่",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isProbation: boolean;
|
||||||
|
|
||||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder)
|
@OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder)
|
||||||
current_holders: PosMaster[];
|
current_holders: PosMaster[];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableProfileAddProbation1708590016918 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableProfileAddProbation1708590016918'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`isProbation\` tinyint NOT NULL COMMENT 'ทดลองปฏิบัติหน้าที่' DEFAULT 0`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`isProbation\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue