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

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 posLevelRepo = AppDataSource.getRepository(PosLevel);
private posTypeRepo = AppDataSource.getRepository(PosType); 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 * API
* *

View file

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

View file

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

View file

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