เพิ่มtableลูกจ้าง

This commit is contained in:
Kittapath 2024-03-15 14:32:08 +07:00
parent 912a8237e6
commit 21c044223c
11 changed files with 1490 additions and 15 deletions

View file

@ -170,6 +170,7 @@ export class EmployeePosTypeController extends Controller {
id: empPosLevel.id,
posLevelName: empPosLevel.posLevelName,
posLevelRank: empPosLevel.posLevelRank,
posLevelAuthority: empPosLevel.posLevelAuthority,
})),
};
@ -198,6 +199,7 @@ export class EmployeePosTypeController extends Controller {
id: empPosLevel.id,
posLevelName: empPosLevel.posLevelName,
posLevelRank: empPosLevel.posLevelRank,
posLevelAuthority: empPosLevel.posLevelAuthority,
})),
}));
return new HttpSuccess(mapEmpPosType);

View file

@ -28,13 +28,13 @@ import { EmployeePosType } from "../entities/EmployeePosType";
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
import { CreateEmployeePosMaster, EmployeePosMaster } from "../entities/EmployeePosMaster";
import { EmployeePosition } from "../entities/EmployeePosition";
import { Profile } from "../entities/Profile";
import { OrgRevision } from "../entities/OrgRevision";
import { OrgRoot } from "../entities/OrgRoot";
import { OrgChild1 } from "../entities/OrgChild1";
import { OrgChild2 } from "../entities/OrgChild2";
import { OrgChild3 } from "../entities/OrgChild3";
import { OrgChild4 } from "../entities/OrgChild4";
import { ProfileEmployee } from "../entities/ProfileEmployee";
@Route("api/v1/org/employee/pos")
@Tags("Employee")
@ -50,7 +50,7 @@ export class EmployeePositionController extends Controller {
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
private employeePositionRepository = AppDataSource.getRepository(EmployeePosition);
private profileRepository = AppDataSource.getRepository(Profile);
private profileRepository = AppDataSource.getRepository(ProfileEmployee);
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1);
@ -227,7 +227,7 @@ export class EmployeePositionController extends Controller {
@Get("position/{id}")
async detailPosition(@Path() id: string) {
const posMaster = await this.employeePosMasterRepository.findOne({
where: { id:id },
where: { id: id },
});
if (!posMaster) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
@ -2015,6 +2015,7 @@ export class EmployeePositionController extends Controller {
await this.employeePosMasterRepository.update(id, {
isSit: false,
next_holderId: null,
current_holderId: null,
});
dataMaster.positions.forEach(async (position) => {

File diff suppressed because it is too large Load diff

View file

@ -2,8 +2,10 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosDict } from "./EmployeePosDict";
import { EmployeePosType } from "./EmployeePosType";
import { EmployeePosition } from "./EmployeePosition";
import { ProfileEmployee } from "./ProfileEmployee";
enum EmployeePosLevelAuthoritys {
enum EmployeePosLevelAuthoritys {
HEAD = "HEAD",
DEPUTY = "DEPUTY",
GOVERNOR = "GOVERNOR",
@ -42,8 +44,14 @@ export class EmployeePosLevel extends EntityBase {
@JoinColumn({ name: "posTypeId" })
posType: EmployeePosType;
@OneToMany(() => EmployeePosition, (position) => position.posLevel)
positions: EmployeePosition[];
@OneToMany(() => EmployeePosDict, (posDict) => posDict.posLevel)
posDicts: EmployeePosDict[];
@OneToMany(() => ProfileEmployee, (profile) => profile.posLevel)
profiles: ProfileEmployee[];
}
export class CreateEmployeePosLevel {
@ -60,4 +68,6 @@ export class CreateEmployeePosLevel {
posTypeId: string;
}
export type UpdateEmployeePosLevel = Partial<CreateEmployeePosLevel> & { posLevelAuthority: EmployeePosLevelAuthoritys };
export type UpdateEmployeePosLevel = Partial<CreateEmployeePosLevel> & {
posLevelAuthority: EmployeePosLevelAuthoritys;
};

View file

@ -9,6 +9,7 @@ import { OrgChild2 } from "./OrgChild2";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
enum EmployeePosMasterLine {
MAIN = "MAIN",
@ -174,13 +175,13 @@ export class EmployeePosMaster extends EntityBase {
@JoinColumn({ name: "orgChild4Id" })
orgChild4: OrgChild4;
@ManyToOne(() => Profile, (posMaster) => posMaster.current_holders)
@ManyToOne(() => ProfileEmployee, (posMaster) => posMaster.current_holders)
@JoinColumn({ name: "current_holderId" })
current_holder: Profile;
current_holder: ProfileEmployee;
@ManyToOne(() => Profile, (posMaster) => posMaster.next_holders)
@ManyToOne(() => ProfileEmployee, (posMaster) => posMaster.next_holders)
@JoinColumn({ name: "next_holderId" })
next_holder: Profile;
next_holder: ProfileEmployee;
@OneToMany(() => EmployeePosition, (position) => position.posMaster)
positions: EmployeePosition[];

View file

@ -2,6 +2,8 @@ import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosDict } from "./EmployeePosDict";
import { EmployeePosLevel } from "./EmployeePosLevel";
import { EmployeePosition } from "./EmployeePosition";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("employeePosType")
export class EmployeePosType extends EntityBase {
@ -29,8 +31,14 @@ export class EmployeePosType extends EntityBase {
@OneToMany(() => EmployeePosLevel, (posLevel) => posLevel.posType)
posLevels: EmployeePosLevel[];
@OneToMany(() => EmployeePosition, (position) => position.posType)
positions: EmployeePosition[];
@OneToMany(() => EmployeePosDict, (posDict) => posDict.posType)
posDicts: EmployeePosDict[];
@OneToMany(() => ProfileEmployee, (profile) => profile.posType)
profiles: ProfileEmployee[];
}
export class CreateEmployeePosType {

View file

@ -55,7 +55,7 @@ export class PosLevel extends EntityBase {
posDicts: PosDict[];
@OneToMany(() => Profile, (profile) => profile.posLevel)
posLevels: Profile[];
profiles: Profile[];
}
export class CreatePosLevel {

View file

@ -33,7 +33,7 @@ export class PosType extends EntityBase {
posDicts: PosDict[];
@OneToMany(() => Profile, (profile) => profile.posType)
posTypes: Profile[];
profiles: Profile[];
}
export class CreatePosType {

View file

@ -135,7 +135,7 @@ export class Profile extends EntityBase {
default: null,
})
birthDate: Date;
@OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder)
current_holders: PosMaster[];
@ -177,15 +177,15 @@ export class Profile extends EntityBase {
@OneToMany(() => ProfileNopaid, (profileNopaid) => profileNopaid.profile)
profileNopaids: ProfileNopaid[];
@OneToMany(() => ProfileOther, (profileOther) => profileOther.profile)
profileOthers: ProfileOther[];
@ManyToOne(() => PosLevel, (posLevel) => posLevel.posLevels)
@ManyToOne(() => PosLevel, (posLevel) => posLevel.profiles)
@JoinColumn({ name: "posLevelId" })
posLevel: PosLevel;
@ManyToOne(() => PosType, (posType) => posType.posTypes)
@ManyToOne(() => PosType, (posType) => posType.profiles)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
}

View file

@ -0,0 +1,219 @@
import { Entity, Column, OneToMany, OneToOne, JoinColumn, ManyToMany, ManyToOne } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosMaster } from "./PosMaster";
import { PosLevel } from "./PosLevel";
import { PosType } from "./PosType";
import { ProfileSalary } from "./ProfileSalary";
import { ProfileDiscipline } from "./ProfileDiscipline";
import { ProfileCertificate } from "./ProfileCertificate";
import { ProfileEducation } from "./ProfileEducation";
import { ProfileTraining } from "./ProfileTraining";
import { ProfileInsignia } from "./ProfileInsignia";
import { ProfileHonor } from "./ProfileHonor";
import { ProfileAssessment } from "./ProfileAssessment";
import { ProfileLeave } from "./ProfileLeave";
import { ProfileAbility } from "./ProfileAbility";
import { ProfileDuty } from "./ProfileDuty";
import { ProfileNopaid } from "./ProfileNopaid";
import { ProfileOther } from "./ProfileOther";
import { EmployeePosLevel } from "./EmployeePosLevel";
import { EmployeePosType } from "./EmployeePosType";
import { EmployeePosMaster } from "./EmployeePosMaster";
@Entity("profileEmployee")
export class ProfileEmployee extends EntityBase {
@Column({
nullable: true,
comment: "คำนำหน้าชื่อ",
length: 40,
default: null,
})
prefix: string;
@Column({
nullable: true,
comment: "ชื่อ",
length: 255,
default: null,
})
firstName: string;
@Column({
nullable: true,
comment: "นามสกุล",
length: 255,
default: null,
})
lastName: string;
@Column({
nullable: true,
comment: "เลขประจำตัวประชาชน",
default: null,
length: 13,
})
citizenId: string;
@Column({
nullable: true,
comment: "ตำแหน่ง",
default: null,
length: 255,
})
position: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีระดับตำแหน่ง",
})
posLevelId: string | null;
@Column({
nullable: true,
length: 40,
comment: "ไอดีกลุ่มงานตำแหน่ง",
})
posTypeId: string | null;
@Column({
nullable: true,
length: 255,
comment: "อีเมล",
})
email: string;
@Column({
nullable: true,
length: 20,
comment: "เบอร์โทร",
})
phone: string;
// @Column({
// nullable: true,
// length: 40,
// comment:
// "คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้",
// default: null,
// unique: false,
// })
// current_holderId: string;
// @Column({
// nullable: true,
// length: 40,
// comment:
// "คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย",
// default: null,
// unique: false,
// })
// next_holderId: string;
@Column({
nullable: true,
comment: "id keycloak",
length: 40,
default: null,
})
keycloak: string;
@Column({
comment: "ทดลองปฏิบัติหน้าที่",
default: false,
})
isProbation: boolean;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่พักราชการ",
default: null,
})
dateRetire: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันเกิด",
default: null,
})
birthDate: Date;
@OneToMany(() => EmployeePosMaster, (posMaster) => posMaster.current_holder)
current_holders: EmployeePosMaster[];
@OneToMany(() => EmployeePosMaster, (posMaster) => posMaster.next_holder)
next_holders: EmployeePosMaster[];
// @OneToMany(() => ProfileSalary, (profileSalary) => profileSalary.profile)
// profileSalary: ProfileSalary[];
// @OneToMany(() => ProfileDiscipline, (profileDiscipline) => profileDiscipline.profile)
// profileDiscipline: ProfileDiscipline[];
// @OneToMany(() => ProfileCertificate, (profileCertificate) => profileCertificate.profile)
// profileCertificates: ProfileCertificate[];
// @OneToMany(() => ProfileEducation, (profileEducation) => profileEducation.profile)
// profileEducations: ProfileEducation[];
// @OneToMany(() => ProfileTraining, (profileTraining) => profileTraining.profile)
// profileTrainings: ProfileTraining[];
// @OneToMany(() => ProfileInsignia, (profileInsignia) => profileInsignia.profile)
// profileInsignias: ProfileInsignia[];
// @OneToMany(() => ProfileHonor, (profileHonor) => profileHonor.profile)
// profileHonors: ProfileHonor[];
// @OneToMany(() => ProfileAssessment, (profileAssessment) => profileAssessment.profile)
// profileAssessments: ProfileAssessment[];
// @OneToMany(() => ProfileLeave, (profileLeave) => profileLeave.profile)
// profileLeaves: ProfileLeave[];
// @OneToMany(() => ProfileAbility, (profileAbility) => profileAbility.profile)
// profileAbilities: ProfileAbility[];
// @OneToMany(() => ProfileDuty, (profileDuty) => profileDuty.profile)
// profileDutys: ProfileDuty[];
// @OneToMany(() => ProfileNopaid, (profileNopaid) => profileNopaid.profile)
// profileNopaids: ProfileNopaid[];
// @OneToMany(() => ProfileOther, (profileOther) => profileOther.profile)
// profileOthers: ProfileOther[];
@ManyToOne(() => EmployeePosLevel, (posLevel) => posLevel.profiles)
@JoinColumn({ name: "posLevelId" })
posLevel: EmployeePosLevel;
@ManyToOne(() => EmployeePosType, (posType) => posType.profiles)
@JoinColumn({ name: "posTypeId" })
posType: EmployeePosType;
}
export class CreateProfileEmployee {
@Column()
prefix: string;
@Column()
firstName: string;
@Column()
lastName: string;
@Column()
citizenId: string;
@Column()
position: string;
@Column("uuid")
posLevelId: string | null;
@Column("uuid")
posTypeId: string | null;
}
export type UpdateProfileEmployee = Partial<CreateProfileEmployee>;

View file

@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableProfileEmployee1710487869374 implements MigrationInterface {
name = 'AddTableProfileEmployee1710487869374'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_00221b20fdf6d460a86f108fc6d\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_41945621a3f1e716dc3b2d994c3\``);
await queryRunner.query(`CREATE TABLE \`profileEmployee\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`prefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'นามสกุล', \`citizenId\` varchar(13) NULL COMMENT 'เลขประจำตัวประชาชน', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`posLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง', \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีกลุ่มงานตำแหน่ง', \`email\` varchar(255) NULL COMMENT 'อีเมล', \`phone\` varchar(20) NULL COMMENT 'เบอร์โทร', \`keycloak\` varchar(40) NULL COMMENT 'id keycloak', \`isProbation\` tinyint NOT NULL COMMENT 'ทดลองปฏิบัติหน้าที่' DEFAULT 0, \`dateRetire\` datetime NULL COMMENT 'วันที่พักราชการ', \`birthDate\` datetime NULL COMMENT 'วันเกิด', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_00221b20fdf6d460a86f108fc6d\` FOREIGN KEY (\`current_holderId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_41945621a3f1e716dc3b2d994c3\` FOREIGN KEY (\`next_holderId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD CONSTRAINT \`FK_cc1b55a08a76d0d3e254c37e11e\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD CONSTRAINT \`FK_773469f2924994e83e9835c48f9\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP FOREIGN KEY \`FK_773469f2924994e83e9835c48f9\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP FOREIGN KEY \`FK_cc1b55a08a76d0d3e254c37e11e\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_41945621a3f1e716dc3b2d994c3\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_00221b20fdf6d460a86f108fc6d\``);
await queryRunner.query(`DROP TABLE \`profileEmployee\``);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_41945621a3f1e716dc3b2d994c3\` FOREIGN KEY (\`next_holderId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_00221b20fdf6d460a86f108fc6d\` FOREIGN KEY (\`current_holderId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
}