diff --git a/src/controllers/DistrictController.ts b/src/controllers/DistrictController.ts index 5966c185..778cc249 100644 --- a/src/controllers/DistrictController.ts +++ b/src/controllers/DistrictController.ts @@ -18,6 +18,7 @@ import HttpSuccess from "../interfaces/http-success"; import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { District, CreateDistrict, UpdateDistrict } from "../entities/District"; +import { Province } from "../entities/Province"; import { Not } from "typeorm"; @Route("api/v1/org/metadata/district") @@ -30,6 +31,7 @@ import { Not } from "typeorm"; @SuccessResponse(HttpStatusCode.OK, "สำเร็จ") export class DistrictController extends Controller { private districtRepository = AppDataSource.getRepository(District); + private provinceRepository = AppDataSource.getRepository(Province); /** * API list รายการเขต @@ -84,6 +86,13 @@ export class DistrictController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเขตนี้"); } + const chkProvince = await this.provinceRepository.findOne({ + where: { id: requestBody.provinceId } + }) + if(!chkProvince){ + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางจังหวัดนี้"); + } + const checkName = await this.districtRepository.findOne({ where: { name: requestBody.name }, }); @@ -118,6 +127,14 @@ export class DistrictController extends Controller { if (!_district) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเขตนี้"); } + + const chkProvince = await this.provinceRepository.findOne({ + where: { id: requestBody.provinceId } + }) + if(!chkProvince){ + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางจังหวัดนี้"); + } + const checkName = await this.districtRepository.findOne({ where: { id: Not(id), name: requestBody.name }, }); diff --git a/src/controllers/ProfileChildrenController.ts b/src/controllers/ProfileChildrenController.ts new file mode 100644 index 00000000..32c0be05 --- /dev/null +++ b/src/controllers/ProfileChildrenController.ts @@ -0,0 +1,117 @@ +import { + Body, + Controller, + Delete, + Example, + Get, + Patch, + Path, + Post, + Request, + Route, + Security, + Tags, +} from "tsoa"; +import { AppDataSource } from "../database/data-source"; +import HttpSuccess from "../interfaces/http-success"; +import HttpStatus from "../interfaces/http-status"; +import HttpError from "../interfaces/http-error"; +import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory"; +import { RequestWithUser } from "../middlewares/user"; +import { Profile } from "../entities/Profile"; +import { + CreateProfileChildren, + ProfileChildren, + UpdateProfileChildren, +} from "../entities/ProfileChildren"; + +@Route("api/v1/org/profile/children") +@Tags("ProfileChildren") +@Security("bearerAuth") +export class ProfileChildrenController extends Controller { + private profileRepository = AppDataSource.getRepository(Profile); + private childrenRepository = AppDataSource.getRepository(ProfileChildren); + private childrenHistoryRepository = AppDataSource.getRepository(ProfileChildrenHistory); + + @Get("{profileId}") + public async getChildren(@Path() profileId: string) { + const lists = await this.childrenRepository.find({ + where: { profileId: profileId }, + }); + return new HttpSuccess(lists); + } + + @Get("history/{childrenId}") + public async childrenHistory(@Path() childrenId: string) { + const record = await this.childrenHistoryRepository.find({ + where: { profileChildrenId: childrenId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + + @Post() + public async newChildren(@Request() req: RequestWithUser, @Body() body: CreateProfileChildren) { + const profile = await this.profileRepository.findOneBy({ id: body.profileId }); + + if (!profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + + const data = new ProfileChildren(); + + const meta = { + createdUserId: req.user.sub, + createdFullName: req.user.name, + lastUpdateUserId: req.user.sub, + lastUpdateFullName: req.user.name, + }; + + Object.assign(data, { ...body, ...meta }); + + await this.childrenRepository.save(data); + + return new HttpSuccess(); + } + + @Patch("{childrenId}") + public async editChildren( + @Request() req: RequestWithUser, + @Body() body: UpdateProfileChildren, + @Path() childrenId: string, + ) { + const record = await this.childrenRepository.findOneBy({ id: childrenId }); + + if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + const history = new ProfileChildrenHistory(); + + Object.assign(history, { ...record, id: undefined }); + Object.assign(record, body); + history.profileChildrenId = childrenId; + record.lastUpdateFullName = req.user.name; + history.lastUpdateFullName = req.user.name; + + await Promise.all([ + this.childrenRepository.save(record), + this.childrenHistoryRepository.save(history), + ]); + + return new HttpSuccess(); + } + + @Delete("{childrenId}") + public async deleteTraning(@Path() childrenId: string) { + await this.childrenHistoryRepository.delete({ + profileChildrenId: childrenId, + }); + + const result = await this.childrenRepository.delete({ id: childrenId }); + + if (result.affected && result.affected <= 0) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + + return new HttpSuccess(); + } +} diff --git a/src/controllers/ProfileChildrenEmployeeController.ts b/src/controllers/ProfileChildrenEmployeeController.ts new file mode 100644 index 00000000..bb71274a --- /dev/null +++ b/src/controllers/ProfileChildrenEmployeeController.ts @@ -0,0 +1,122 @@ +import { + Body, + Controller, + Delete, + Example, + Get, + Patch, + Path, + Post, + Request, + Route, + Security, + Tags, +} from "tsoa"; +import { AppDataSource } from "../database/data-source"; +import HttpSuccess from "../interfaces/http-success"; +import HttpStatus from "../interfaces/http-status"; +import HttpError from "../interfaces/http-error"; +import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory"; +import { RequestWithUser } from "../middlewares/user"; +import { Profile } from "../entities/Profile"; +import { + CreateProfileChildren, + CreateProfileChildrenEmployee, + ProfileChildren, + UpdateProfileChildren, +} from "../entities/ProfileChildren"; +import { ProfileEmployee } from "../entities/ProfileEmployee"; + +@Route("api/v1/org/profile-employee/children") +@Tags("ProfileChildren") +@Security("bearerAuth") +export class ProfileChildrenEmployeeController extends Controller { + private profileRepository = AppDataSource.getRepository(ProfileEmployee); + private childrenRepository = AppDataSource.getRepository(ProfileChildren); + private childrenHistoryRepository = AppDataSource.getRepository(ProfileChildrenHistory); + + @Get("{profileId}") + public async getChildren(@Path() profileId: string) { + const lists = await this.childrenRepository.find({ + where: { profileEmployeeId: profileId }, + }); + return new HttpSuccess(lists); + } + + @Get("history/{childrenId}") + public async childrenHistory(@Path() childrenId: string) { + const record = await this.childrenHistoryRepository.find({ + where: { profileChildrenId: childrenId }, + order: { createdAt: "DESC" }, + }); + return new HttpSuccess(record); + } + + @Post() + public async newChildren( + @Request() req: RequestWithUser, + @Body() body: CreateProfileChildrenEmployee, + ) { + const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId }); + + if (!profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + + const data = new ProfileChildren(); + + const meta = { + createdUserId: req.user.sub, + createdFullName: req.user.name, + lastUpdateUserId: req.user.sub, + lastUpdateFullName: req.user.name, + }; + + Object.assign(data, { ...body, ...meta }); + + await this.childrenRepository.save(data); + + return new HttpSuccess(); + } + + @Patch("{childrenId}") + public async editChildren( + @Request() req: RequestWithUser, + @Body() body: UpdateProfileChildren, + @Path() childrenId: string, + ) { + const record = await this.childrenRepository.findOneBy({ id: childrenId }); + + if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + + const history = new ProfileChildrenHistory(); + + Object.assign(history, { ...record, id: undefined }); + Object.assign(record, body); + history.profileChildrenId = childrenId; + record.lastUpdateFullName = req.user.name; + history.lastUpdateFullName = req.user.name; + + await Promise.all([ + this.childrenRepository.save(record), + this.childrenHistoryRepository.save(history), + ]); + + return new HttpSuccess(); + } + + @Delete("{childrenId}") + public async deleteTraning(@Path() childrenId: string) { + await this.childrenHistoryRepository.delete({ + profileChildrenId: childrenId, + }); + + const result = await this.childrenRepository.delete({ id: childrenId }); + + if (result.affected && result.affected <= 0) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + + return new HttpSuccess(); + } +} diff --git a/src/controllers/ProfileFamilyHistoryController.ts b/src/controllers/ProfileFamilyHistoryController.ts index 29424f1f..6d696560 100644 --- a/src/controllers/ProfileFamilyHistoryController.ts +++ b/src/controllers/ProfileFamilyHistoryController.ts @@ -16,8 +16,6 @@ import { AppDataSource } from "../database/data-source"; import { CreateChildren, CreateProfileFamily, - ProfileChildren, - ProfileChildrenHistory, ProfileFamilyHistory, UpdateProfileFamily, } from "../entities/ProfileFamily"; @@ -26,6 +24,8 @@ import HttpStatus from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { RequestWithUser } from "../middlewares/user"; import { Profile } from "../entities/Profile"; +import { ProfileChildren } from "../entities/ProfileChildren"; +import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory"; @Route("api/v1/org/profile/family") @Tags("ProfileFamilyHistory") @@ -228,7 +228,7 @@ export class ProfileFamilyHistoryController extends Controller { ...v, children: await this.childrenHistoryRepo.find({ order: { createdAt: "ASC" }, - where: { profileFamilyHistoryId: v.id }, + // where: { profileFamilyHistoryId: v.id }, }), })), ); @@ -340,7 +340,7 @@ export class ProfileFamilyHistoryController extends Controller { return await this.childrenHistoryRepo.save( this.childrenHistoryRepo.create({ ...v, - profileFamilyHistoryId: familyRecord.id, + // profileFamilyHistoryId: familyRecord.id, profileChildrenId: v.id, id: undefined, }), diff --git a/src/controllers/ProfileFamilyHistoryEmployeeController.ts b/src/controllers/ProfileFamilyHistoryEmployeeController.ts index 98c1f0b3..ce34730d 100644 --- a/src/controllers/ProfileFamilyHistoryEmployeeController.ts +++ b/src/controllers/ProfileFamilyHistoryEmployeeController.ts @@ -15,10 +15,7 @@ import { import { AppDataSource } from "../database/data-source"; import { CreateChildren, - CreateProfileFamily, CreateProfileFamilyEmployee, - ProfileChildren, - ProfileChildrenHistory, ProfileFamilyHistory, UpdateProfileFamily, } from "../entities/ProfileFamily"; @@ -26,8 +23,9 @@ import HttpSuccess from "../interfaces/http-success"; import HttpStatus from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { RequestWithUser } from "../middlewares/user"; -import { Profile } from "../entities/Profile"; import { ProfileEmployee } from "../entities/ProfileEmployee"; +import { ProfileChildren } from "../entities/ProfileChildren"; +import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory"; @Route("api/v1/org/profile-employee/family") @Tags("ProfileFamilyHistoryEmployee") @@ -230,7 +228,7 @@ export class ProfileFamilyHistoryEmployeeController extends Controller { ...v, children: await this.childrenHistoryRepo.find({ order: { createdAt: "ASC" }, - where: { profileFamilyHistoryId: v.id }, + // where: { profileFamilyHistoryId: v.id }, }), })), ); @@ -342,7 +340,7 @@ export class ProfileFamilyHistoryEmployeeController extends Controller { return await this.childrenHistoryRepo.save( this.childrenHistoryRepo.create({ ...v, - profileFamilyHistoryId: familyRecord.id, + // profileFamilyHistoryId: familyRecord.id, profileChildrenId: v.id, id: undefined, }), @@ -361,7 +359,7 @@ export class ProfileFamilyHistoryEmployeeController extends Controller { if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } - + return new HttpSuccess(); } } diff --git a/src/controllers/SubDistrictController.ts b/src/controllers/SubDistrictController.ts index ced1e659..3ea667c8 100644 --- a/src/controllers/SubDistrictController.ts +++ b/src/controllers/SubDistrictController.ts @@ -18,6 +18,7 @@ import HttpSuccess from "../interfaces/http-success"; import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { SubDistrict, CreateSubDistrict, UpdateSubDistrict } from "../entities/SubDistrict"; +import { District } from "../entities/District"; import { Not } from "typeorm"; @Route("api/v1/org/metadata/subDistrict") @@ -30,11 +31,12 @@ import { Not } from "typeorm"; @SuccessResponse(HttpStatusCode.OK, "สำเร็จ") export class SubDistrictController extends Controller { private subDistrictRepository = AppDataSource.getRepository(SubDistrict); + private districtRepository = AppDataSource.getRepository(District); /** - * API list รายการเพศ + * API list รายการแขวง * - * @summary ORG_058 - CRUD เพศ (ADMIN) #62 + * @summary ORG_058 - CRUD แขวง (ADMIN) #62 * */ @Get() @@ -47,11 +49,11 @@ export class SubDistrictController extends Controller { } /** - * API รายละเอียดรายการเพศ + * API รายละเอียดรายการแขวง * - * @summary ORG_058 - CRUD เพศ (ADMIN) #62 + * @summary ORG_058 - CRUD แขวง (ADMIN) #62 * - * @param {string} id Id เพศ + * @param {string} id Id แขวง */ @Get("{id}") async GetById(@Path() id: string) { @@ -60,16 +62,16 @@ export class SubDistrictController extends Controller { select: ["id", "name"], }); if (!_subDistrict) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางแขวงนี้"); } return new HttpSuccess(_subDistrict); } /** - * API สร้างรายการ body เพศ + * API สร้างรายการ body แขวง * - * @summary ORG_058 - CRUD เพศ (ADMIN) #62 + * @summary ORG_058 - CRUD แขวง (ADMIN) #62 * */ @Post() @@ -80,11 +82,21 @@ export class SubDistrictController extends Controller { ) { const _subDistrict = Object.assign(new SubDistrict(), requestBody); if (!_subDistrict) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางแขวงนี้"); + } + + const chkDistrict = await this.districtRepository.findOne({ + where: { id: requestBody.districtId } + }) + if (!chkDistrict) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเขตนี้"); } const checkName = await this.subDistrictRepository.findOne({ - where: { name: requestBody.name }, + where: { + name: requestBody.name, + districtId: requestBody.districtId + }, }); if (checkName) { @@ -100,11 +112,11 @@ export class SubDistrictController extends Controller { } /** - * API แก้ไขรายการ body เพศ + * API แก้ไขรายการ body แขวง * - * @summary ORG_058 - CRUD เพศ (ADMIN) #62 + * @summary ORG_058 - CRUD แขวง (ADMIN) #62 * - * @param {string} id Id เพศ + * @param {string} id Id แขวง */ @Put("{id}") async Put( @@ -115,10 +127,22 @@ export class SubDistrictController extends Controller { ) { const _subDistrict = await this.subDistrictRepository.findOne({ where: { id: id } }); if (!_subDistrict) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางแขวงนี้"); } + + const chkDistrict = await this.districtRepository.findOne({ + where: { id: requestBody.districtId } + }) + if (!chkDistrict) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเขตนี้"); + } + const checkName = await this.subDistrictRepository.findOne({ - where: { id: Not(id), name: requestBody.name }, + where: { + id: Not(id), + name: requestBody.name, + districtId: requestBody.districtId + }, }); if (checkName) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); @@ -132,11 +156,11 @@ export class SubDistrictController extends Controller { } /** - * API ลบรายการเพศ + * API ลบรายการแขวง * - * @summary ORG_058 - CRUD เพศ (ADMIN) #62 + * @summary ORG_058 - CRUD แขวง (ADMIN) #62 * - * @param {string} id Id เพศ + * @param {string} id Id แขวง */ @Delete("{id}") async Delete(@Path() id: string) { @@ -144,7 +168,7 @@ export class SubDistrictController extends Controller { where: { id: id }, }); if (!_delSubDistrict) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางแขวงนี้"); } await this.subDistrictRepository.delete(_delSubDistrict.id); return new HttpSuccess(); diff --git a/src/entities/District.ts b/src/entities/District.ts index f6c1b639..61e292cc 100644 --- a/src/entities/District.ts +++ b/src/entities/District.ts @@ -36,6 +36,9 @@ export class District extends EntityBase { export class CreateDistrict { @Column() name: string; + + @Column() + provinceId: string; } export type UpdateDistrict = Partial; diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index 28e0763d..e5ab9173 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -15,12 +15,16 @@ import { ProfileAbility } from "./ProfileAbility"; import { ProfileDuty } from "./ProfileDuty"; import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileOther } from "./ProfileOther"; -import { ProfileChildren, ProfileFamilyHistory } from "./ProfileFamily"; +import { ProfileFamilyHistory } from "./ProfileFamily"; import { ProfileGovernment } from "./ProfileGovernment"; import { Province } from "./Province"; import { SubDistrict } from "./SubDistrict"; import { District } from "./District"; import { ProfileAvatar } from "./ProfileAvatar"; +import { ProfileFamilyFather } from "./ProfileFamilyFather"; +import { ProfileFamilyMother } from "./ProfileFamilyMother"; +import { ProfileFamilyCouple } from "./ProfileFamilyCouple"; +import { ProfileChildren } from "./ProfileChildren"; import { ProfileDiscipline } from "./ProfileDiscipline"; @Entity("profile") @@ -150,7 +154,7 @@ export class Profile extends EntityBase { @Column({ nullable: true, type: "datetime", - comment: "วันที่พักราชการ", + comment: "วันครบเกษียณอายุ", default: null, }) dateRetire: Date; @@ -163,6 +167,14 @@ export class Profile extends EntityBase { }) dateAppoint: Date; + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่เกษียณอายุราชการตามกฏหมาย", + default: null, + }) + dateRetireLaw: Date; + @Column({ nullable: true, type: "datetime", @@ -309,7 +321,7 @@ export class Profile extends EntityBase { profileFamily: ProfileFamilyHistory[]; @OneToMany(() => ProfileChildren, (profileChildren) => profileChildren.profile) - profileChildren: ProfileChildren[]; + profileChildrens: ProfileChildren[]; @OneToMany(() => ProfileGovernment, (profileGovernment) => profileGovernment.profile) profileGovernment: ProfileGovernment[]; @@ -317,6 +329,15 @@ export class Profile extends EntityBase { @OneToMany(() => ProfileHistory, (v) => v.profile) histories: ProfileHistory[]; + @OneToMany(() => ProfileFamilyFather, (v) => v.profile) + profileFamilyFather: ProfileFamilyFather[]; + + @OneToMany(() => ProfileFamilyMother, (v) => v.profile) + profileFamilyMother: ProfileFamilyMother[]; + + @OneToMany(() => ProfileFamilyCouple, (v) => v.profile) + profileFamilyCouple: ProfileFamilyCouple[]; + @ManyToOne(() => PosLevel, (posLevel) => posLevel.profiles) @JoinColumn({ name: "posLevelId" }) posLevel: PosLevel; diff --git a/src/entities/ProfileChildren.ts b/src/entities/ProfileChildren.ts new file mode 100644 index 00000000..4e3c929b --- /dev/null +++ b/src/entities/ProfileChildren.ts @@ -0,0 +1,112 @@ +import { Column, Entity, ManyToOne, OneToMany, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; +import { ProfileEmployee } from "./ProfileEmployee"; +import { ProfileChildrenHistory } from "./ProfileChildrenHistory"; + +@Entity("profileChildren") +export class ProfileChildren extends EntityBase { + @Column({ + nullable: true, + default: null, + comment: "อาชีพบุตร", + }) + childrenCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อบุตร", + }) + childrenFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลบุตร", + }) + childrenLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าบุตร", + }) + childrenPrefix: string; + + @Column({ + nullable: true, + default: null, + type: "boolean", + comment: "มีชีวิตบุตร", + }) + childrenLive: boolean; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนบุตร", + }) + childrenCitizenId: string; + + @Column({ + nullable: true, + length: 40, + type: "uuid", + comment: "คีย์นอก(FK) ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + + @ManyToOne(() => Profile, (Profile) => Profile.profileChildrens) + @JoinColumn({ name: "profileId" }) + profile: Profile; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileChildrens) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; + + @OneToMany( + () => ProfileChildrenHistory, + (profileChildrenHistory) => profileChildrenHistory.histories, + ) + profileChildrenHistories: ProfileChildrenHistory[]; +} + +export type CreateProfileChildren = { + profileId: string; + childrenCareer: string; + childrenFirstName: string; + childrenLastName: string; + childrenPrefix: string; + childrenLive: boolean; + childrenCitizenId: string; +}; + +export type CreateProfileChildrenEmployee = { + profileEmployeeId: string; + childrenCareer: string; + childrenFirstName: string; + childrenLastName: string; + childrenPrefix: string; + childrenLive: boolean; + childrenCitizenId: string; +}; + +export type UpdateProfileChildren = { + id: string; + childrenCareer?: string | null; + childrenFirstName?: string | null; + childrenLastName?: string | null; + childrenPrefix?: string | null; + childrenLive?: boolean | null; + childrenCitizenId?: string | null; +}; diff --git a/src/entities/ProfileChildrenHistory.ts b/src/entities/ProfileChildrenHistory.ts new file mode 100644 index 00000000..3c2dae6e --- /dev/null +++ b/src/entities/ProfileChildrenHistory.ts @@ -0,0 +1,155 @@ +import { Column, Entity, ManyToOne, OneToMany, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; +import { ProfileEmployee } from "./ProfileEmployee"; +import { ProfileChildren } from "./ProfileChildren"; + +@Entity("profileChildrenHistory") +export class ProfileChildrenHistory extends EntityBase { + @Column({ + nullable: true, + default: null, + comment: "อาชีพบุตร", + }) + childrenCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อบุตร", + }) + childrenFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลบุตร", + }) + childrenLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าบุตร", + }) + childrenPrefix: string; + + @Column({ + nullable: true, + default: null, + type: "boolean", + comment: "มีชีวิตบุตร", + }) + childrenLive: boolean; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนบุตร", + }) + childrenCitizenId: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileChildren", + default: null, + }) + profileChildrenId: string; + + @ManyToOne(() => ProfileChildren, (profileChildren) => profileChildren.profileChildrenHistories) + @JoinColumn({ name: "profileChildrenId" }) + histories: ProfileChildren; +} + +export type CreateChildren = { + childrenCareer: string; + childrenFirstName: string; + childrenLastName: string; + childrenPrefix: string; + childrenLive: boolean; + childrenCitizenId: string; +}; + +export type UpdateChildren = { + id: string; + childrenCareer?: string | null; + childrenFirstName?: string | null; + childrenLastName?: string | null; + childrenPrefix?: string | null; + childrenLive?: boolean | null; + childrenCitizenId?: string | null; +}; + +export type CreateProfileFamily = { + couple: boolean | null; + couplePrefix: string | null; + coupleFirstName: string | null; + coupleLastName: string | null; + coupleLastNameOld: string | null; + coupleCareer: string | null; + coupleCitizenId: string | null; + coupleLive: boolean | null; + fatherPrefix: string | null; + fatherFirstName: string | null; + fatherLastName: string | null; + fatherCareer: string | null; + fatherCitizenId: string | null; + fatherLive: boolean | null; + motherPrefix: string | null; + motherFirstName: string | null; + motherLastName: string | null; + motherCareer: string | null; + motherCitizenId: string | null; + motherLive: boolean | null; + profileId: string; + children: CreateChildren[]; +}; +export type CreateProfileFamilyEmployee = { + couple: boolean | null; + couplePrefix: string | null; + coupleFirstName: string | null; + coupleLastName: string | null; + coupleLastNameOld: string | null; + coupleCareer: string | null; + coupleCitizenId: string | null; + coupleLive: boolean | null; + fatherPrefix: string | null; + fatherFirstName: string | null; + fatherLastName: string | null; + fatherCareer: string | null; + fatherCitizenId: string | null; + fatherLive: boolean | null; + motherPrefix: string | null; + motherFirstName: string | null; + motherLastName: string | null; + motherCareer: string | null; + motherCitizenId: string | null; + motherLive: boolean | null; + profileEmployeeId: string | null; + children: CreateChildren[]; +}; + +export type UpdateProfileFamily = { + couple?: boolean | null; + couplePrefix?: string | null; + coupleFirstName?: string | null; + coupleLastName?: string | null; + coupleLastNameOld?: string | null; + coupleCareer?: string | null; + coupleCitizenId?: string | null; + coupleLive?: boolean | null; + fatherPrefix?: string | null; + fatherFirstName?: string | null; + fatherLastName?: string | null; + fatherCareer?: string | null; + fatherCitizenId?: string | null; + fatherLive?: boolean | null; + motherPrefix?: string | null; + motherFirstName?: string | null; + motherLastName?: string | null; + motherCareer?: string | null; + motherCitizenId?: string | null; + motherLive?: boolean | null; + children: UpdateChildren[]; +}; diff --git a/src/entities/ProfileEmployee.ts b/src/entities/ProfileEmployee.ts index db38a05c..6d0e334a 100644 --- a/src/entities/ProfileEmployee.ts +++ b/src/entities/ProfileEmployee.ts @@ -14,12 +14,17 @@ import { ProfileDuty } from "./ProfileDuty"; import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileDiscipline } from "./ProfileDiscipline"; import { ProfileChangeName } from "./ProfileChangeName"; -import { ProfileChildren, ProfileFamilyHistory } from "./ProfileFamily"; +import { ProfileFamilyHistory } from "./ProfileFamily"; import { ProfileEducation } from "./ProfileEducation"; import { ProfileAbility } from "./ProfileAbility"; import { ProfileOther } from "./ProfileOther"; import { ProfileAvatar } from "./ProfileAvatar"; import { ProfileGovernment } from "./ProfileGovernment"; +import { ProfileFamilyFather } from "./ProfileFamilyFather"; +import { ProfileFamilyMother } from "./ProfileFamilyMother"; +import { ProfileFamilyCouple } from "./ProfileFamilyCouple"; + +import { ProfileChildren } from "./ProfileChildren"; @Entity("profileEmployee") export class ProfileEmployee extends EntityBase { @Column({ @@ -130,7 +135,7 @@ export class ProfileEmployee extends EntityBase { @Column({ nullable: true, type: "datetime", - comment: "วันที่พักราชการ", + comment: "วันครบเกษียณอายุ", default: null, }) dateRetire: Date; @@ -143,6 +148,14 @@ export class ProfileEmployee extends EntityBase { }) birthDate: Date; + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่เกษียณอายุราชการตามกฏหมาย", + default: null, + }) + dateRetireLaw: Date; + @Column({ type: "double", nullable: true, @@ -274,6 +287,15 @@ export class ProfileEmployee extends EntityBase { @OneToMany(() => ProfileGovernment, (v) => v.profileEmployee) profileGovernment: ProfileGovernment[]; + + @OneToMany(() => ProfileFamilyFather, (v) => v.profile) + profileFamilyFather: ProfileFamilyFather[]; + + @OneToMany(() => ProfileFamilyMother, (v) => v.profile) + profileFamilyMother: ProfileFamilyMother[]; + + @OneToMany(() => ProfileFamilyCouple, (v) => v.profile) + profileFamilyCouple: ProfileFamilyCouple[]; } @Entity("profileEmployeeHistory") @@ -295,22 +317,22 @@ export class CreateProfileEmployee { prefix: string; firstName: string; lastName: string; - position: string; - isProbation: boolean | null; - dateRetire: Date | null; + // position: string; + // isProbation: boolean | null; + // dateRetire: Date | null; birthDate: Date | null; salaryLevel: number | null; - ethnicity: string | null; - telephoneNumber: string | null; + // ethnicity: string | null; + // telephoneNumber: string | null; citizenId: string; - religion: string | null; + // religion: string | null; posLevelId: string | null; posTypeId: string | null; - gender: string | null; - relationship: string | null; - bloodGroup: string | null; - email: string | null; - phone: string | null; + // gender: string | null; + // relationship: string | null; + // bloodGroup: string | null; + // email: string | null; + // phone: string | null; } export type UpdateProfileEmployee = { @@ -318,9 +340,9 @@ export type UpdateProfileEmployee = { prefix?: string | null; firstName?: string | null; lastName?: string | null; - position?: string | null; - isProbation?: boolean | null; - dateRetire?: Date | null; + // position?: string | null; + // isProbation?: boolean | null; + // dateRetire?: Date | null; birthDate?: Date | null; salaryLevel?: number | null; ethnicity?: string | null; diff --git a/src/entities/ProfileFamily.ts b/src/entities/ProfileFamily.ts index eceef17d..baee34ff 100644 --- a/src/entities/ProfileFamily.ts +++ b/src/entities/ProfileFamily.ts @@ -167,114 +167,11 @@ export class ProfileFamilyHistory extends EntityBase { @ManyToOne(() => Profile, (v) => v.profileFamily) profile: Profile; - @OneToMany(() => ProfileChildrenHistory, (v) => v.profileFamilyHistory) - profileChildrenHistories: ProfileChildrenHistory[]; - @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileFamilys) @JoinColumn({ name: "profileEmployeeId" }) profileEmployee: ProfileEmployee; } -@Entity("profileChildren") -export class ProfileChildren extends EntityBase { - @Column({ - nullable: true, - default: null, - comment: "อาชีพบุตร", - }) - childrenCareer: string; - - @Column({ - nullable: true, - default: null, - comment: "ชื่อบุตร", - }) - childrenFirstName: string; - - @Column({ - nullable: true, - default: null, - comment: "นามสกุลบุตร", - }) - childrenLastName: string; - - @Column({ - nullable: true, - default: null, - comment: "คำนำหน้าบุตร", - }) - childrenPrefix: string; - - @Column({ - nullable: true, - default: null, - type: "boolean", - comment: "มีชีวิตบุตร", - }) - childrenLive: boolean; - - @Column({ - nullable: true, - default: null, - comment: "เลขที่บัตรประชาชนบุตร", - }) - childrenCitizenId: string; - - @Column({ - nullable: true, - length: 40, - type: "uuid", - comment: "คีย์นอก(FK) ของตาราง Profile", - default: null, - }) - profileId: string; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", - default: null, - }) - profileEmployeeId: string; - - @ManyToOne(() => Profile, (v) => v.profileFamily, { onDelete: "CASCADE" }) - profile: Profile; - - @OneToMany(() => ProfileChildrenHistory, (v) => v.profileChildren) - histories: Profile; - - @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileChildrens) - @JoinColumn({ name: "profileEmployeeId" }) - profileEmployee: ProfileEmployee; -} - -@Entity("profileChildrenHistory") -export class ProfileChildrenHistory extends ProfileChildren { - @Column({ - nullable: true, - length: 40, - type: "uuid", - comment: "คีย์นอก(FK) ของตาราง Profile", - default: null, - }) - profileFamilyHistoryId: string; - - @ManyToOne(() => ProfileFamilyHistory, (v) => v.profileChildrenHistories, { onDelete: "CASCADE" }) - profileFamilyHistory: ProfileFamilyHistory; - - @Column({ - nullable: true, - length: 40, - type: "uuid", - comment: "คีย์นอก(FK) ของตาราง Profile", - default: null, - }) - profileChildrenId: string; - - @ManyToOne(() => ProfileChildren, (v) => v.histories, { onDelete: "CASCADE" }) - profileChildren: ProfileChildren; -} - export type CreateChildren = { childrenCareer: string; childrenFirstName: string; diff --git a/src/entities/ProfileFamilyCouple.ts b/src/entities/ProfileFamilyCouple.ts new file mode 100644 index 00000000..0157177c --- /dev/null +++ b/src/entities/ProfileFamilyCouple.ts @@ -0,0 +1,145 @@ +import { Column, Entity, ManyToOne, OneToMany, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; +import { ProfileEmployee } from "./ProfileEmployee"; +import { ProfileFamilyCoupleHistory } from "./ProfileFamilyCoupleHistory"; + +@Entity("profileFamilyCouple") +export class ProfileFamilyCouple extends EntityBase { + + @Column({ + nullable: true, + default: null, + type: "boolean", + }) + couple: boolean; + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าคู่สมรส", + }) + couplePrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อคู่สมรส", + }) + coupleFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลคู่สมรส", + }) + coupleLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลคู่สมรส(เดิม)", + }) + coupleLastNameOld: string; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพคู่สมรส", + }) + coupleCareer: string; + + @Column({ + nullable: true, + default: null, + length: 13, + comment: "เลขที่บัตรประชาชนคู่สมรส", + }) + coupleCitizenId: string; + + @Column({ + nullable: true, + default: null, + type: "boolean", + comment: "มีชีวิตคู่สมรส", + }) + coupleLive: boolean; + + @Column({ + nullable: true, + comment: "ความสัมพันธ์", + length: 40, + default: null, + }) + relationship: string; + + @Column({ + nullable: true, + length: 40, + type: "uuid", + comment: "คีย์นอก(FK) ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + + @OneToMany( + () => ProfileFamilyCoupleHistory, + (v) => v.histories, + ) + profileFamilyCouple: ProfileFamilyCoupleHistory[]; + + @ManyToOne(() => Profile, (v) => v.profileFamilyCouple) + @JoinColumn({ name: "profileId" }) + profile: Profile; + + @ManyToOne(() => ProfileEmployee, (v) => v.profileFamilyCouple) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; + +} + +export type CreateProfileFamilyCouple= { + profileId: string; + couple: boolean | null; + couplePrefix: string | null; + coupleFirstName: string | null; + coupleLastName: string | null; + coupleLastNameOld: string | null; + coupleCareer: string | null; + coupleCitizenId: string | null; + coupleLive: boolean | null; + relationship: string | null; +} + +export type CreateProfileEmployeeFamilyCouple= { + profileEmployeeId: string; + couple: boolean | null; + couplePrefix: string | null; + coupleFirstName: string | null; + coupleLastName: string | null; + coupleLastNameOld: string | null; + coupleCareer: string | null; + coupleCitizenId: string | null; + coupleLive: boolean | null; + relationship: string | null; +} + +export type UpdateProfileFamilyCouple = { + couple?: boolean | null; + couplePrefix?: string | null; + coupleFirstName?: string | null; + coupleLastName?: string | null; + coupleLastNameOld?: string | null; + coupleCareer?: string | null; + coupleCitizenId?: string | null; + coupleLive?: boolean | null; + relationship: string | null; +}; diff --git a/src/entities/ProfileFamilyCoupleHistory.ts b/src/entities/ProfileFamilyCoupleHistory.ts new file mode 100644 index 00000000..d831bf3a --- /dev/null +++ b/src/entities/ProfileFamilyCoupleHistory.ts @@ -0,0 +1,60 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { ProfileFamilyCouple } from "./ProfileFamilyCouple"; + +@Entity("profileFamilyCoupleHistory") +export class ProfileFamilyCoupleHistory extends EntityBase { + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าบิดา", + }) + fatherPrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อบิดา", + }) + fatherFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลบิดา", + }) + fatherLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพบิดา", + }) + fatherCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนบิดา", + }) + fatherCitizenId: string; + + @Column({ + nullable: true, + default: null, + comment: "มีชีวิตบิดา", + }) + fatherLive: boolean; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileFamilyFather", + default: null, + }) + profileFamilyCoupleId: string; + + @ManyToOne(() => ProfileFamilyCouple, (v) => v.profileFamilyCouple) + @JoinColumn({ name: "profileFamilyCoupleId" }) + histories: ProfileFamilyCouple; +} diff --git a/src/entities/ProfileFamilyFather.ts b/src/entities/ProfileFamilyFather.ts new file mode 100644 index 00000000..8b56d64e --- /dev/null +++ b/src/entities/ProfileFamilyFather.ts @@ -0,0 +1,112 @@ +import { Column, Entity, ManyToOne, OneToMany, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; +import { ProfileEmployee } from "./ProfileEmployee"; +import { ProfileFamilyFatherHistory } from "./ProfileFamilyFatherHistory"; + +@Entity("profileFamilyFather") +export class ProfileFamilyFather extends EntityBase { + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าบิดา", + }) + fatherPrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อบิดา", + }) + fatherFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลบิดา", + }) + fatherLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพบิดา", + }) + fatherCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนบิดา", + }) + fatherCitizenId: string; + + @Column({ + nullable: true, + default: null, + comment: "มีชีวิตบิดา", + }) + fatherLive: boolean; + + @Column({ + nullable: true, + length: 40, + type: "uuid", + comment: "คีย์นอก(FK) ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + + @OneToMany( + () => ProfileFamilyFatherHistory, + (v) => v.histories, + ) + profileFamilyFather: ProfileFamilyFatherHistory[]; + + @ManyToOne(() => Profile, (v) => v.profileFamilyFather) + @JoinColumn({ name: "profileId" }) + profile: Profile; + + @ManyToOne(() => ProfileEmployee, (v) => v.profileFamilyFather) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; + +} + +export type CreateProfileFamilyFather = { + profileId: string; + fatherPrefix: string | null; + fatherFirstName: string | null; + fatherLastName: string | null; + fatherCareer: string | null; + fatherCitizenId: string | null; + fatherLive: boolean | null; +} + +export type CreateProfileEmployeeFamilyFather = { + profileEmployeeId: string; + fatherPrefix: string | null; + fatherFirstName: string | null; + fatherLastName: string | null; + fatherCareer: string | null; + fatherCitizenId: string | null; + fatherLive: boolean | null; +} + +export type UpdateProfileFamilyFather = { + fatherPrefix?: string | null; + fatherFirstName?: string | null; + fatherLastName?: string | null; + fatherCareer?: string | null; + fatherCitizenId?: string | null; + fatherLive?: boolean | null; +}; diff --git a/src/entities/ProfileFamilyFatherHistory.ts b/src/entities/ProfileFamilyFatherHistory.ts new file mode 100644 index 00000000..dd99f6be --- /dev/null +++ b/src/entities/ProfileFamilyFatherHistory.ts @@ -0,0 +1,60 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { ProfileFamilyFather } from "./ProfileFamilyFather"; + +@Entity("profileFamilyFatherHistory") +export class ProfileFamilyFatherHistory extends EntityBase { + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าบิดา", + }) + fatherPrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อบิดา", + }) + fatherFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลบิดา", + }) + fatherLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพบิดา", + }) + fatherCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนบิดา", + }) + fatherCitizenId: string; + + @Column({ + nullable: true, + default: null, + comment: "มีชีวิตบิดา", + }) + fatherLive: boolean; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileFamilyFather", + default: null, + }) + profileFamilyFatherId: string; + + @ManyToOne(() => ProfileFamilyFather, (v) => v.profileFamilyFather) + @JoinColumn({ name: "profileFamilyFatherId" }) + histories: ProfileFamilyFather; +} diff --git a/src/entities/ProfileFamilyMother.ts b/src/entities/ProfileFamilyMother.ts new file mode 100644 index 00000000..c143237d --- /dev/null +++ b/src/entities/ProfileFamilyMother.ts @@ -0,0 +1,112 @@ +import { Column, Entity, ManyToOne, OneToMany, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; +import { ProfileEmployee } from "./ProfileEmployee"; +import { ProfileFamilyMotherHistory } from "./ProfileFamilyMotherHistory"; + +@Entity("profileFamilyMother") +export class ProfileFamilyMother extends EntityBase { + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้ามารดา", + }) + motherPrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อมารดา", + }) + motherFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลมารดา", + }) + motherLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพบิดา", + }) + motherCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนมารดา", + }) + motherCitizenId: string; + + @Column({ + nullable: true, + default: null, + comment: "มีชีวิตมารดา", + }) + motherLive: boolean; + + @Column({ + nullable: true, + length: 40, + type: "uuid", + comment: "คีย์นอก(FK) ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + + @OneToMany( + () => ProfileFamilyMotherHistory, + (v) => v.histories, + ) + profileFamilyMother: ProfileFamilyMotherHistory[]; + + @ManyToOne(() => Profile, (v) => v.profileFamilyMother) + @JoinColumn({ name: "profileId" }) + profile: Profile; + + @ManyToOne(() => ProfileEmployee, (v) => v.profileFamilyMother) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; + +} + +export type CreateProfileFamilyMother = { + profileId: string; + motherPrefix: string | null; + motherFirstName: string | null; + motherLastName: string | null; + motherCareer: string | null; + motherCitizenId: string | null; + motherLive: boolean | null; +} + +export type CreateProfileEmployeeFamilyMother= { + profileEmployeeId: string; + motherPrefix: string | null; + motherFirstName: string | null; + motherLastName: string | null; + motherCareer: string | null; + motherCitizenId: string | null; + motherLive: boolean | null; +} + +export type UpdateProfileFamilyMother= { + motherPrefix: string | null; + motherFirstName: string | null; + motherLastName: string | null; + motherCareer: string | null; + motherCitizenId: string | null; + motherLive: boolean | null; +}; diff --git a/src/entities/ProfileFamilyMotherHistory.ts b/src/entities/ProfileFamilyMotherHistory.ts new file mode 100644 index 00000000..90fd6a90 --- /dev/null +++ b/src/entities/ProfileFamilyMotherHistory.ts @@ -0,0 +1,61 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { ProfileFamilyMother } from "./ProfileFamilyMother"; + +@Entity("profileFamilyMotherHistory") +export class ProfileFamilyMotherHistory extends EntityBase { + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้ามารดา", + }) + motherPrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อมารดา", + }) + motherFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลมารดา", + }) + motherLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพบิดา", + }) + motherCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนมารดา", + }) + motherCitizenId: string; + + @Column({ + nullable: true, + default: null, + comment: "มีชีวิตมารดา", + }) + motherLive: boolean; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileFamilyMother", + default: null, + }) + profileFamilyMotherId: string; + + @ManyToOne(() => ProfileFamilyMother, (v) => v.profileFamilyMother) + @JoinColumn({ name: "profileFamilyMotherId" }) + histories: ProfileFamilyMother; +} diff --git a/src/entities/SubDistrict.ts b/src/entities/SubDistrict.ts index ae54c6da..8d7a325d 100644 --- a/src/entities/SubDistrict.ts +++ b/src/entities/SubDistrict.ts @@ -40,6 +40,12 @@ export class SubDistrict extends EntityBase { export class CreateSubDistrict { @Column() name: string; + + @Column() + districtId: string; + + @Column() + zipCode: string; } export type UpdateSubDistrict = Partial; diff --git a/src/migration/1715682448384-add_table_ProfileChildren.ts b/src/migration/1715682448384-add_table_ProfileChildren.ts new file mode 100644 index 00000000..fe92e79c --- /dev/null +++ b/src/migration/1715682448384-add_table_ProfileChildren.ts @@ -0,0 +1,36 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableProfileChildren1715682448384 implements MigrationInterface { + name = 'AddTableProfileChildren1715682448384' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP FOREIGN KEY \`FK_a0467be33be13ab1ba0b21acc7a\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP FOREIGN KEY \`FK_b357180653180284b853f0bb18d\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP FOREIGN KEY \`FK_ff56943048f9616e96cd8e3507d\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP FOREIGN KEY \`FK_6a37dfb48ea6108cba60b9d4f69\``); + await queryRunner.query(`ALTER TABLE \`profileChildren\` DROP FOREIGN KEY \`FK_b7de772d753b42334c98536eccb\``); + await queryRunner.query(`DROP INDEX \`FK_f5758428d496b6d2a051c8af92b\` ON \`profileSalary\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP COLUMN \`profileEmployeeId\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP COLUMN \`profileFamilyHistoryId\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP COLUMN \`profileId\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`profileChildrenId\` \`profileChildrenId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileChildren'`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD CONSTRAINT \`FK_ff56943048f9616e96cd8e3507d\` FOREIGN KEY (\`profileChildrenId\`) REFERENCES \`profileChildren\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileChildren\` ADD CONSTRAINT \`FK_b7de772d753b42334c98536eccb\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileChildren\` DROP FOREIGN KEY \`FK_b7de772d753b42334c98536eccb\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` DROP FOREIGN KEY \`FK_ff56943048f9616e96cd8e3507d\``); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`profileChildrenId\` \`profileChildrenId\` varchar(40) NULL COMMENT 'คีย์นอก(FK) ของตาราง Profile'`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK) ของตาราง Profile'`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD \`profileFamilyHistoryId\` varchar(40) NULL COMMENT 'คีย์นอก(FK) ของตาราง Profile'`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`); + await queryRunner.query(`CREATE INDEX \`FK_f5758428d496b6d2a051c8af92b\` ON \`profileSalary\` (\`profileEmployeeId\`)`); + await queryRunner.query(`ALTER TABLE \`profileChildren\` ADD CONSTRAINT \`FK_b7de772d753b42334c98536eccb\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD CONSTRAINT \`FK_6a37dfb48ea6108cba60b9d4f69\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD CONSTRAINT \`FK_ff56943048f9616e96cd8e3507d\` FOREIGN KEY (\`profileChildrenId\`) REFERENCES \`profileChildren\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD CONSTRAINT \`FK_b357180653180284b853f0bb18d\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` ADD CONSTRAINT \`FK_a0467be33be13ab1ba0b21acc7a\` FOREIGN KEY (\`profileFamilyHistoryId\`) REFERENCES \`profileFamilyHistory\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`); + } + +} diff --git a/src/migration/1715683524015-add_table_Profilefather.ts b/src/migration/1715683524015-add_table_Profilefather.ts new file mode 100644 index 00000000..ec9dd16e --- /dev/null +++ b/src/migration/1715683524015-add_table_Profilefather.ts @@ -0,0 +1,42 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableProfilefather1715683524015 implements MigrationInterface { + name = 'AddTableProfilefather1715683524015' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`profileFamilyFatherHistory\` (\`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', \`fatherPrefix\` varchar(255) NULL COMMENT 'คำนำหน้าบิดา', \`fatherFirstName\` varchar(255) NULL COMMENT 'ชื่อบิดา', \`fatherLastName\` varchar(255) NULL COMMENT 'นามสกุลบิดา', \`fatherCareer\` varchar(255) NULL COMMENT 'อาชีพบิดา', \`fatherCitizenId\` varchar(255) NULL COMMENT 'เลขที่บัตรประชาชนบิดา', \`fatherLive\` tinyint NULL COMMENT 'มีชีวิตบิดา', \`profileFamilyFatherId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileFamilyFather', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`profileFamilyFather\` (\`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', \`fatherPrefix\` varchar(255) NULL COMMENT 'คำนำหน้าบิดา', \`fatherFirstName\` varchar(255) NULL COMMENT 'ชื่อบิดา', \`fatherLastName\` varchar(255) NULL COMMENT 'นามสกุลบิดา', \`fatherCareer\` varchar(255) NULL COMMENT 'อาชีพบิดา', \`fatherCitizenId\` varchar(255) NULL COMMENT 'เลขที่บัตรประชาชนบิดา', \`fatherLive\` tinyint NULL COMMENT 'มีชีวิตบิดา', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK) ของตาราง Profile', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`profileFamilyMotherHistory\` (\`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', \`motherPrefix\` varchar(255) NULL COMMENT 'คำนำหน้ามารดา', \`motherFirstName\` varchar(255) NULL COMMENT 'ชื่อมารดา', \`motherLastName\` varchar(255) NULL COMMENT 'นามสกุลมารดา', \`motherCareer\` varchar(255) NULL COMMENT 'อาชีพบิดา', \`motherCitizenId\` varchar(255) NULL COMMENT 'เลขที่บัตรประชาชนมารดา', \`motherLive\` tinyint NULL COMMENT 'มีชีวิตมารดา', \`profileFamilyMotherId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileFamilyMother', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`profileFamilyMother\` (\`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', \`motherPrefix\` varchar(255) NULL COMMENT 'คำนำหน้ามารดา', \`motherFirstName\` varchar(255) NULL COMMENT 'ชื่อมารดา', \`motherLastName\` varchar(255) NULL COMMENT 'นามสกุลมารดา', \`motherCareer\` varchar(255) NULL COMMENT 'อาชีพบิดา', \`motherCitizenId\` varchar(255) NULL COMMENT 'เลขที่บัตรประชาชนมารดา', \`motherLive\` tinyint NULL COMMENT 'มีชีวิตมารดา', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK) ของตาราง Profile', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`profileFamilyCoupleHistory\` (\`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', \`fatherPrefix\` varchar(255) NULL COMMENT 'คำนำหน้าบิดา', \`fatherFirstName\` varchar(255) NULL COMMENT 'ชื่อบิดา', \`fatherLastName\` varchar(255) NULL COMMENT 'นามสกุลบิดา', \`fatherCareer\` varchar(255) NULL COMMENT 'อาชีพบิดา', \`fatherCitizenId\` varchar(255) NULL COMMENT 'เลขที่บัตรประชาชนบิดา', \`fatherLive\` tinyint NULL COMMENT 'มีชีวิตบิดา', \`profileFamilyCoupleId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileFamilyFather', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`profileFamilyCouple\` (\`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', \`couple\` tinyint NULL, \`couplePrefix\` varchar(255) NULL COMMENT 'คำนำหน้าคู่สมรส', \`coupleFirstName\` varchar(255) NULL COMMENT 'ชื่อคู่สมรส', \`coupleLastName\` varchar(255) NULL COMMENT 'นามสกุลคู่สมรส', \`coupleLastNameOld\` varchar(255) NULL COMMENT 'นามสกุลคู่สมรส(เดิม)', \`coupleCareer\` varchar(255) NULL COMMENT 'อาชีพคู่สมรส', \`coupleCitizenId\` varchar(13) NULL COMMENT 'เลขที่บัตรประชาชนคู่สมรส', \`coupleLive\` tinyint NULL COMMENT 'มีชีวิตคู่สมรส', \`relationship\` varchar(40) NULL COMMENT 'ความสัมพันธ์', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK) ของตาราง Profile', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` ADD CONSTRAINT \`FK_6629eded70dc92ea1aeb3e85b9c\` FOREIGN KEY (\`profileFamilyFatherId\`) REFERENCES \`profileFamilyFather\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` ADD CONSTRAINT \`FK_4e6e4398088759257f0d647481b\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` ADD CONSTRAINT \`FK_30aed478da56fc7f14b2716c397\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` ADD CONSTRAINT \`FK_1af4d1673e616bd1af623f32402\` FOREIGN KEY (\`profileFamilyMotherId\`) REFERENCES \`profileFamilyMother\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` ADD CONSTRAINT \`FK_39b3c862fc9822b94a4fe2027b0\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` ADD CONSTRAINT \`FK_b7ecea341cf3c2aa82f78b768ef\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD CONSTRAINT \`FK_849255f4788774b559b7dca8eda\` FOREIGN KEY (\`profileFamilyCoupleId\`) REFERENCES \`profileFamilyCouple\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` ADD CONSTRAINT \`FK_6c6624f4d3f33de4942dd5b6fc5\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` ADD CONSTRAINT \`FK_68a54ba0970de34319338943581\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` DROP FOREIGN KEY \`FK_68a54ba0970de34319338943581\``); + await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` DROP FOREIGN KEY \`FK_6c6624f4d3f33de4942dd5b6fc5\``); + await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP FOREIGN KEY \`FK_849255f4788774b559b7dca8eda\``); + await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` DROP FOREIGN KEY \`FK_b7ecea341cf3c2aa82f78b768ef\``); + await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` DROP FOREIGN KEY \`FK_39b3c862fc9822b94a4fe2027b0\``); + await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` DROP FOREIGN KEY \`FK_1af4d1673e616bd1af623f32402\``); + await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` DROP FOREIGN KEY \`FK_30aed478da56fc7f14b2716c397\``); + await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` DROP FOREIGN KEY \`FK_4e6e4398088759257f0d647481b\``); + await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` DROP FOREIGN KEY \`FK_6629eded70dc92ea1aeb3e85b9c\``); + await queryRunner.query(`DROP TABLE \`profileFamilyCouple\``); + await queryRunner.query(`DROP TABLE \`profileFamilyCoupleHistory\``); + await queryRunner.query(`DROP TABLE \`profileFamilyMother\``); + await queryRunner.query(`DROP TABLE \`profileFamilyMotherHistory\``); + await queryRunner.query(`DROP TABLE \`profileFamilyFather\``); + await queryRunner.query(`DROP TABLE \`profileFamilyFatherHistory\``); + } + +} diff --git a/src/migration/1715683984766-add_table_dateRetire.ts b/src/migration/1715683984766-add_table_dateRetire.ts new file mode 100644 index 00000000..5ddaf272 --- /dev/null +++ b/src/migration/1715683984766-add_table_dateRetire.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableDateRetire1715683984766 implements MigrationInterface { + name = 'AddTableDateRetire1715683984766' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`dateRetireLaw\` datetime NULL COMMENT 'วันที่เกษียณอายุราชการตามกฏหมาย'`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`dateRetireLaw\` datetime NULL COMMENT 'วันที่เกษียณอายุราชการตามกฏหมาย'`); + await queryRunner.query(`ALTER TABLE \`profile\` ADD \`dateRetireLaw\` datetime NULL COMMENT 'วันที่เกษียณอายุราชการตามกฏหมาย'`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`dateRetireLaw\` datetime NULL COMMENT 'วันที่เกษียณอายุราชการตามกฏหมาย'`); + await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`dateRetire\` \`dateRetire\` datetime NULL COMMENT 'วันครบเกษียณอายุ'`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`dateRetire\` \`dateRetire\` datetime NULL COMMENT 'วันครบเกษียณอายุ'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`dateRetire\` \`dateRetire\` datetime NULL COMMENT 'วันที่พักราชการ'`); + await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`dateRetire\` \`dateRetire\` datetime NULL COMMENT 'วันที่พักราชการ'`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`dateRetireLaw\``); + await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`dateRetireLaw\``); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`dateRetireLaw\``); + await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`dateRetireLaw\``); + } + +}