เพิ่มอัตราตำแหน่งลูกจ้าง
This commit is contained in:
parent
806fb21c61
commit
ee6b6f7cc2
11 changed files with 2226 additions and 106 deletions
|
|
@ -18,8 +18,12 @@ import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { Not } from "typeorm";
|
import { Not } from "typeorm";
|
||||||
import { EmployeePosType,} from "../entities/EmployeePosType";
|
import { EmployeePosType } from "../entities/EmployeePosType";
|
||||||
import { EmployeePosLevel, CreateEmployeePosLevel, UpdateEmployeePosLevel } from "../entities/EmployeePosLevel";
|
import {
|
||||||
|
EmployeePosLevel,
|
||||||
|
CreateEmployeePosLevel,
|
||||||
|
UpdateEmployeePosLevel,
|
||||||
|
} from "../entities/EmployeePosLevel";
|
||||||
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||||
|
|
||||||
@Route("api/v1/org/employee/pos/level")
|
@Route("api/v1/org/employee/pos/level")
|
||||||
|
|
@ -31,7 +35,6 @@ import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class EmployeePosLevelController extends Controller {
|
export class EmployeePosLevelController extends Controller {
|
||||||
|
|
||||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||||
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
||||||
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||||
|
|
@ -54,7 +57,7 @@ export class EmployeePosLevelController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
const EmpPosType = await this.employeePosTypeRepository.findOne({
|
const EmpPosType = await this.employeePosTypeRepository.findOne({
|
||||||
where: { id: requestBody.employeePosTypeId }
|
where: { id: requestBody.posTypeId },
|
||||||
});
|
});
|
||||||
if (!EmpPosType) {
|
if (!EmpPosType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
|
||||||
|
|
@ -99,7 +102,7 @@ export class EmployeePosLevelController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
const EmpPosType = await this.employeePosTypeRepository.findOne({
|
const EmpPosType = await this.employeePosTypeRepository.findOne({
|
||||||
where: { id: requestBody.employeePosTypeId }
|
where: { id: requestBody.posTypeId },
|
||||||
});
|
});
|
||||||
if (!EmpPosType) {
|
if (!EmpPosType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้");
|
||||||
|
|
@ -140,7 +143,7 @@ export class EmployeePosLevelController extends Controller {
|
||||||
|
|
||||||
//ตารางตำแหน่งลูกจ้างประจำ
|
//ตารางตำแหน่งลูกจ้างประจำ
|
||||||
const EmpPosition = await this.employeePosDictRepository.find({
|
const EmpPosition = await this.employeePosDictRepository.find({
|
||||||
where: { employeePosLevelId: id },
|
where: { posLevelId: id },
|
||||||
});
|
});
|
||||||
if (EmpPosition.length > 0) {
|
if (EmpPosition.length > 0) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
|
|
@ -163,8 +166,8 @@ export class EmployeePosLevelController extends Controller {
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetEmpLevelById(@Path() id: string) {
|
async GetEmpLevelById(@Path() id: string) {
|
||||||
const getEmpPosLevel = await this.employeePosLevelRepository.findOne({
|
const getEmpPosLevel = await this.employeePosLevelRepository.findOne({
|
||||||
relations: ["employeePosType"],
|
relations: ["posType"],
|
||||||
select: ["id", "posLevelName", "posLevelRank",],
|
select: ["id", "posLevelName", "posLevelRank"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!getEmpPosLevel) {
|
if (!getEmpPosLevel) {
|
||||||
|
|
@ -173,9 +176,9 @@ export class EmployeePosLevelController extends Controller {
|
||||||
const mapEmpPosLevel = {
|
const mapEmpPosLevel = {
|
||||||
id: getEmpPosLevel.id,
|
id: getEmpPosLevel.id,
|
||||||
posLevelName: getEmpPosLevel.posLevelName,
|
posLevelName: getEmpPosLevel.posLevelName,
|
||||||
posTypeName: getEmpPosLevel.employeePosType == null ? null : getEmpPosLevel.employeePosType.posTypeName, //กลุ่มงาน
|
posTypeName: getEmpPosLevel.posType == null ? null : getEmpPosLevel.posType.posTypeName, //กลุ่มงาน
|
||||||
commander: null //ผู้มีอำนาจสั่งบรรจุ
|
commander: null, //ผู้มีอำนาจสั่งบรรจุ
|
||||||
}
|
};
|
||||||
return new HttpSuccess(mapEmpPosLevel);
|
return new HttpSuccess(mapEmpPosLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,14 +191,14 @@ export class EmployeePosLevelController extends Controller {
|
||||||
@Get()
|
@Get()
|
||||||
async GetEmpPosLevel() {
|
async GetEmpPosLevel() {
|
||||||
const empPosLevel = await this.employeePosLevelRepository.find({
|
const empPosLevel = await this.employeePosLevelRepository.find({
|
||||||
relations: ["employeePosType"],
|
relations: ["posType"],
|
||||||
select: ["id","posLevelName", "posLevelRank",],
|
select: ["id", "posLevelName", "posLevelRank"],
|
||||||
});
|
});
|
||||||
const mapEmpPosLevel = empPosLevel.map((item) => ({
|
const mapEmpPosLevel = empPosLevel.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
posLevelName: item.posLevelName,
|
posLevelName: item.posLevelName,
|
||||||
posTypeName: item.employeePosType == null ? null : item.employeePosType.posTypeName, //กลุ่มงาน
|
posTypeName: item.posType == null ? null : item.posType.posTypeName, //กลุ่มงาน
|
||||||
commander: null //ผู้มีอำนาจสั่งบรรจุ
|
commander: null, //ผู้มีอำนาจสั่งบรรจุ
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess(mapEmpPosLevel);
|
return new HttpSuccess(mapEmpPosLevel);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,11 @@ import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { Not } from "typeorm";
|
import { Not } from "typeorm";
|
||||||
import { EmployeePosType, CreateEmployeePosType, UpdateEmployeePosType } from "../entities/EmployeePosType";
|
import {
|
||||||
|
EmployeePosType,
|
||||||
|
CreateEmployeePosType,
|
||||||
|
UpdateEmployeePosType,
|
||||||
|
} from "../entities/EmployeePosType";
|
||||||
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
||||||
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||||
|
|
||||||
|
|
@ -31,7 +35,6 @@ import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class EmployeePosTypeController extends Controller {
|
export class EmployeePosTypeController extends Controller {
|
||||||
|
|
||||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||||
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
private employeePosTypeRepository = AppDataSource.getRepository(EmployeePosType);
|
||||||
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
|
||||||
|
|
@ -59,10 +62,7 @@ export class EmployeePosTypeController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (chkEmpPosTypeName) {
|
if (chkEmpPosTypeName) {
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
EmpPosType.createdUserId = request.user.sub;
|
EmpPosType.createdUserId = request.user.sub;
|
||||||
EmpPosType.createdFullName = request.user.name;
|
EmpPosType.createdFullName = request.user.name;
|
||||||
|
|
@ -96,10 +96,7 @@ export class EmployeePosTypeController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (chkEmpPosType) {
|
if (chkEmpPosType) {
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
EmpPosType.lastUpdateUserId = request.user.sub;
|
EmpPosType.lastUpdateUserId = request.user.sub;
|
||||||
EmpPosType.lastUpdateFullName = request.user.name;
|
EmpPosType.lastUpdateFullName = request.user.name;
|
||||||
|
|
@ -123,7 +120,7 @@ export class EmployeePosTypeController extends Controller {
|
||||||
}
|
}
|
||||||
//ตารางระดับชั้นงาน
|
//ตารางระดับชั้นงาน
|
||||||
const EmpPosLevel = await this.employeePosLevelRepository.find({
|
const EmpPosLevel = await this.employeePosLevelRepository.find({
|
||||||
where: { employeePosTypeId: id },
|
where: { posTypeId: id },
|
||||||
});
|
});
|
||||||
if (EmpPosLevel.length > 0) {
|
if (EmpPosLevel.length > 0) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
|
|
@ -133,7 +130,7 @@ export class EmployeePosTypeController extends Controller {
|
||||||
}
|
}
|
||||||
//ตารางตำแหน่งลูกจ้างประจำ
|
//ตารางตำแหน่งลูกจ้างประจำ
|
||||||
const EmpPosition = await this.employeePosDictRepository.find({
|
const EmpPosition = await this.employeePosDictRepository.find({
|
||||||
where: { employeePosTypeId: id },
|
where: { posTypeId: id },
|
||||||
});
|
});
|
||||||
if (EmpPosition.length > 0) {
|
if (EmpPosition.length > 0) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
|
|
@ -156,8 +153,8 @@ export class EmployeePosTypeController extends Controller {
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetEmpTypeById(@Path() id: string) {
|
async GetEmpTypeById(@Path() id: string) {
|
||||||
const getEmpPosType = await this.employeePosTypeRepository.findOne({
|
const getEmpPosType = await this.employeePosTypeRepository.findOne({
|
||||||
|
relations: ["posLevels"],
|
||||||
select: ["id", "posTypeName", "posTypeRank"],
|
select: ["id", "posTypeName", "posTypeRank"],
|
||||||
relations: ["employeePosLevels"],
|
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!getEmpPosType) {
|
if (!getEmpPosType) {
|
||||||
|
|
@ -168,7 +165,7 @@ export class EmployeePosTypeController extends Controller {
|
||||||
id: getEmpPosType.id,
|
id: getEmpPosType.id,
|
||||||
posTypeName: getEmpPosType.posTypeName,
|
posTypeName: getEmpPosType.posTypeName,
|
||||||
posTypeRank: getEmpPosType.posTypeRank,
|
posTypeRank: getEmpPosType.posTypeRank,
|
||||||
posLevels: getEmpPosType.employeePosLevels.map((empPosLevel) => ({
|
posLevels: getEmpPosType.posLevels.map((empPosLevel) => ({
|
||||||
id: empPosLevel.id,
|
id: empPosLevel.id,
|
||||||
posLevelName: empPosLevel.posLevelName,
|
posLevelName: empPosLevel.posLevelName,
|
||||||
posLevelRank: empPosLevel.posLevelRank,
|
posLevelRank: empPosLevel.posLevelRank,
|
||||||
|
|
@ -187,15 +184,15 @@ export class EmployeePosTypeController extends Controller {
|
||||||
@Get()
|
@Get()
|
||||||
async GetEmpPosType() {
|
async GetEmpPosType() {
|
||||||
const empPosType = await this.employeePosTypeRepository.find({
|
const empPosType = await this.employeePosTypeRepository.find({
|
||||||
|
relations: ["posLevels"],
|
||||||
select: ["id", "posTypeName", "posTypeRank"],
|
select: ["id", "posTypeName", "posTypeRank"],
|
||||||
relations: ["employeePosLevels"],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapEmpPosType = empPosType.map((item) => ({
|
const mapEmpPosType = empPosType.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
posTypeName: item.posTypeName,
|
posTypeName: item.posTypeName,
|
||||||
posTypeRank: item.posTypeRank,
|
posTypeRank: item.posTypeRank,
|
||||||
posLevels: item.employeePosLevels.map((empPosLevel) => ({
|
posLevels: item.posLevels.map((empPosLevel) => ({
|
||||||
id: empPosLevel.id,
|
id: empPosLevel.id,
|
||||||
posLevelName: empPosLevel.posLevelName,
|
posLevelName: empPosLevel.posLevelName,
|
||||||
posLevelRank: empPosLevel.posLevelRank,
|
posLevelRank: empPosLevel.posLevelRank,
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -2097,7 +2097,7 @@ export class PositionController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API สร้างทะเบียนประวัติ
|
* API ลบคนครองตำแหน่ง
|
||||||
*
|
*
|
||||||
* @summary ORG_066 - ลบคนครองตำแหน่ง (ADMIN) #71
|
* @summary ORG_066 - ลบคนครองตำแหน่ง (ADMIN) #71
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { EmployeePosType } from "./EmployeePosType";
|
import { EmployeePosType } from "./EmployeePosType";
|
||||||
import { EmployeePosLevel } from "./EmployeePosLevel";
|
import { EmployeePosLevel } from "./EmployeePosLevel";
|
||||||
|
|
@ -17,21 +17,21 @@ export class EmployeePosDict extends EntityBase {
|
||||||
length: 40,
|
length: 40,
|
||||||
comment: "คีย์นอก(FK)ของตาราง employeePosType",
|
comment: "คีย์นอก(FK)ของตาราง employeePosType",
|
||||||
})
|
})
|
||||||
employeePosTypeId: string;
|
posTypeId: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
length: 40,
|
length: 40,
|
||||||
comment: "คีย์นอก(FK)ของตาราง employeePosLevel",
|
comment: "คีย์นอก(FK)ของตาราง employeePosLevel",
|
||||||
})
|
})
|
||||||
employeePosLevelId: string;
|
posLevelId: string;
|
||||||
|
|
||||||
@ManyToOne(() => EmployeePosType, (employeePosType) => employeePosType)
|
@ManyToOne(() => EmployeePosType, (posType) => posType)
|
||||||
@JoinColumn({ name: "employeePosTypeId" })
|
@JoinColumn({ name: "posTypeId" })
|
||||||
employeePosType: EmployeePosType;
|
posType: EmployeePosType;
|
||||||
|
|
||||||
@ManyToOne(() => EmployeePosLevel, (employeePosLevel) => employeePosLevel)
|
@ManyToOne(() => EmployeePosLevel, (posLevel) => posLevel)
|
||||||
@JoinColumn({ name: "employeePosLevelId" })
|
@JoinColumn({ name: "posLevelId" })
|
||||||
employeePosLevel: EmployeePosLevel;
|
posLevel: EmployeePosLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateEmployeePosDict {
|
export class CreateEmployeePosDict {
|
||||||
|
|
@ -39,10 +39,10 @@ export class CreateEmployeePosDict {
|
||||||
posDictName: string | null;
|
posDictName: string | null;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
employeePosTypeId: string | null;
|
posTypeId: string | null;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
employeePosLevelId: string | null;
|
posLevelId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateEmployeePosDict {
|
export class UpdateEmployeePosDict {
|
||||||
|
|
@ -50,8 +50,8 @@ export class UpdateEmployeePosDict {
|
||||||
posDictName: string;
|
posDictName: string;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
employeePosTypeId: string;
|
posTypeId: string;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
employeePosLevelId: string;
|
posLevelId: string;
|
||||||
}
|
}
|
||||||
|
|
@ -21,15 +21,14 @@ export class EmployeePosLevel extends EntityBase {
|
||||||
length: 40,
|
length: 40,
|
||||||
comment: "คีย์นอก(FK)ของตาราง employeePosType",
|
comment: "คีย์นอก(FK)ของตาราง employeePosType",
|
||||||
})
|
})
|
||||||
employeePosTypeId: string;
|
posTypeId: string;
|
||||||
|
|
||||||
@ManyToOne(() => EmployeePosType, (employeePosType) => employeePosType.employeePosLevels)
|
@ManyToOne(() => EmployeePosType, (posType) => posType.posLevels)
|
||||||
@JoinColumn({ name: "employeePosTypeId" })
|
@JoinColumn({ name: "posTypeId" })
|
||||||
employeePosType: EmployeePosType;
|
posType: EmployeePosType;
|
||||||
|
|
||||||
@OneToMany(() => EmployeePosDict, (employeePosDict) => employeePosDict.employeePosLevel)
|
|
||||||
employeePosDicts: EmployeePosDict[];
|
|
||||||
|
|
||||||
|
@OneToMany(() => EmployeePosDict, (posDict) => posDict.posLevel)
|
||||||
|
posDicts: EmployeePosDict[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateEmployeePosLevel {
|
export class CreateEmployeePosLevel {
|
||||||
|
|
@ -40,8 +39,7 @@ export class CreateEmployeePosLevel {
|
||||||
posLevelRank: number;
|
posLevelRank: number;
|
||||||
|
|
||||||
@Column("uuid")
|
@Column("uuid")
|
||||||
employeePosTypeId: string;
|
posTypeId: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateEmployeePosLevel= Partial<CreateEmployeePosLevel>;
|
export type UpdateEmployeePosLevel = Partial<CreateEmployeePosLevel>;
|
||||||
|
|
|
||||||
218
src/entities/EmployeePosMaster.ts
Normal file
218
src/entities/EmployeePosMaster.ts
Normal file
|
|
@ -0,0 +1,218 @@
|
||||||
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany, ManyToMany } from "typeorm";
|
||||||
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { CreateEmployeePosDict } from "./EmployeePosDict";
|
||||||
|
import { OrgRevision } from "./OrgRevision";
|
||||||
|
import { CreateEmployeePosition, EmployeePosition } from "./EmployeePosition";
|
||||||
|
import { OrgRoot } from "./OrgRoot";
|
||||||
|
import { OrgChild1 } from "./OrgChild1";
|
||||||
|
import { OrgChild2 } from "./OrgChild2";
|
||||||
|
import { OrgChild3 } from "./OrgChild3";
|
||||||
|
import { OrgChild4 } from "./OrgChild4";
|
||||||
|
import { Profile } from "./Profile";
|
||||||
|
|
||||||
|
enum EmployeePosMasterLine {
|
||||||
|
MAIN = "MAIN",
|
||||||
|
SUPPORT = "SUPPORT",
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity("employeePosMaster")
|
||||||
|
export class EmployeePosMaster extends EntityBase {
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)",
|
||||||
|
length: 16,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterNoPrefix: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "เลขที่ตำแหน่ง เป็นตัวเลข",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterNo: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "Suffix หลังเลขที่ตำแหน่ง เช่น ช.",
|
||||||
|
length: 16,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterNoSuffix: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "datetime",
|
||||||
|
comment: "วัน-เวลาที่สร้าง",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterCreatedAt: Date;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment:
|
||||||
|
"รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
ancestorDNA: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ลำดับที่แสดงผล",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterOrder: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ลำดับความสำคัญ",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterPriority: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "สายงานในอัตรากำลัง (หลัก / สนับสนุน) คนละฟิลด์กับสายงานของตำแหน่ง",
|
||||||
|
type: "enum",
|
||||||
|
enum: EmployeePosMasterLine,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
posMasterLine: EmployeePosMasterLine;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "นั่งทับตำแหน่งไหม",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isSit: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง orgRoot",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
orgRootId?: string | null;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง orgChild1",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
orgChild1Id?: string | null;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง orgChild2",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
orgChild2Id?: string | null;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง orgChild3",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
orgChild3Id?: string | null;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง orgChild4",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
orgChild4Id?: string | null;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment:
|
||||||
|
"คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
current_holderId?: string | null;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment:
|
||||||
|
"คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
next_holderId?: string | null;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
||||||
|
})
|
||||||
|
orgRevisionId: string; //fk
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
|
||||||
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
orgRevision: OrgRevision;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.posMasters)
|
||||||
|
@JoinColumn({ name: "orgRootId" })
|
||||||
|
orgRoot: OrgRoot;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.posMasters)
|
||||||
|
@JoinColumn({ name: "orgChild1Id" })
|
||||||
|
orgChild1: OrgChild1;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.posMasters)
|
||||||
|
@JoinColumn({ name: "orgChild2Id" })
|
||||||
|
orgChild2: OrgChild2;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.posMasters)
|
||||||
|
@JoinColumn({ name: "orgChild3Id" })
|
||||||
|
orgChild3: OrgChild3;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgChild4, (orgChild4) => orgChild4.posMasters)
|
||||||
|
@JoinColumn({ name: "orgChild4Id" })
|
||||||
|
orgChild4: OrgChild4;
|
||||||
|
|
||||||
|
@ManyToOne(() => Profile, (posMaster) => posMaster.current_holders)
|
||||||
|
@JoinColumn({ name: "current_holderId" })
|
||||||
|
current_holder: Profile;
|
||||||
|
|
||||||
|
@ManyToOne(() => Profile, (posMaster) => posMaster.next_holders)
|
||||||
|
@JoinColumn({ name: "next_holderId" })
|
||||||
|
next_holder: Profile;
|
||||||
|
|
||||||
|
@OneToMany(() => EmployeePosition, (position) => position.posMaster)
|
||||||
|
positions: EmployeePosition[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CreateEmployeePosMaster {
|
||||||
|
@Column()
|
||||||
|
posMasterNoPrefix: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
posMasterNo: number;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
posMasterNoSuffix: string;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
positions: CreateEmployeePosDict[];
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
orgRootId?: string | null;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
orgChild1Id?: string | null;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
orgChild2Id?: string | null;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
orgChild3Id?: string | null;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
orgChild4Id?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type UpdateEmployeePosMaster = Partial<EmployeePosMaster>;
|
||||||
|
|
@ -26,12 +26,11 @@ export class EmployeePosType extends EntityBase {
|
||||||
})
|
})
|
||||||
posTypeShortName: string;
|
posTypeShortName: string;
|
||||||
|
|
||||||
@OneToMany(() => EmployeePosLevel, (employeePosLevel) => employeePosLevel.employeePosType)
|
@OneToMany(() => EmployeePosLevel, (posLevel) => posLevel.posType)
|
||||||
employeePosLevels: EmployeePosLevel[];
|
posLevels: EmployeePosLevel[];
|
||||||
|
|
||||||
@OneToMany(() => EmployeePosDict, (employeePosDict) => employeePosDict.employeePosType)
|
|
||||||
employeePosDicts: EmployeePosDict[];
|
|
||||||
|
|
||||||
|
@OneToMany(() => EmployeePosDict, (posDict) => posDict.posType)
|
||||||
|
posDicts: EmployeePosDict[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateEmployeePosType {
|
export class CreateEmployeePosType {
|
||||||
|
|
@ -43,7 +42,6 @@ export class CreateEmployeePosType {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
posTypeShortName: string;
|
posTypeShortName: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateEmployeePosType = Partial<CreateEmployeePosType>;
|
export type UpdateEmployeePosType = Partial<CreateEmployeePosType>;
|
||||||
|
|
|
||||||
74
src/entities/EmployeePosition.ts
Normal file
74
src/entities/EmployeePosition.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
||||||
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { EmployeePosType } from "./EmployeePosType";
|
||||||
|
import { EmployeePosLevel } from "./EmployeePosLevel";
|
||||||
|
import { EmployeePosMaster } from "./EmployeePosMaster";
|
||||||
|
|
||||||
|
@Entity("employeePosition")
|
||||||
|
export class EmployeePosition extends EntityBase {
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ชื่อตำแหน่ง",
|
||||||
|
length: 255,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
positionName: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง employeePosType",
|
||||||
|
})
|
||||||
|
posTypeId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง employeePosLevel",
|
||||||
|
})
|
||||||
|
posLevelId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
positionIsSelected: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
length: 40,
|
||||||
|
comment: "เชื่อมโยงกับตารางเลขที่ตำแหน่ง",
|
||||||
|
})
|
||||||
|
posMasterId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => EmployeePosMaster, (posMaster) => posMaster)
|
||||||
|
@JoinColumn({ name: "posMasterId" })
|
||||||
|
posMaster: EmployeePosMaster;
|
||||||
|
|
||||||
|
@ManyToOne(() => EmployeePosType, (posType) => posType)
|
||||||
|
@JoinColumn({ name: "posTypeId" })
|
||||||
|
posType: EmployeePosType;
|
||||||
|
|
||||||
|
@ManyToOne(() => EmployeePosLevel, (posLevel) => posLevel)
|
||||||
|
@JoinColumn({ name: "posLevelId" })
|
||||||
|
posLevel: EmployeePosLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CreateEmployeePosition {
|
||||||
|
@Column()
|
||||||
|
positionName: string | null;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
posTypeId: string | null;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
posLevelId: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class UpdateEmployeePosition {
|
||||||
|
@Column()
|
||||||
|
positionName: string;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
posTypeId: string;
|
||||||
|
|
||||||
|
@Column("uuid")
|
||||||
|
posLevelId: string;
|
||||||
|
}
|
||||||
38
src/migration/1710328629522-add_table_employeePosition.ts
Normal file
38
src/migration/1710328629522-add_table_employeePosition.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddTableEmployeePosition1710328629522 implements MigrationInterface {
|
||||||
|
name = 'AddTableEmployeePosition1710328629522'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE TABLE \`employeePosition\` (\`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', \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่ง', \`posTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType', \`posLevelId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosLevel', \`positionIsSelected\` tinyint NOT NULL COMMENT 'เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?' DEFAULT 0, \`posMasterId\` varchar(40) NOT NULL COMMENT 'เชื่อมโยงกับตารางเลขที่ตำแหน่ง', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`CREATE TABLE \`employeePosMaster\` (\`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', \`posMasterNoPrefix\` varchar(16) NULL COMMENT 'Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)', \`posMasterNo\` int NULL COMMENT 'เลขที่ตำแหน่ง เป็นตัวเลข', \`posMasterNoSuffix\` varchar(16) NULL COMMENT 'Suffix หลังเลขที่ตำแหน่ง เช่น ช.', \`posMasterCreatedAt\` datetime NULL COMMENT 'วัน-เวลาที่สร้าง', \`ancestorDNA\` varchar(40) NULL COMMENT 'รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้', \`posMasterOrder\` int NULL COMMENT 'ลำดับที่แสดงผล', \`posMasterPriority\` int NULL COMMENT 'ลำดับความสำคัญ', \`posMasterLine\` enum ('MAIN', 'SUPPORT') NULL COMMENT 'สายงานในอัตรากำลัง (หลัก / สนับสนุน) คนละฟิลด์กับสายงานของตำแหน่ง', \`isSit\` tinyint NOT NULL COMMENT 'นั่งทับตำแหน่งไหม' DEFAULT 0, \`orgRootId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot', \`orgChild1Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild1', \`orgChild2Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild2', \`orgChild3Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild3', \`orgChild4Id\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgChild4', \`current_holderId\` varchar(40) NULL COMMENT 'คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้', \`next_holderId\` varchar(40) NULL COMMENT 'คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย', \`orgRevisionId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRevision', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosition\` ADD CONSTRAINT \`FK_1c8174b8e11333448f250657c49\` FOREIGN KEY (\`posMasterId\`) REFERENCES \`employeePosMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosition\` ADD CONSTRAINT \`FK_c3b098a7bdf65ed6daec420d23e\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosition\` ADD CONSTRAINT \`FK_ef5fcb52f3920d3029a334ae19e\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_85b7778f4b345c6c214f47e4a8f\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_93aae3c3c292aadf0b3a4c9019e\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_bbda5c4d36100593214af67f522\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_768a012f53f8cb3a87876a541f5\` FOREIGN KEY (\`orgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_bce3a2a666b53ce5ac10aafbbfa\` FOREIGN KEY (\`orgChild3Id\`) REFERENCES \`orgChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` ADD CONSTRAINT \`FK_c6dd2d044ce9a06c2e8e0e8af0f\` FOREIGN KEY (\`orgChild4Id\`) REFERENCES \`orgChild4\`(\`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`);
|
||||||
|
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`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
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(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_c6dd2d044ce9a06c2e8e0e8af0f\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_bce3a2a666b53ce5ac10aafbbfa\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_768a012f53f8cb3a87876a541f5\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_bbda5c4d36100593214af67f522\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_93aae3c3c292aadf0b3a4c9019e\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosMaster\` DROP FOREIGN KEY \`FK_85b7778f4b345c6c214f47e4a8f\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosition\` DROP FOREIGN KEY \`FK_ef5fcb52f3920d3029a334ae19e\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosition\` DROP FOREIGN KEY \`FK_c3b098a7bdf65ed6daec420d23e\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosition\` DROP FOREIGN KEY \`FK_1c8174b8e11333448f250657c49\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`employeePosMaster\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`employeePosition\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
34
src/migration/1710330337194-add_table_employeePosition1.ts
Normal file
34
src/migration/1710330337194-add_table_employeePosition1.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddTableEmployeePosition11710330337194 implements MigrationInterface {
|
||||||
|
name = 'AddTableEmployeePosition11710330337194'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` DROP FOREIGN KEY \`FK_a822851af7b58288be65debfdd5\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP FOREIGN KEY \`FK_28d45cec912604b7d6f3dfac39a\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP FOREIGN KEY \`FK_73ad56ef383399f567d58b213e2\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`employeePosTypeId\` \`posTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP COLUMN \`employeePosTypeId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP COLUMN \`employeePosLevelId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD \`posTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD \`posLevelId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosLevel'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` ADD CONSTRAINT \`FK_7fb9ab868f3f46b44f460c984f1\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD CONSTRAINT \`FK_63e8a14abd222c948e0e175e941\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD CONSTRAINT \`FK_73da087c2ee4b6e74c9590ae3a2\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP FOREIGN KEY \`FK_73da087c2ee4b6e74c9590ae3a2\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP FOREIGN KEY \`FK_63e8a14abd222c948e0e175e941\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` DROP FOREIGN KEY \`FK_7fb9ab868f3f46b44f460c984f1\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP COLUMN \`posLevelId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP COLUMN \`posTypeId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD \`employeePosLevelId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosLevel'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD \`employeePosTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`posTypeId\` \`employeePosTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD CONSTRAINT \`FK_73ad56ef383399f567d58b213e2\` FOREIGN KEY (\`employeePosTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD CONSTRAINT \`FK_28d45cec912604b7d6f3dfac39a\` FOREIGN KEY (\`employeePosLevelId\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` ADD CONSTRAINT \`FK_a822851af7b58288be65debfdd5\` FOREIGN KEY (\`employeePosTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue