Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-05-15 11:46:31 +07:00
commit a6f575bff3
22 changed files with 1298 additions and 152 deletions

View file

@ -18,6 +18,7 @@ import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status"; import HttpStatusCode from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import { District, CreateDistrict, UpdateDistrict } from "../entities/District"; import { District, CreateDistrict, UpdateDistrict } from "../entities/District";
import { Province } from "../entities/Province";
import { Not } from "typeorm"; import { Not } from "typeorm";
@Route("api/v1/org/metadata/district") @Route("api/v1/org/metadata/district")
@ -30,6 +31,7 @@ import { Not } from "typeorm";
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") @SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
export class DistrictController extends Controller { export class DistrictController extends Controller {
private districtRepository = AppDataSource.getRepository(District); private districtRepository = AppDataSource.getRepository(District);
private provinceRepository = AppDataSource.getRepository(Province);
/** /**
* API list * API list
@ -84,6 +86,13 @@ export class DistrictController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเขตนี้"); 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({ const checkName = await this.districtRepository.findOne({
where: { name: requestBody.name }, where: { name: requestBody.name },
}); });
@ -118,6 +127,14 @@ export class DistrictController extends Controller {
if (!_district) { if (!_district) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเขตนี้"); 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({ const checkName = await this.districtRepository.findOne({
where: { id: Not(id), name: requestBody.name }, where: { id: Not(id), name: requestBody.name },
}); });

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -16,8 +16,6 @@ import { AppDataSource } from "../database/data-source";
import { import {
CreateChildren, CreateChildren,
CreateProfileFamily, CreateProfileFamily,
ProfileChildren,
ProfileChildrenHistory,
ProfileFamilyHistory, ProfileFamilyHistory,
UpdateProfileFamily, UpdateProfileFamily,
} from "../entities/ProfileFamily"; } from "../entities/ProfileFamily";
@ -26,6 +24,8 @@ import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { ProfileChildren } from "../entities/ProfileChildren";
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
@Route("api/v1/org/profile/family") @Route("api/v1/org/profile/family")
@Tags("ProfileFamilyHistory") @Tags("ProfileFamilyHistory")
@ -228,7 +228,7 @@ export class ProfileFamilyHistoryController extends Controller {
...v, ...v,
children: await this.childrenHistoryRepo.find({ children: await this.childrenHistoryRepo.find({
order: { createdAt: "ASC" }, 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( return await this.childrenHistoryRepo.save(
this.childrenHistoryRepo.create({ this.childrenHistoryRepo.create({
...v, ...v,
profileFamilyHistoryId: familyRecord.id, // profileFamilyHistoryId: familyRecord.id,
profileChildrenId: v.id, profileChildrenId: v.id,
id: undefined, id: undefined,
}), }),

View file

@ -15,10 +15,7 @@ import {
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { import {
CreateChildren, CreateChildren,
CreateProfileFamily,
CreateProfileFamilyEmployee, CreateProfileFamilyEmployee,
ProfileChildren,
ProfileChildrenHistory,
ProfileFamilyHistory, ProfileFamilyHistory,
UpdateProfileFamily, UpdateProfileFamily,
} from "../entities/ProfileFamily"; } from "../entities/ProfileFamily";
@ -26,8 +23,9 @@ import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import { ProfileChildren } from "../entities/ProfileChildren";
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
@Route("api/v1/org/profile-employee/family") @Route("api/v1/org/profile-employee/family")
@Tags("ProfileFamilyHistoryEmployee") @Tags("ProfileFamilyHistoryEmployee")
@ -230,7 +228,7 @@ export class ProfileFamilyHistoryEmployeeController extends Controller {
...v, ...v,
children: await this.childrenHistoryRepo.find({ children: await this.childrenHistoryRepo.find({
order: { createdAt: "ASC" }, 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( return await this.childrenHistoryRepo.save(
this.childrenHistoryRepo.create({ this.childrenHistoryRepo.create({
...v, ...v,
profileFamilyHistoryId: familyRecord.id, // profileFamilyHistoryId: familyRecord.id,
profileChildrenId: v.id, profileChildrenId: v.id,
id: undefined, id: undefined,
}), }),

View file

@ -18,6 +18,7 @@ import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status"; import HttpStatusCode from "../interfaces/http-status";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import { SubDistrict, CreateSubDistrict, UpdateSubDistrict } from "../entities/SubDistrict"; import { SubDistrict, CreateSubDistrict, UpdateSubDistrict } from "../entities/SubDistrict";
import { District } from "../entities/District";
import { Not } from "typeorm"; import { Not } from "typeorm";
@Route("api/v1/org/metadata/subDistrict") @Route("api/v1/org/metadata/subDistrict")
@ -30,11 +31,12 @@ import { Not } from "typeorm";
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") @SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
export class SubDistrictController extends Controller { export class SubDistrictController extends Controller {
private subDistrictRepository = AppDataSource.getRepository(SubDistrict); 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() @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}") @Get("{id}")
async GetById(@Path() id: string) { async GetById(@Path() id: string) {
@ -60,16 +62,16 @@ export class SubDistrictController extends Controller {
select: ["id", "name"], select: ["id", "name"],
}); });
if (!_subDistrict) { if (!_subDistrict) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางแขวงนี้");
} }
return new HttpSuccess(_subDistrict); return new HttpSuccess(_subDistrict);
} }
/** /**
* API body * API body
* *
* @summary ORG_058 - CRUD (ADMIN) #62 * @summary ORG_058 - CRUD (ADMIN) #62
* *
*/ */
@Post() @Post()
@ -80,11 +82,21 @@ export class SubDistrictController extends Controller {
) { ) {
const _subDistrict = Object.assign(new SubDistrict(), requestBody); const _subDistrict = Object.assign(new SubDistrict(), requestBody);
if (!_subDistrict) { 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({ const checkName = await this.subDistrictRepository.findOne({
where: { name: requestBody.name }, where: {
name: requestBody.name,
districtId: requestBody.districtId
},
}); });
if (checkName) { 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}") @Put("{id}")
async Put( async Put(
@ -115,10 +127,22 @@ export class SubDistrictController extends Controller {
) { ) {
const _subDistrict = await this.subDistrictRepository.findOne({ where: { id: id } }); const _subDistrict = await this.subDistrictRepository.findOne({ where: { id: id } });
if (!_subDistrict) { 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({ 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) { if (checkName) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); 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}") @Delete("{id}")
async Delete(@Path() id: string) { async Delete(@Path() id: string) {
@ -144,7 +168,7 @@ export class SubDistrictController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (!_delSubDistrict) { if (!_delSubDistrict) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางเพศนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสถานภาพทางแขวงนี้");
} }
await this.subDistrictRepository.delete(_delSubDistrict.id); await this.subDistrictRepository.delete(_delSubDistrict.id);
return new HttpSuccess(); return new HttpSuccess();

View file

@ -36,6 +36,9 @@ export class District extends EntityBase {
export class CreateDistrict { export class CreateDistrict {
@Column() @Column()
name: string; name: string;
@Column()
provinceId: string;
} }
export type UpdateDistrict = Partial<CreateDistrict>; export type UpdateDistrict = Partial<CreateDistrict>;

View file

@ -15,12 +15,16 @@ import { ProfileAbility } from "./ProfileAbility";
import { ProfileDuty } from "./ProfileDuty"; import { ProfileDuty } from "./ProfileDuty";
import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileNopaid } from "./ProfileNopaid";
import { ProfileOther } from "./ProfileOther"; import { ProfileOther } from "./ProfileOther";
import { ProfileChildren, ProfileFamilyHistory } from "./ProfileFamily"; import { ProfileFamilyHistory } from "./ProfileFamily";
import { ProfileGovernment } from "./ProfileGovernment"; import { ProfileGovernment } from "./ProfileGovernment";
import { Province } from "./Province"; import { Province } from "./Province";
import { SubDistrict } from "./SubDistrict"; import { SubDistrict } from "./SubDistrict";
import { District } from "./District"; import { District } from "./District";
import { ProfileAvatar } from "./ProfileAvatar"; import { ProfileAvatar } from "./ProfileAvatar";
import { ProfileFamilyFather } from "./ProfileFamilyFather";
import { ProfileFamilyMother } from "./ProfileFamilyMother";
import { ProfileFamilyCouple } from "./ProfileFamilyCouple";
import { ProfileChildren } from "./ProfileChildren";
import { ProfileDiscipline } from "./ProfileDiscipline"; import { ProfileDiscipline } from "./ProfileDiscipline";
@Entity("profile") @Entity("profile")
@ -150,7 +154,7 @@ export class Profile extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
type: "datetime", type: "datetime",
comment: "วันที่พักราชการ", comment: "วันครบเกษียณอายุ",
default: null, default: null,
}) })
dateRetire: Date; dateRetire: Date;
@ -163,6 +167,14 @@ export class Profile extends EntityBase {
}) })
dateAppoint: Date; dateAppoint: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่เกษียณอายุราชการตามกฏหมาย",
default: null,
})
dateRetireLaw: Date;
@Column({ @Column({
nullable: true, nullable: true,
type: "datetime", type: "datetime",
@ -309,7 +321,7 @@ export class Profile extends EntityBase {
profileFamily: ProfileFamilyHistory[]; profileFamily: ProfileFamilyHistory[];
@OneToMany(() => ProfileChildren, (profileChildren) => profileChildren.profile) @OneToMany(() => ProfileChildren, (profileChildren) => profileChildren.profile)
profileChildren: ProfileChildren[]; profileChildrens: ProfileChildren[];
@OneToMany(() => ProfileGovernment, (profileGovernment) => profileGovernment.profile) @OneToMany(() => ProfileGovernment, (profileGovernment) => profileGovernment.profile)
profileGovernment: ProfileGovernment[]; profileGovernment: ProfileGovernment[];
@ -317,6 +329,15 @@ export class Profile extends EntityBase {
@OneToMany(() => ProfileHistory, (v) => v.profile) @OneToMany(() => ProfileHistory, (v) => v.profile)
histories: ProfileHistory[]; 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) @ManyToOne(() => PosLevel, (posLevel) => posLevel.profiles)
@JoinColumn({ name: "posLevelId" }) @JoinColumn({ name: "posLevelId" })
posLevel: PosLevel; posLevel: PosLevel;

View file

@ -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;
};

View file

@ -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[];
};

View file

@ -14,12 +14,17 @@ import { ProfileDuty } from "./ProfileDuty";
import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileNopaid } from "./ProfileNopaid";
import { ProfileDiscipline } from "./ProfileDiscipline"; import { ProfileDiscipline } from "./ProfileDiscipline";
import { ProfileChangeName } from "./ProfileChangeName"; import { ProfileChangeName } from "./ProfileChangeName";
import { ProfileChildren, ProfileFamilyHistory } from "./ProfileFamily"; import { ProfileFamilyHistory } from "./ProfileFamily";
import { ProfileEducation } from "./ProfileEducation"; import { ProfileEducation } from "./ProfileEducation";
import { ProfileAbility } from "./ProfileAbility"; import { ProfileAbility } from "./ProfileAbility";
import { ProfileOther } from "./ProfileOther"; import { ProfileOther } from "./ProfileOther";
import { ProfileAvatar } from "./ProfileAvatar"; import { ProfileAvatar } from "./ProfileAvatar";
import { ProfileGovernment } from "./ProfileGovernment"; import { ProfileGovernment } from "./ProfileGovernment";
import { ProfileFamilyFather } from "./ProfileFamilyFather";
import { ProfileFamilyMother } from "./ProfileFamilyMother";
import { ProfileFamilyCouple } from "./ProfileFamilyCouple";
import { ProfileChildren } from "./ProfileChildren";
@Entity("profileEmployee") @Entity("profileEmployee")
export class ProfileEmployee extends EntityBase { export class ProfileEmployee extends EntityBase {
@Column({ @Column({
@ -130,7 +135,7 @@ export class ProfileEmployee extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
type: "datetime", type: "datetime",
comment: "วันที่พักราชการ", comment: "วันครบเกษียณอายุ",
default: null, default: null,
}) })
dateRetire: Date; dateRetire: Date;
@ -143,6 +148,14 @@ export class ProfileEmployee extends EntityBase {
}) })
birthDate: Date; birthDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่เกษียณอายุราชการตามกฏหมาย",
default: null,
})
dateRetireLaw: Date;
@Column({ @Column({
type: "double", type: "double",
nullable: true, nullable: true,
@ -274,6 +287,15 @@ export class ProfileEmployee extends EntityBase {
@OneToMany(() => ProfileGovernment, (v) => v.profileEmployee) @OneToMany(() => ProfileGovernment, (v) => v.profileEmployee)
profileGovernment: ProfileGovernment[]; 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") @Entity("profileEmployeeHistory")
@ -295,22 +317,22 @@ export class CreateProfileEmployee {
prefix: string; prefix: string;
firstName: string; firstName: string;
lastName: string; lastName: string;
position: string; // position: string;
isProbation: boolean | null; // isProbation: boolean | null;
dateRetire: Date | null; // dateRetire: Date | null;
birthDate: Date | null; birthDate: Date | null;
salaryLevel: number | null; salaryLevel: number | null;
ethnicity: string | null; // ethnicity: string | null;
telephoneNumber: string | null; // telephoneNumber: string | null;
citizenId: string; citizenId: string;
religion: string | null; // religion: string | null;
posLevelId: string | null; posLevelId: string | null;
posTypeId: string | null; posTypeId: string | null;
gender: string | null; // gender: string | null;
relationship: string | null; // relationship: string | null;
bloodGroup: string | null; // bloodGroup: string | null;
email: string | null; // email: string | null;
phone: string | null; // phone: string | null;
} }
export type UpdateProfileEmployee = { export type UpdateProfileEmployee = {
@ -318,9 +340,9 @@ export type UpdateProfileEmployee = {
prefix?: string | null; prefix?: string | null;
firstName?: string | null; firstName?: string | null;
lastName?: string | null; lastName?: string | null;
position?: string | null; // position?: string | null;
isProbation?: boolean | null; // isProbation?: boolean | null;
dateRetire?: Date | null; // dateRetire?: Date | null;
birthDate?: Date | null; birthDate?: Date | null;
salaryLevel?: number | null; salaryLevel?: number | null;
ethnicity?: string | null; ethnicity?: string | null;

View file

@ -167,114 +167,11 @@ export class ProfileFamilyHistory extends EntityBase {
@ManyToOne(() => Profile, (v) => v.profileFamily) @ManyToOne(() => Profile, (v) => v.profileFamily)
profile: Profile; profile: Profile;
@OneToMany(() => ProfileChildrenHistory, (v) => v.profileFamilyHistory)
profileChildrenHistories: ProfileChildrenHistory[];
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileFamilys) @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileFamilys)
@JoinColumn({ name: "profileEmployeeId" }) @JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee; 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 = { export type CreateChildren = {
childrenCareer: string; childrenCareer: string;
childrenFirstName: string; childrenFirstName: string;

View file

@ -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;
};

View file

@ -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;
}

View file

@ -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;
};

View file

@ -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;
}

View file

@ -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;
};

View file

@ -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;
}

View file

@ -40,6 +40,12 @@ export class SubDistrict extends EntityBase {
export class CreateSubDistrict { export class CreateSubDistrict {
@Column() @Column()
name: string; name: string;
@Column()
districtId: string;
@Column()
zipCode: string;
} }
export type UpdateSubDistrict = Partial<CreateSubDistrict>; export type UpdateSubDistrict = Partial<CreateSubDistrict>;

View file

@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableProfileChildren1715682448384 implements MigrationInterface {
name = 'AddTableProfileChildren1715682448384'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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`);
}
}

View file

@ -0,0 +1,42 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableProfilefather1715683524015 implements MigrationInterface {
name = 'AddTableProfilefather1715683524015'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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\``);
}
}

View file

@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDateRetire1715683984766 implements MigrationInterface {
name = 'AddTableDateRetire1715683984766'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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\``);
}
}