From afa7c95a0180c2cafe0caf87c22829e9c3da5951 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 11 Jun 2024 16:13:51 +0700 Subject: [PATCH 1/5] no message --- src/controllers/ProfileAvatarController.ts | 12 +++++++++ src/controllers/ProfileController.ts | 30 +++++++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index a97cb6a1..c79e1821 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -22,6 +22,18 @@ export class ProfileAvatarController extends Controller { return new HttpSuccess(lists); } + @Get("profileId/{id}") + async getProfile(@Path() id: string) { + const profile = await this.profileRepository.findOne({ + select: ["avatar", "avatarName"], + where: { id }, + }); + + if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + return new HttpSuccess(profile); + } + @Get("select/{profileId}/{id}") public async selectAvatar(@Path() profileId: string, @Path() id: string) { const result = await this.avatarRepository.findOneBy({ id: id }); diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index f3168c46..7862f8f0 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -496,15 +496,27 @@ export class ProfileController extends Controller { 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 = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.posType", "posType") + .skip((1 - 1) * 20) + .take(20) + .getMany(); + const _commander = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.posType", "posType") + .skip((1 - 1) * 20) + .take(20) + .getMany(); + const _chairman = await this.profileRepo + .createQueryBuilder("profile") + .leftJoinAndSelect("profile.posLevel", "posLevel") + .leftJoinAndSelect("profile.posType", "posType") + .skip((1 - 1) * 20) + .take(20) + .getMany(); const caregiver = _caregiver.map((_data) => ({ id: _data.id, From dd5662c14ae016fb74d4a69627aad1285a3b0649 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 11 Jun 2024 16:14:36 +0700 Subject: [PATCH 2/5] =?UTF-8?q?entity=20=E0=B8=A2=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=A2=E0=B8=AA=E0=B8=B1=E0=B8=9A=E0=B9=80=E0=B8=9B=E0=B8=A5?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=A2=E0=B8=99=E0=B8=95=E0=B8=B3=E0=B9=81?= =?UTF-8?q?=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ChangePositionController.ts | 50 +++++ src/controllers/ProfileEmployeeController.ts | 6 +- src/entities/ChangePosition.ts | 37 ++++ src/entities/ProfileChangePosition.ts | 200 +++++++++++++++++++ 4 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 src/controllers/ChangePositionController.ts create mode 100644 src/entities/ChangePosition.ts create mode 100644 src/entities/ProfileChangePosition.ts diff --git a/src/controllers/ChangePositionController.ts b/src/controllers/ChangePositionController.ts new file mode 100644 index 00000000..09f231d8 --- /dev/null +++ b/src/controllers/ChangePositionController.ts @@ -0,0 +1,50 @@ +import { + Controller, + Get, + Post, + Put, + Delete, + Patch, + Route, + Security, + Tags, + Body, + Path, + Request, + Example, + SuccessResponse, + Response, + Query, +} from "tsoa"; +import { AppDataSource } from "../database/data-source"; +import HttpSuccess from "../interfaces/http-success"; +import HttpStatusCode from "../interfaces/http-status"; +import { Equal, ILike, In, IsNull, Like, Not, Brackets, MoreThan } from "typeorm"; +import { ChangePosition } from "../entities/ChangePosition"; + +@Route("api/v1/placement/change-position") +@Tags("Switch") +@Security("bearerAuth") +@Response( + HttpStatusCode.INTERNAL_SERVER_ERROR, + "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", +) +@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +export class ChangePositionController extends Controller { + private ChangePositionRepository = AppDataSource.getRepository(ChangePosition); + + /** + * API รายการออกคำสั่งย้ายสับเปลี่ยนตำแหน่ง + * + * @summary API รายการออกคำสั่งย้ายสับเปลี่ยนตำแหน่ง + * + */ + @Get("") + async GetChangePositionLists() { + + const data = await this.ChangePositionRepository.find(); + return new HttpSuccess(data); + + } + +} diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index ec09edf0..e6f70abb 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -556,7 +556,11 @@ export class ProfileEmployeeController extends Controller { const exists = !!body.citizenId && (await this.profileRepo.findOne({ - where: { id: Not(id), citizenId: body.citizenId }, + where: { + id: Not(id), + citizenId: body.citizenId, + employeeClass: String(body.employeeClass) + }, })); if (exists) { diff --git a/src/entities/ChangePosition.ts b/src/entities/ChangePosition.ts new file mode 100644 index 00000000..428ba1c5 --- /dev/null +++ b/src/entities/ChangePosition.ts @@ -0,0 +1,37 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { ProfileChangePosition } from "./ProfileChangePosition"; + +@Entity("changePosition") +export class ChangePosition extends EntityBase { + @Column({ + nullable: true, + comment: "ชื่อรอบการย้ายสับเปลี่ยนตำแหน่ง", + type: "text", + default: null, + }) + name: string; + + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่ดำเนินการ", + default: null, + }) + date: Date; + + @OneToMany(() => ProfileChangePosition, (x) => x.profile) + profileChangePosition: ProfileChangePosition[]; +} + +export class CreateChangePosition { + name: string; + date?: Date; + status?: string; +} + +export type UpdateChangePosition = { + name: string; + date?: Date; + status?: string; +}; diff --git a/src/entities/ProfileChangePosition.ts b/src/entities/ProfileChangePosition.ts new file mode 100644 index 00000000..0baa3bf8 --- /dev/null +++ b/src/entities/ProfileChangePosition.ts @@ -0,0 +1,200 @@ +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { ChangePosition } from "./ChangePosition"; + +@Entity("profileChangePosition") +export class ProfileChangePosition extends EntityBase { + @Column({ nullable: true, comment: "เหตุผลที่รับโอนราชการ", type: "text", default: null }) + reason: string; + + @Column({ nullable: true, comment: "วุฒิ/สาขาเดิม", default: null }) + educationOld: string; + + @Column({ nullable: true, comment: "สังกัดเดิม", default: null }) + organizationPositionOld: string; + + @Column({ nullable: true, comment: "สังกัดเดิม", default: null }) + organizationOld: string; + + @Column({ nullable: true, comment: "ตำแหน่งเดิม", default: null }) + positionOld: string; + + @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท", default: null }) + positionTypeOld: string; + + @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ", default: null }) + positionLevelOld: string; + + @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่", default: null }) + positionNumberOld: string; + + @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน", type: "double", default: null }) + amountOld: number; + + + + @Column({ nullable: true, comment: "profile Id", default: null }) + profileId: string; + + @Column({ nullable: true, comment: "คำนำหน้า", default: null }) + prefix: string; + + @Column({ nullable: true, comment: "ชื่อ", default: null }) + firstName: string; + + @Column({ nullable: true, comment: "นามสกุล", default: null }) + lastName: string; + + @Column({ nullable: true, comment: "เลขบัตรประชาชน", default: null }) + citizenId: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน root", default: null }) + root: string; + + @Column({ nullable: true, comment: "id หน่วยงาน root", default: null }) + rootId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน root", default: null }) + rootShortName: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child1", default: null }) + child1: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child1", default: null }) + child1Id: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child1", default: null }) + child1ShortName: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child2", default: null }) + child2: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child2", default: null }) + child2Id: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child2", default: null }) + child2ShortName: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child3", default: null }) + child3: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child3", default: null }) + child3Id: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child3", default: null }) + child3ShortName: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child4", default: null }) + child4: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child4", default: null }) + child4Id: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child4", default: null }) + child4ShortName: string; + + @Column({ nullable: true, comment: "ระดับโครงสร้าง", type: "int", default: null }) + node: number; + + @Column({ nullable: true, comment: "id โครงสร้าง", type: "uuid", default: null }) + nodeId: string; + + @Column({ nullable: true, comment: "id อัตรากำลัง", default: null }) + posmasterId: string; + + @Column({ nullable: true, comment: "id revision", default: null }) + orgRevisionId: string; + + @Column({ nullable: true, comment: "id ตำแหน่ง", default: null }) + positionId: string; + + @Column({ nullable: true, comment: "สายงาน", default: null }) + positionField: string; + + @Column({ nullable: true, comment: "เลขที่ตำแหน่ง", type: "int", default: null }) + posMasterNo: number; + + @Column({ nullable: true, comment: "ชื่อตำแหน่งในสายงาน", default: null }) + position: string; + + @Column({ nullable: true, comment: "id ประเภทตำแหน่ง", default: null }) + posTypeId: string; + + @Column({ nullable: true, comment: "ชื่อประเภทตำแหน่ง", default: null }) + posTypeName: string; + + @Column({ nullable: true, comment: "id ระดับตำแหน่ง", default: null }) + posLevelId: string; + + @Column({ nullable: true, comment: "ชื่อระดับตำแหน่ง", default: null }) + posLevelName: string; + + + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน root old", default: null }) + rootOld: string; + + @Column({ nullable: true, comment: "id หน่วยงาน root old", default: null }) + rootOldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน root old", default: null }) + rootShortNameOld: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child1 old", default: null }) + child1Old: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child1 old", default: null }) + child1OldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child1 old", default: null }) + child1ShortNameOld: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child2 old", default: null }) + child2Old: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child2 old", default: null }) + child2OldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child2 old", default: null }) + child2ShortNameOld: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child3 old", default: null }) + child3Old: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child3 old", default: null }) + child3OldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child3 old", default: null }) + child3ShortNameOld: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child4 old", default: null }) + child4Old: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child4 old", default: null }) + child4OldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child4 old", default: null }) + child4ShortNameOld: string; + + @Column({ nullable: true, comment: "เลขที่ตำแหน่ง old", type: "int", default: null }) + posMasterNoOld: number; + + @Column({ nullable: true, comment: "id ประเภทตำแหน่ง old", default: null }) + posTypeOldId: string; + + @Column({ nullable: true, comment: "ชื่อประเภทตำแหน่ง old", default: null }) + posTypeNameOld: string; + + @Column({ nullable: true, comment: "id ระดับตำแหน่ง old", default: null }) + posLevelOldId: string; + + @Column({ nullable: true, comment: "ชื่อระดับตำแหน่ง old", default: null }) + posLevelNameOld: string; + + @Column({nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง ChangePosition", default: null }) + changePositionId: string; + + @ManyToOne(() => ChangePosition, (v) => v.profileChangePosition) + @JoinColumn({ name: "changePositionId" }) + profile: ChangePosition; +} From c1be9bc235b63012a7b83f8da1883791aea3a3b5 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 11 Jun 2024 16:14:36 +0700 Subject: [PATCH 3/5] =?UTF-8?q?entity=20=E0=B8=A2=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=A2=E0=B8=AA=E0=B8=B1=E0=B8=9A=E0=B9=80=E0=B8=9B=E0=B8=A5?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=A2=E0=B8=99=E0=B8=95=E0=B8=B3=E0=B9=81?= =?UTF-8?q?=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ChangePositionController.ts | 50 +++++ src/controllers/ProfileEmployeeController.ts | 6 +- src/entities/ChangePosition.ts | 37 ++++ src/entities/ProfileChangePosition.ts | 200 +++++++++++++++++++ 4 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 src/controllers/ChangePositionController.ts create mode 100644 src/entities/ChangePosition.ts create mode 100644 src/entities/ProfileChangePosition.ts diff --git a/src/controllers/ChangePositionController.ts b/src/controllers/ChangePositionController.ts new file mode 100644 index 00000000..09f231d8 --- /dev/null +++ b/src/controllers/ChangePositionController.ts @@ -0,0 +1,50 @@ +import { + Controller, + Get, + Post, + Put, + Delete, + Patch, + Route, + Security, + Tags, + Body, + Path, + Request, + Example, + SuccessResponse, + Response, + Query, +} from "tsoa"; +import { AppDataSource } from "../database/data-source"; +import HttpSuccess from "../interfaces/http-success"; +import HttpStatusCode from "../interfaces/http-status"; +import { Equal, ILike, In, IsNull, Like, Not, Brackets, MoreThan } from "typeorm"; +import { ChangePosition } from "../entities/ChangePosition"; + +@Route("api/v1/placement/change-position") +@Tags("Switch") +@Security("bearerAuth") +@Response( + HttpStatusCode.INTERNAL_SERVER_ERROR, + "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", +) +@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +export class ChangePositionController extends Controller { + private ChangePositionRepository = AppDataSource.getRepository(ChangePosition); + + /** + * API รายการออกคำสั่งย้ายสับเปลี่ยนตำแหน่ง + * + * @summary API รายการออกคำสั่งย้ายสับเปลี่ยนตำแหน่ง + * + */ + @Get("") + async GetChangePositionLists() { + + const data = await this.ChangePositionRepository.find(); + return new HttpSuccess(data); + + } + +} diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index ec09edf0..e6f70abb 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -556,7 +556,11 @@ export class ProfileEmployeeController extends Controller { const exists = !!body.citizenId && (await this.profileRepo.findOne({ - where: { id: Not(id), citizenId: body.citizenId }, + where: { + id: Not(id), + citizenId: body.citizenId, + employeeClass: String(body.employeeClass) + }, })); if (exists) { diff --git a/src/entities/ChangePosition.ts b/src/entities/ChangePosition.ts new file mode 100644 index 00000000..428ba1c5 --- /dev/null +++ b/src/entities/ChangePosition.ts @@ -0,0 +1,37 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { ProfileChangePosition } from "./ProfileChangePosition"; + +@Entity("changePosition") +export class ChangePosition extends EntityBase { + @Column({ + nullable: true, + comment: "ชื่อรอบการย้ายสับเปลี่ยนตำแหน่ง", + type: "text", + default: null, + }) + name: string; + + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่ดำเนินการ", + default: null, + }) + date: Date; + + @OneToMany(() => ProfileChangePosition, (x) => x.profile) + profileChangePosition: ProfileChangePosition[]; +} + +export class CreateChangePosition { + name: string; + date?: Date; + status?: string; +} + +export type UpdateChangePosition = { + name: string; + date?: Date; + status?: string; +}; diff --git a/src/entities/ProfileChangePosition.ts b/src/entities/ProfileChangePosition.ts new file mode 100644 index 00000000..0baa3bf8 --- /dev/null +++ b/src/entities/ProfileChangePosition.ts @@ -0,0 +1,200 @@ +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { ChangePosition } from "./ChangePosition"; + +@Entity("profileChangePosition") +export class ProfileChangePosition extends EntityBase { + @Column({ nullable: true, comment: "เหตุผลที่รับโอนราชการ", type: "text", default: null }) + reason: string; + + @Column({ nullable: true, comment: "วุฒิ/สาขาเดิม", default: null }) + educationOld: string; + + @Column({ nullable: true, comment: "สังกัดเดิม", default: null }) + organizationPositionOld: string; + + @Column({ nullable: true, comment: "สังกัดเดิม", default: null }) + organizationOld: string; + + @Column({ nullable: true, comment: "ตำแหน่งเดิม", default: null }) + positionOld: string; + + @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท", default: null }) + positionTypeOld: string; + + @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ", default: null }) + positionLevelOld: string; + + @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่", default: null }) + positionNumberOld: string; + + @Column({ nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน", type: "double", default: null }) + amountOld: number; + + + + @Column({ nullable: true, comment: "profile Id", default: null }) + profileId: string; + + @Column({ nullable: true, comment: "คำนำหน้า", default: null }) + prefix: string; + + @Column({ nullable: true, comment: "ชื่อ", default: null }) + firstName: string; + + @Column({ nullable: true, comment: "นามสกุล", default: null }) + lastName: string; + + @Column({ nullable: true, comment: "เลขบัตรประชาชน", default: null }) + citizenId: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน root", default: null }) + root: string; + + @Column({ nullable: true, comment: "id หน่วยงาน root", default: null }) + rootId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน root", default: null }) + rootShortName: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child1", default: null }) + child1: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child1", default: null }) + child1Id: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child1", default: null }) + child1ShortName: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child2", default: null }) + child2: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child2", default: null }) + child2Id: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child2", default: null }) + child2ShortName: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child3", default: null }) + child3: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child3", default: null }) + child3Id: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child3", default: null }) + child3ShortName: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child4", default: null }) + child4: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child4", default: null }) + child4Id: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child4", default: null }) + child4ShortName: string; + + @Column({ nullable: true, comment: "ระดับโครงสร้าง", type: "int", default: null }) + node: number; + + @Column({ nullable: true, comment: "id โครงสร้าง", type: "uuid", default: null }) + nodeId: string; + + @Column({ nullable: true, comment: "id อัตรากำลัง", default: null }) + posmasterId: string; + + @Column({ nullable: true, comment: "id revision", default: null }) + orgRevisionId: string; + + @Column({ nullable: true, comment: "id ตำแหน่ง", default: null }) + positionId: string; + + @Column({ nullable: true, comment: "สายงาน", default: null }) + positionField: string; + + @Column({ nullable: true, comment: "เลขที่ตำแหน่ง", type: "int", default: null }) + posMasterNo: number; + + @Column({ nullable: true, comment: "ชื่อตำแหน่งในสายงาน", default: null }) + position: string; + + @Column({ nullable: true, comment: "id ประเภทตำแหน่ง", default: null }) + posTypeId: string; + + @Column({ nullable: true, comment: "ชื่อประเภทตำแหน่ง", default: null }) + posTypeName: string; + + @Column({ nullable: true, comment: "id ระดับตำแหน่ง", default: null }) + posLevelId: string; + + @Column({ nullable: true, comment: "ชื่อระดับตำแหน่ง", default: null }) + posLevelName: string; + + + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน root old", default: null }) + rootOld: string; + + @Column({ nullable: true, comment: "id หน่วยงาน root old", default: null }) + rootOldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน root old", default: null }) + rootShortNameOld: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child1 old", default: null }) + child1Old: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child1 old", default: null }) + child1OldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child1 old", default: null }) + child1ShortNameOld: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child2 old", default: null }) + child2Old: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child2 old", default: null }) + child2OldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child2 old", default: null }) + child2ShortNameOld: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child3 old", default: null }) + child3Old: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child3 old", default: null }) + child3OldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child3 old", default: null }) + child3ShortNameOld: string; + + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child4 old", default: null }) + child4Old: string; + + @Column({ nullable: true, comment: "id หน่วยงาน child4 old", default: null }) + child4OldId: string; + + @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน child4 old", default: null }) + child4ShortNameOld: string; + + @Column({ nullable: true, comment: "เลขที่ตำแหน่ง old", type: "int", default: null }) + posMasterNoOld: number; + + @Column({ nullable: true, comment: "id ประเภทตำแหน่ง old", default: null }) + posTypeOldId: string; + + @Column({ nullable: true, comment: "ชื่อประเภทตำแหน่ง old", default: null }) + posTypeNameOld: string; + + @Column({ nullable: true, comment: "id ระดับตำแหน่ง old", default: null }) + posLevelOldId: string; + + @Column({ nullable: true, comment: "ชื่อระดับตำแหน่ง old", default: null }) + posLevelNameOld: string; + + @Column({nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง ChangePosition", default: null }) + changePositionId: string; + + @ManyToOne(() => ChangePosition, (v) => v.profileChangePosition) + @JoinColumn({ name: "changePositionId" }) + profile: ChangePosition; +} From fc0f86b845644e458a9e521a2cd1ed80f192da83 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 11 Jun 2024 16:19:35 +0700 Subject: [PATCH 4/5] migrate --- .../1718097497764-add_table_change_position.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/migration/1718097497764-add_table_change_position.ts diff --git a/src/migration/1718097497764-add_table_change_position.ts b/src/migration/1718097497764-add_table_change_position.ts new file mode 100644 index 00000000..ee44c7fa --- /dev/null +++ b/src/migration/1718097497764-add_table_change_position.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableChangePosition1718097497764 implements MigrationInterface { + name = 'AddTableChangePosition1718097497764' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`changePosition\` (\`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', \`name\` text NULL COMMENT 'ชื่อรอบการย้ายสับเปลี่ยนตำแหน่ง', \`date\` datetime NULL COMMENT 'วันที่ดำเนินการ', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`profileChangePosition\` (\`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', \`reason\` text NULL COMMENT 'เหตุผลที่รับโอนราชการ', \`educationOld\` varchar(255) NULL COMMENT 'วุฒิ/สาขาเดิม', \`organizationPositionOld\` varchar(255) NULL COMMENT 'สังกัดเดิม', \`organizationOld\` varchar(255) NULL COMMENT 'สังกัดเดิม', \`positionOld\` varchar(255) NULL COMMENT 'ตำแหน่งเดิม', \`positionTypeOld\` varchar(255) NULL COMMENT 'ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท', \`positionLevelOld\` varchar(255) NULL COMMENT 'ข้อมูลหน่วยงานเดิม ระดับ', \`positionNumberOld\` varchar(255) NULL COMMENT 'ข้อมูลหน่วยงานเดิม เลขที่', \`amountOld\` double NULL COMMENT 'ข้อมูลหน่วยงานเดิม เงินเดือน', \`profileId\` varchar(255) NULL COMMENT 'profile Id', \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'นามสกุล', \`citizenId\` varchar(255) NULL COMMENT 'เลขบัตรประชาชน', \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน root', \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน root', \`rootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน root', \`child1\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child1', \`child1Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child1', \`child1ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child1', \`child2\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child2', \`child2Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child2', \`child2ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child2', \`child3\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child3', \`child3Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child3', \`child3ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child3', \`child4\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child4', \`child4Id\` varchar(255) NULL COMMENT 'id หน่วยงาน child4', \`child4ShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child4', \`node\` int NULL COMMENT 'ระดับโครงสร้าง', \`nodeId\` varchar(255) NULL COMMENT 'id โครงสร้าง', \`posmasterId\` varchar(255) NULL COMMENT 'id อัตรากำลัง', \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision', \`positionId\` varchar(255) NULL COMMENT 'id ตำแหน่ง', \`positionField\` varchar(255) NULL COMMENT 'สายงาน', \`posMasterNo\` int NULL COMMENT 'เลขที่ตำแหน่ง', \`position\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน', \`posTypeId\` varchar(255) NULL COMMENT 'id ประเภทตำแหน่ง', \`posTypeName\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง', \`posLevelId\` varchar(255) NULL COMMENT 'id ระดับตำแหน่ง', \`posLevelName\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง', \`rootOld\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน root old', \`rootOldId\` varchar(255) NULL COMMENT 'id หน่วยงาน root old', \`rootShortNameOld\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน root old', \`child1Old\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child1 old', \`child1OldId\` varchar(255) NULL COMMENT 'id หน่วยงาน child1 old', \`child1ShortNameOld\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child1 old', \`child2Old\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child2 old', \`child2OldId\` varchar(255) NULL COMMENT 'id หน่วยงาน child2 old', \`child2ShortNameOld\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child2 old', \`child3Old\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child3 old', \`child3OldId\` varchar(255) NULL COMMENT 'id หน่วยงาน child3 old', \`child3ShortNameOld\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child3 old', \`child4Old\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน child4 old', \`child4OldId\` varchar(255) NULL COMMENT 'id หน่วยงาน child4 old', \`child4ShortNameOld\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน child4 old', \`posMasterNoOld\` int NULL COMMENT 'เลขที่ตำแหน่ง old', \`posTypeOldId\` varchar(255) NULL COMMENT 'id ประเภทตำแหน่ง old', \`posTypeNameOld\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง old', \`posLevelOldId\` varchar(255) NULL COMMENT 'id ระดับตำแหน่ง old', \`posLevelNameOld\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง old', \`changePositionId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ChangePosition', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`profileChangePosition\` ADD CONSTRAINT \`FK_91b13ee34e6af4bee74771d17e8\` FOREIGN KEY (\`changePositionId\`) REFERENCES \`changePosition\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileChangePosition\` DROP FOREIGN KEY \`FK_91b13ee34e6af4bee74771d17e8\``); + await queryRunner.query(`DROP TABLE \`profileChangePosition\``); + await queryRunner.query(`DROP TABLE \`changePosition\``); + } + +} From 87047b383dc395d4be43c1edf0d8c9b658216ac3 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 11 Jun 2024 16:24:10 +0700 Subject: [PATCH 5/5] no message --- src/entities/ChangePosition.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/entities/ChangePosition.ts b/src/entities/ChangePosition.ts index 428ba1c5..907ef018 100644 --- a/src/entities/ChangePosition.ts +++ b/src/entities/ChangePosition.ts @@ -20,6 +20,14 @@ export class ChangePosition extends EntityBase { }) date: Date; + @Column({ + nullable: true, + comment: "สถานะ", + type: "text", + default: null, + }) + status: string; + @OneToMany(() => ProfileChangePosition, (x) => x.profile) profileChangePosition: ProfileChangePosition[]; }