เพิ่มผู้บังคับบัญชา

This commit is contained in:
Kittapath 2024-03-27 13:48:06 +07:00
parent 474630a7ba
commit ad08061836
5 changed files with 110 additions and 0 deletions

View file

@ -44,6 +44,65 @@ export class ProfileController extends Controller {
private posLevelRepo = AppDataSource.getRepository(PosLevel);
private posTypeRepo = AppDataSource.getRepository(PosType);
/**
*
*
* @param {string} id Id
*/
@Get("placement/{id}")
async getProfilePlacement(@Path() id: string) {
const profile = await this.profileRepo.findOne({
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const _caregiver = await this.profileRepo.find({
relations: { posLevel: true, posType: true },
});
const _commander = await this.profileRepo.find({
relations: { posLevel: true, posType: true },
});
const _chairman = await this.profileRepo.find({
relations: { posLevel: true, posType: true },
});
const caregiver = _caregiver.map((_data) => ({
id: _data.id,
prefix: _data.prefix,
firstName: _data.firstName,
lastName: _data.lastName,
citizenId: _data.citizenId,
position: _data.position,
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
posType: _data.posType == null ? null : _data.posType.posTypeName,
isDirector: true,
}));
const commander = _commander.map((_data) => ({
id: _data.id,
prefix: _data.prefix,
firstName: _data.firstName,
lastName: _data.lastName,
citizenId: _data.citizenId,
position: _data.position,
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
posType: _data.posType == null ? null : _data.posType.posTypeName,
isDirector: true,
}));
const chairman = _chairman.map((_data) => ({
id: _data.id,
prefix: _data.prefix,
firstName: _data.firstName,
lastName: _data.lastName,
citizenId: _data.citizenId,
position: _data.position,
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
posType: _data.posType == null ? null : _data.posType.posTypeName,
isDirector: true,
}));
return new HttpSuccess({ caregiver, commander, chairman });
}
/**
* API
*

View file

@ -36,6 +36,11 @@ export class ProfileGovernmentHistoryController extends Controller {
private positionRepo = AppDataSource.getRepository(Position);
private posMasterRepo = AppDataSource.getRepository(PosMaster);
/**
*
* @summary
*
*/
@Get("{profileId}")
@Example({})
public async getGovHistory(@Path() profileId: string) {
@ -127,6 +132,11 @@ export class ProfileGovernmentHistoryController extends Controller {
return new HttpSuccess(data);
}
/**
*
* @summary
*
*/
@Get("history/{profileId}")
@Example({})
public async govHistory(@Path() profileId: string) {
@ -168,6 +178,11 @@ export class ProfileGovernmentHistoryController extends Controller {
// return new HttpSuccess();
// }
/**
*
* @summary
*
*/
@Patch("{profileId}")
public async editGov(
@Request() req: RequestWithUser,

View file

@ -185,6 +185,14 @@ export class Profile extends EntityBase {
})
birthDate: Date;
@Column({
nullable: true,
comment: "เหตุผลกรณีวันไม่ตรงกัน",
length: 255,
default: null,
})
reasonSameDate: string;
@Column({
nullable: true,
comment: "เชื้อชาติ",

View file

@ -44,15 +44,25 @@ export class ProfileGovernment extends EntityBase {
default: null,
})
govAgePlus: number;
@Column({
nullable: true,
comment: "เหตุผลกรณีวันไม่ตรงกัน",
length: 255,
default: null,
})
reasonSameDate: string;
}
export type CreateProfileGovernment = {
profileId: string;
dateAppoint?: Date | null;
dateStart?: Date | null;
reasonSameDate?: string | null;
};
export type UpdateProfileGovernment = {
dateAppoint?: Date | null;
dateStart?: Date | null;
reasonSameDate?: string | null;
};

View file

@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfilegovAddReasonSameDate1711521703929 implements MigrationInterface {
name = 'UpdateTableProfilegovAddReasonSameDate1711521703929'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileGovernment\` ADD \`reasonSameDate\` varchar(255) NULL COMMENT 'เหตุผลกรณีวันไม่ตรงกัน'`);
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`reasonSameDate\` varchar(255) NULL COMMENT 'เหตุผลกรณีวันไม่ตรงกัน'`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`reasonSameDate\` varchar(255) NULL COMMENT 'เหตุผลกรณีวันไม่ตรงกัน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`reasonSameDate\``);
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`reasonSameDate\``);
await queryRunner.query(`ALTER TABLE \`profileGovernment\` DROP COLUMN \`reasonSameDate\``);
}
}