เพิ่มฟิลด์ employeePosLevel.posLevelAuthority

This commit is contained in:
Bright 2024-03-14 14:02:17 +07:00
parent ac1599485a
commit a069c81d41
3 changed files with 37 additions and 5 deletions

View file

@ -167,7 +167,7 @@ export class EmployeePosLevelController extends Controller {
async GetEmpLevelById(@Path() id: string) {
const getEmpPosLevel = await this.employeePosLevelRepository.findOne({
relations: ["posType"],
select: ["id", "posLevelName", "posLevelRank"],
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority"],
where: { id: id },
});
if (!getEmpPosLevel) {
@ -178,7 +178,7 @@ export class EmployeePosLevelController extends Controller {
posLevelName: getEmpPosLevel.posLevelName,
posTypeId: getEmpPosLevel.posType == null ? null : getEmpPosLevel.posType.id,
posTypeName: getEmpPosLevel.posType == null ? null : getEmpPosLevel.posType.posTypeName, //กลุ่มงาน
commander: null, //ผู้มีอำนาจสั่งบรรจุ
posLevelAuthority: getEmpPosLevel.posLevelAuthority, //ผู้มีอำนาจสั่งบรรจุ
};
return new HttpSuccess(mapEmpPosLevel);
}
@ -193,14 +193,14 @@ export class EmployeePosLevelController extends Controller {
async GetEmpPosLevel() {
const empPosLevel = await this.employeePosLevelRepository.find({
relations: ["posType"],
select: ["id", "posLevelName", "posLevelRank"],
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority"],
});
const mapEmpPosLevel = empPosLevel.map((item) => ({
id: item.id,
posLevelName: item.posLevelName,
posTypeId: item.posType == null ? null : item.posType.id,
posTypeName: item.posType == null ? null : item.posType.posTypeName, //กลุ่มงาน
commander: null, //ผู้มีอำนาจสั่งบรรจุ
posLevelAuthority: item.posLevelAuthority, //ผู้มีอำนาจสั่งบรรจุ
}));
return new HttpSuccess(mapEmpPosLevel);
}

View file

@ -3,6 +3,11 @@ import { EntityBase } from "./base/Base";
import { EmployeePosDict } from "./EmployeePosDict";
import { EmployeePosType } from "./EmployeePosType";
enum EmployeePosLevelAuthoritys {
HEAD = "HEAD",
DEPUTY = "DEPUTY",
GOVERNOR = "GOVERNOR",
}
@Entity("employeePosLevel")
export class EmployeePosLevel extends EntityBase {
@Column({
@ -17,6 +22,16 @@ export class EmployeePosLevel extends EntityBase {
})
posLevelRank: number;
@Column({
nullable: true,
comment:
"ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ",
type: "enum",
enum: EmployeePosLevelAuthoritys,
default: null,
})
posLevelAuthority: EmployeePosLevelAuthoritys;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง employeePosType",
@ -38,8 +53,11 @@ export class CreateEmployeePosLevel {
@Column()
posLevelRank: number;
@Column()
posLevelAuthority: string;
@Column("uuid")
posTypeId: string;
}
export type UpdateEmployeePosLevel = Partial<CreateEmployeePosLevel>;
export type UpdateEmployeePosLevel = Partial<CreateEmployeePosLevel> & { posLevelAuthority: EmployeePosLevelAuthoritys };

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddColumnEmployeePosLevelPosLevelAuthority1710399617760 implements MigrationInterface {
name = 'AddColumnEmployeePosLevelPosLevelAuthority1710399617760'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` ADD \`posLevelAuthority\` enum ('HEAD', 'DEPUTY', 'GOVERNOR') NULL COMMENT 'ผู้มีอำนาจสั่งบรรจุของระดับนี้ head = หัวหน้าหน่วยงาน , deputy = ปลัด , governor = ผู้ว่าฯ'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` DROP COLUMN \`posLevelAuthority\``);
}
}