แก้ฟิวขอทุน

This commit is contained in:
Kittapath 2024-04-04 19:59:28 +07:00
parent 7e9aa4e0fa
commit de746486d1
5 changed files with 451 additions and 410 deletions

View file

@ -13,16 +13,15 @@ import {
Query,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import { Brackets, Not } from "typeorm";
import { Brackets } from "typeorm";
import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status";
import { Development } from "../entities/Development";
import {
CreateDevelopmentHistory,
DevelopmentHistory,
UpdateDevelopmentHistory,
} from "../entities/DevelopmentHistory";
CreateDevelopmentScholarship,
DevelopmentScholarship,
UpdateDevelopmentScholarship,
} from "../entities/DevelopmentScholarship";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
@ -30,298 +29,223 @@ import { PosLevel } from "../entities/PosLevel";
@Tags("DevelopmentScholarship")
@Security("bearerAuth")
export class DevelopmentScholarshipController extends Controller {
private developmentHistoryRepository = AppDataSource.getRepository(DevelopmentHistory);
private developmentRepository = AppDataSource.getRepository(Development);
private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship);
private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel);
// /**
// * API เพิ่มประวัติการฝึกอบรม/ดูงาน
// *
// * @summary DEV_006 - เพิ่มประวัติการฝึกอบรม/ดูงาน#6
// *
// */
// @Post()
// async CreateDevelopmentHistory(
// @Body() requestBody: CreateDevelopmentHistory,
// @Request() request: { user: Record<string, any> },
// ) {
// const type = "OFFICER";
// const chk_name = await this.developmentHistoryRepository.find({
// where: {
// citizenId: requestBody.citizenId,
// developmentId: requestBody.developmentId,
// type: type,
// },
// });
// if (chk_name.length > 0) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว");
// }
/**
* API /
*
* @summary DEV_011 - /#11
*
*/
@Post()
async CreateDevelopmentScholarship(
@Body() requestBody: CreateDevelopmentScholarship,
@Request() request: { user: Record<string, any> },
) {
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
// const checkId = await this.developmentRepository.findOne({
// where: { id: requestBody.developmentId },
// });
// if (!checkId) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม");
// }
// if (requestBody.posTypeId != null) {
// const checkId = await this.posTypeRepository.findOne({
// where: { id: requestBody.posTypeId },
// });
// if (!checkId) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
// }
// }
// if (requestBody.posLevelId != null) {
// const checkId = await this.posLevelRepository.findOne({
// where: { id: requestBody.posLevelId },
// });
// if (!checkId) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
// }
// }
const development = Object.assign(new DevelopmentScholarship(), requestBody);
development.createdUserId = request.user.sub;
development.createdFullName = request.user.name;
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
await this.developmentScholarshipRepository.save(development);
return new HttpSuccess(development.id);
}
// const development = Object.assign(new DevelopmentHistory(), requestBody);
// development.type = type;
// development.createdUserId = request.user.sub;
// development.createdFullName = request.user.name;
// development.lastUpdateUserId = request.user.sub;
// development.lastUpdateFullName = request.user.name;
// await this.developmentHistoryRepository.save(development);
// return new HttpSuccess(development.id);
// }
/**
* API /
*
* @summary DEV_012 - / #12
*
* @param {string} id Id
*/
@Put("{id}")
async UpdateDevelopmentScholarship(
@Path() id: string,
@Body() requestBody: UpdateDevelopmentScholarship,
@Request() request: { user: Record<string, any> },
) {
const development = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
if (requestBody.posTypeId != null) {
const checkId = await this.posTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
}
}
if (requestBody.posLevelId != null) {
const checkId = await this.posLevelRepository.findOne({
where: { id: requestBody.posLevelId },
});
if (!checkId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
}
}
Object.assign(development, requestBody);
development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name;
await this.developmentScholarshipRepository.save(development);
return new HttpSuccess(development.id);
}
// /**
// * API แก้ไขประวัติการฝึกอบรม/ดูงาน
// *
// * @summary DEV_007 - แก้ไขประวัติการฝึกอบรม/ดูงาน #7
// *
// * @param {string} id Id โครงการ
// */
// @Put("{id}")
// async UpdateDevelopmentHistory(
// @Path() id: string,
// @Body() requestBody: UpdateDevelopmentHistory,
// @Request() request: { user: Record<string, any> },
// ) {
// const type = "OFFICER";
// const development = await this.developmentHistoryRepository.findOne({
// where: { id: id, type: type },
// });
// if (!development) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
// }
// const chk_name = await this.developmentHistoryRepository.find({
// where: {
// citizenId: requestBody.citizenId,
// developmentId: requestBody.developmentId,
// type: type,
// id: Not(id),
// },
// });
// if (chk_name.length > 0) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ประวัติการฝึกอบรม/ดูงาน มีอยู่ในระบบแล้ว");
// }
// const checkId = await this.developmentRepository.findOne({
// where: { id: requestBody.developmentId },
// });
// if (!checkId) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรม");
// }
// if (requestBody.posTypeId != null) {
// const checkId = await this.posTypeRepository.findOne({
// where: { id: requestBody.posTypeId },
// });
// if (!checkId) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
// }
// }
// if (requestBody.posLevelId != null) {
// const checkId = await this.posLevelRepository.findOne({
// where: { id: requestBody.posLevelId },
// });
// if (!checkId) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
// }
// }
// Object.assign(development, requestBody);
// development.type = type;
// development.lastUpdateUserId = request.user.sub;
// development.lastUpdateFullName = request.user.name;
// await this.developmentHistoryRepository.save(development);
// return new HttpSuccess(development.id);
// }
/**
* API /
*
* @summary DEV_013 - / #13
*
* @param {string} id Id
*/
@Delete("{id}")
async DeleteDevelopmentScholarship(@Path() id: string) {
const development = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
// /**
// * API ลบประวัติการฝึกอบรม/ดูงาน
// *
// * @summary DEV_008 - ลบประวัติการฝึกอบรม/ดูงาน #8
// *
// * @param {string} id Id โครงการ
// */
// @Delete("{id}")
// async DeleteDevelopmentHistory(@Path() id: string) {
// const type = "OFFICER";
// const development = await this.developmentHistoryRepository.findOne({
// where: { id: id, type: type },
// });
// if (!development) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
// }
await this.developmentScholarshipRepository.remove(development);
return new HttpSuccess();
}
// await this.developmentHistoryRepository.remove(development);
// return new HttpSuccess();
// }
/**
* API /
*
* @summary DEV_014 - / #14
*
*/
@Get()
async GetDevelopmentScholarshipLists(
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string,
@Query("year") year?: number,
) {
const type = "OFFICER";
const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship)
.createQueryBuilder("developmentScholarship")
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
.leftJoinAndSelect("developmentScholarship.posType", "posType")
.andWhere(
year != 0 && year != null && year != undefined
? "developmentScholarship.scholarshipYear = :scholarshipYear"
: "1=1",
{ year: year },
)
.andWhere("developmentScholarship.type = :type", { type: type })
.andWhere(
new Brackets((qb) => {
qb.where(
keyword != null && keyword != ""
? "developmentScholarship.prefix LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != ""
? "developmentScholarship.firstName LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != ""
? "developmentScholarship.lastName LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != ""
? "developmentScholarship.position LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != ""
? "developmentScholarship.position LIKE :keyword"
: "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1",
{
keyword: `%${keyword}%`,
},
);
}),
)
.orderBy("developmentScholarship.createdAt", "DESC")
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
const formattedData = development.map((item) => ({
id: item.id,
citizenId: item.citizenId,
fullName: item.prefix + item.firstName + " " + item.lastName,
position: item.position,
posType: item.posType ? item.posType.posTypeName : null,
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
posExecutive: item.posExecutive,
}));
// /**
// * API รายการประวัติการฝึกอบรม/ดูงาน
// *
// * @summary DEV_009 - รายการประวัติการฝึกอบรม/ดูงาน #9
// *
// */
// @Get()
// async GetDevelopmentHistoryLists(
// @Query("page") page: number = 1,
// @Query("pageSize") pageSize: number = 10,
// @Query("keyword") keyword?: string,
// @Query("year") year?: number,
// ) {
// const type = "OFFICER";
// const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
// .createQueryBuilder("developmentHistory")
// .leftJoinAndSelect("developmentHistory.development", "development")
// .leftJoinAndSelect("developmentHistory.posLevel", "posLevel")
// .leftJoinAndSelect("developmentHistory.posType", "posType")
// .andWhere(year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1", { year: year })
// .andWhere("developmentHistory.type = :type", { type: type })
// .andWhere(
// new Brackets((qb) => {
// qb.where(
// keyword != null && keyword != ""
// ? "developmentHistory.prefix LIKE :keyword"
// : "1=1",
// {
// keyword: `%${keyword}%`,
// },
// )
// .orWhere(
// keyword != null && keyword != ""
// ? "developmentHistory.firstName LIKE :keyword"
// : "1=1",
// {
// keyword: `%${keyword}%`,
// },
// )
// .orWhere(
// keyword != null && keyword != ""
// ? "developmentHistory.lastName LIKE :keyword"
// : "1=1",
// {
// keyword: `%${keyword}%`,
// },
// )
// .orWhere(
// keyword != null && keyword != ""
// ? "developmentHistory.position LIKE :keyword"
// : "1=1",
// {
// keyword: `%${keyword}%`,
// },
// )
// .orWhere(
// keyword != null && keyword != ""
// ? "developmentHistory.position LIKE :keyword"
// : "1=1",
// {
// keyword: `%${keyword}%`,
// },
// )
// .orWhere(
// keyword != null && keyword != ""
// ? "development.projectName LIKE :keyword"
// : "1=1",
// {
// keyword: `%${keyword}%`,
// },
// )
// .orWhere(
// keyword != null && keyword != ""
// ? "posType.posTypeName LIKE :keyword"
// : "1=1",
// {
// keyword: `%${keyword}%`,
// },
// )
// .orWhere(
// keyword != null && keyword != ""
// ? "posLevel.posLevelName LIKE :keyword"
// : "1=1",
// {
// keyword: `%${keyword}%`,
// },
// );
// }),
// )
// .orderBy("developmentHistory.createdAt", "DESC")
// .skip((page - 1) * pageSize)
// .take(pageSize)
// .getManyAndCount();
// const formattedData = development.map(item => ({
// id: item.id,
// citizenId: item.citizenId,
// fullName: item.prefix+item.firstName+" "+item.lastName,
// position: item.position,
// posType: item.posType ? item.posType.posTypeName : null,
// posLevel: item.posLevel ? item.posLevel.posLevelName : null,
// posExecutive: item.posExecutive,
// projectName: item.development.projectName,
// }));
return new HttpSuccess({ data: formattedData, total });
}
// return new HttpSuccess({ data: formattedData, total });
// }
/**
* API /
*
* @summary DEV_015 - / #15
*
* @param {string} id Id
*/
@Get("{id}")
async GetDevelopemtScholarshipById(@Path() id: string) {
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
// /**
// * API รายละเอียดประวัติการฝึกอบรม/ดูงาน
// *
// * @summary DEV_010 - รายละเอียดประวัติการฝึกอบรม/ดูงาน #10
// *
// * @param {string} id Id โครงการ
// */
// @Get("{id}")
// async GetDevelopemtHistoryById(@Path() id: string) {
// const type = "OFFICER";
// const getDevelopment = await this.developmentHistoryRepository.findOne({
// relations: ["development"],
// where: { id: id, type: type },
// });
// if (!getDevelopment) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
// }
// const formattedData = {
// rank: getDevelopment.rank ? getDevelopment.rank : null,
// prefix: getDevelopment.prefix ? getDevelopment.prefix : null,
// firstName: getDevelopment.firstName ? getDevelopment.firstName : null,
// lastName: getDevelopment.lastName ? getDevelopment.lastName : null,
// citizenId: getDevelopment.citizenId ? getDevelopment.citizenId : null,
// position: getDevelopment.position ? getDevelopment.position : null,
// posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null,
// posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
// developmentId: getDevelopment.developmentId ? getDevelopment.developmentId : null,
// order: getDevelopment.order ? getDevelopment.order : null,
// dateOrder: getDevelopment.dateOrder ? getDevelopment.dateOrder : null,
// year: getDevelopment.development.year ? getDevelopment.development.year : null,
// projectName: getDevelopment.development.projectName ? getDevelopment.development.projectName : null,
// dateStart: getDevelopment.development.dateStart ? getDevelopment.development.dateStart : null,
// dateEnd: getDevelopment.development.dateEnd ? getDevelopment.development.dateEnd : null,
// totalDate: getDevelopment.development.totalDate ? getDevelopment.development.totalDate : null,
// addressAcademic: getDevelopment.development.addressAcademic ? getDevelopment.development.addressAcademic : null,
// topicAcademic: getDevelopment.development.topicAcademic ? getDevelopment.development.topicAcademic : null,
// dateStudyStart: getDevelopment.development.dateStudyStart ? getDevelopment.development.dateStudyStart : null,
// dateStudyEnd: getDevelopment.development.dateStudyEnd ? getDevelopment.development.dateStudyEnd : null,
// org: null,
// };
// return new HttpSuccess(formattedData);
// }
return new HttpSuccess(getDevelopment);
}
}

View file

@ -1,5 +1,7 @@
import { Entity, Column, ManyToOne, JoinColumn, Double } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosLevel } from "./PosLevel";
import { PosType } from "./PosType";
@Entity("developmentScholarship")
export class DevelopmentScholarship extends EntityBase {
@ -59,6 +61,28 @@ export class DevelopmentScholarship extends EntityBase {
})
posExecutive: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีระดับตำแหน่ง",
})
posLevelId: string | null;
@ManyToOne(() => PosLevel, (posLevel) => posLevel.developmentScholars)
@JoinColumn({ name: "posLevelId" })
posLevel: PosLevel;
@Column({
nullable: true,
length: 40,
comment: "ไอดีประเภทตำแหน่ง",
})
posTypeId: string | null;
@ManyToOne(() => PosType, (posType) => posType.developmentScholars)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
@Column({
nullable: true,
comment: "ยศ(ผู้ค้ำ)",
@ -115,6 +139,28 @@ export class DevelopmentScholarship extends EntityBase {
})
guarantorPosExecutive: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีระดับตำแหน่ง(ผู้ค้ำ)",
})
posLevelguarantorId: string | null;
@ManyToOne(() => PosLevel, (posLevel) => posLevel.developmentScholarGuarantors)
@JoinColumn({ name: "posLevelguarantorId" })
posLevelguarantor: PosLevel;
@Column({
nullable: true,
length: 40,
comment: "ไอดีประเภทตำแหน่ง(ผู้ค้ำ)",
})
posTypeguarantorId: string | null;
@ManyToOne(() => PosType, (posType) => posType.developmentScholarGuarantors)
@JoinColumn({ name: "posTypeguarantorId" })
posTypeguarantor: PosType;
@Column({
nullable: true,
comment: "ปีงบประมาณที่ได้รับทุน",
@ -177,7 +223,7 @@ export class DevelopmentScholarship extends EntityBase {
changeDetail: string;
@Column({
//การศึกษาในประเทศ = DOMESTICE ,
//การศึกษาในประเทศ = DOMESTICE
//ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ) = NOABROAD
//ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ) = ABROAD
//ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร) = EXECUTIVE
@ -238,29 +284,28 @@ export class DevelopmentScholarship extends EntityBase {
reportBackDate: Date;
@Column({
//ปริญญาตรี = BACHELOR , ปริญญาโท = GRADUATE , ปริญญาเอก = MASTER , ปริญญาดุษฎีบัณฑิต = DOCTOR
nullable: true,
comment: "ระดับปริญญา",
length: 10,
length: 255,
default: null,
})
degreeLevel: string;
@Column({
nullable: true,
comment: "หลักสูตรการศึกษา",
comment: "หลักสูตรการศึกษา/หลักสูตรการฝึกอบรม",
length: 255,
default: null,
})
courseOfStudy: string;
course: string;
@Column({
nullable: true,
comment: "สาขาวิชา",
comment: "สาขาวิชา/สาขา",
length: 255,
default: null,
})
fieldOfStudy: string;
field: string;
@Column({
nullable: true,
@ -272,7 +317,7 @@ export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
comment: "สถาบันการศึกษา",
comment: "สถาบันการศึกษา/สถาบันการศึกษา_หน่วยงานผู้จัดการฝึกอบรม/สถานที่ไปศึกษาดูงานในประเทศ",
length: 255,
default: null,
})
@ -280,35 +325,35 @@ export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
comment: "วันเริ่มต้นการศึกษา",
length: 255,
type: "datetime",
comment: "วันเริ่มต้นการศึกษา/วันเริ่มต้นการฝึกอบรม/วันเริ่มต้นการศึกษาดูงานในประเทศ",
default: null,
})
studyStartDate: string;
@Column({
nullable: true,
comment: "วันสิ้นสุดการศึกษา",
length: 255,
default: null,
})
studyEndDate: string;
startDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันสิ้นสุดการศึกษา/วันสิ้นสุดการฝึกอบรม/วันสิ้นสุดการศึกษาดูงานในประเทศ",
default: null,
})
endDate: Date;
@Column({
nullable: true,
comment: "สถานที่ไปศึกษาดูงาน",
length: 255,
default: null,
})
studyTourPlace: Date;
studyPlace: string;
@Column({
nullable: true,
type: "datetime",
comment: "หัวข้อการไปศึกษาดูงาน",
comment: "หัวข้อการไปศึกษาดูงาน/หัวข้อการไปศึกษาดูงานในประเทศ",
length: 255,
default: null,
})
studyTourTopic: Date;
studyTopic: string;
@Column({
nullable: true,
@ -316,7 +361,7 @@ export class DevelopmentScholarship extends EntityBase {
comment: "วันเริ่มต้นการศึกษาดูงาน",
default: null,
})
studyTourStartDate: Date;
studyStartDate: Date;
@Column({
nullable: true,
@ -324,7 +369,7 @@ export class DevelopmentScholarship extends EntityBase {
comment: "วันสิ้นสุดการศึกษาดูงาน",
default: null,
})
studyTourEndDate: Date;
studyEndDate: Date;
@Column({
nullable: true,
@ -332,7 +377,7 @@ export class DevelopmentScholarship extends EntityBase {
length: 255,
default: null,
})
studyTourCountry: string;
studyCountry: string;
@Column({
nullable: true,
@ -340,7 +385,7 @@ export class DevelopmentScholarship extends EntityBase {
length: 255,
default: null,
})
studyTourAbroadTopic: string;
studyAbroadTopic: string;
@Column({
nullable: true,
@ -348,7 +393,7 @@ export class DevelopmentScholarship extends EntityBase {
comment: "วันเริ่มต้นการศึกษาดูงานต่างประเทศ",
default: null,
})
studyTourAbroadStartDate: Date;
studyAbroadStartDate: Date;
@Column({
nullable: true,
@ -356,79 +401,35 @@ export class DevelopmentScholarship extends EntityBase {
comment: "วันสิ้นสุดการศึกษาดูงานต่างประเทศ",
default: null,
})
studyTourAbroadEndDate: Date;
studyAbroadEndDate: Date;
@Column({
nullable: true,
comment: "รวมระยะเวลาในการศึกษา",
comment: "รวมระยะเวลาในการศึกษา/รวมระยะเวลาในการฝึกอบรม",
length: 40,
default: null,
})
totalStudyPeriod: string;
@Column({
nullable: true,
comment: "หลักสูตรการฝึกอบรม",
length: 255,
default: null,
})
trainingCourseName: string;
@Column({
nullable: true,
type: "date",
comment: "วันเริ่มต้นการฝึกอบรม",
default: null,
})
trainingStartDate: Date;
@Column({
nullable: true,
type: "date",
comment: "วันสิ้นสุดการฝึกอบรม",
default: null,
})
trainingEndDate: Date;
@Column({
nullable: true,
comment: "รวมระยะเวลาในการฝึกอบรม",
length: 40,
default: null,
})
totalTrainingTime: string;
@Column({
nullable: true,
comment: "เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ",
default: null,
length: 255,
})
order: string;
@Column({
nullable: true,
type: "datetime",
comment: "คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่",
default: null,
})
dateOrder: Date;
totalPeriod: string;
}
export class CreateDevelopmentScholarship {
rank: string | null;
rank?: string | null;
prefix: string | null;
firstName: string | null;
lastName: string | null;
citizenId: string | null;
position: string | null;
posExecutive: string | null;
guarantorRank: string | null;
posLevelId: string | null;
posTypeId: string | null;
guarantorRank?: string | null;
guarantorPrefix: string | null;
guarantorFirstName: string | null;
guarantorLastName: string | null;
guarantorCitizenId: string | null;
guarantorPosition: string | null;
guarantorPosExecutive: string | null;
posLevelguarantorId: string | null;
posTypeguarantorId: string | null;
scholarshipYear: number | null;
budgetSource: string | null;
budgetApprove: Double | null;
@ -445,44 +446,42 @@ export class CreateDevelopmentScholarship {
reportBackNoDate: Date | null;
reportBackDate: Date | null;
degreeLevel: string | null;
courseOfStudy: string | null;
fieldOfStudy: string | null;
course: string | null;
field: string | null;
faculty: string | null;
educationalInstitution: string | null;
studyStartDate: string | null;
studyEndDate: string | null;
studyTourPlace: Date | null;
studyTourTopic: Date | null;
studyTourStartDate: Date | null;
studyTourEndDate: Date | null;
studyTourCountry: string | null;
studyTourAbroadTopic: string | null;
studyTourAbroadStartDate: Date | null;
studyTourAbroadEndDate: Date | null;
totalStudyPeriod: string | null;
trainingCourseName: string | null;
trainingStartDate: Date | null;
trainingEndDate: Date | null;
totalTrainingTime: string | null;
order: string | null;
dateOrder: Date | null;
startDate: Date | null;
endDate: Date | null;
studyPlace: Date | null;
studyTopic: Date | null;
studyStartDate: Date | null;
studyEndDate: Date | null;
studyCountry: string | null;
studyAbroadTopic: string | null;
studyAbroadStartDate: Date | null;
studyAbroadEndDate: Date | null;
totalPeriod: string | null;
}
export class UpdateDevelopmentScholarship {
rank: string | null;
rank?: string | null;
prefix: string | null;
firstName: string | null;
lastName: string | null;
citizenId: string | null;
position: string | null;
posExecutive: string | null;
guarantorRank: string | null;
posLevelId: string | null;
posTypeId: string | null;
guarantorRank?: string | null;
guarantorPrefix: string | null;
guarantorFirstName: string | null;
guarantorLastName: string | null;
guarantorCitizenId: string | null;
guarantorPosition: string | null;
guarantorPosExecutive: string | null;
posLevelguarantorId: string | null;
posTypeguarantorId: string | null;
scholarshipYear: number | null;
budgetSource: string | null;
budgetApprove: Double | null;
@ -499,25 +498,19 @@ export class UpdateDevelopmentScholarship {
reportBackNoDate: Date | null;
reportBackDate: Date | null;
degreeLevel: string | null;
courseOfStudy: string | null;
fieldOfStudy: string | null;
course: string | null;
field: string | null;
faculty: string | null;
educationalInstitution: string | null;
studyStartDate: string | null;
studyEndDate: string | null;
studyTourPlace: Date | null;
studyTourTopic: Date | null;
studyTourStartDate: Date | null;
studyTourEndDate: Date | null;
studyTourCountry: string | null;
studyTourAbroadTopic: string | null;
studyTourAbroadStartDate: Date | null;
studyTourAbroadEndDate: Date | null;
totalStudyPeriod: string | null;
trainingCourseName: string | null;
trainingStartDate: Date | null;
trainingEndDate: Date | null;
totalTrainingTime: string | null;
order: string | null;
dateOrder: Date | null;
startDate: Date | null;
endDate: Date | null;
studyPlace: Date | null;
studyTopic: Date | null;
studyStartDate: Date | null;
studyEndDate: Date | null;
studyCountry: string | null;
studyAbroadTopic: string | null;
studyAbroadStartDate: Date | null;
studyAbroadEndDate: Date | null;
totalPeriod: string | null;
}

View file

@ -4,6 +4,7 @@ import { PosType } from "./PosType";
import { ActualGoal } from "./ActualGoal";
import { PlannedGoal } from "./PlannedGoal";
import { DevelopmentHistory } from "./DevelopmentHistory";
import { DevelopmentScholarship } from "./DevelopmentScholarship";
enum PosLevelAuthority {
HEAD = "HEAD",
@ -55,6 +56,18 @@ export class PosLevel extends EntityBase {
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel)
developmentHistorys: DevelopmentHistory[];
@OneToMany(
() => DevelopmentScholarship,
(developmentScholarship) => developmentScholarship.posLevel,
)
developmentScholars: DevelopmentScholarship[];
@OneToMany(
() => DevelopmentScholarship,
(developmentScholarship) => developmentScholarship.posLevelguarantor,
)
developmentScholarGuarantors: DevelopmentScholarship[];
}
export class CreatePosLevel {

View file

@ -4,6 +4,7 @@ import { PosLevel } from "./PosLevel";
import { ActualGoal } from "./ActualGoal";
import { PlannedGoal } from "./PlannedGoal";
import { DevelopmentHistory } from "./DevelopmentHistory";
import { DevelopmentScholarship } from "./DevelopmentScholarship";
@Entity("posType")
export class PosType extends EntityBase {
@ -34,6 +35,18 @@ export class PosType extends EntityBase {
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posType)
developmentHistorys: DevelopmentHistory[];
@OneToMany(
() => DevelopmentScholarship,
(developmentScholarship) => developmentScholarship.posType,
)
developmentScholars: DevelopmentScholarship[];
@OneToMany(
() => DevelopmentScholarship,
(developmentScholarship) => developmentScholarship.posTypeguarantor,
)
developmentScholarGuarantors: DevelopmentScholarship[];
}
export class CreatePosType {

View file

@ -0,0 +1,98 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableDevscholar11712235509538 implements MigrationInterface {
name = 'AddTableDevscholar11712235509538'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`courseOfStudy\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`dateOrder\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`fieldOfStudy\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`order\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourAbroadTopic\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourCountry\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourPlace\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTourTopic\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalStudyPeriod\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalTrainingTime\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingCourseName\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`trainingStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posLevelguarantorId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง(ผู้ค้ำ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`posTypeguarantorId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง(ผู้ค้ำ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`course\` varchar(255) NULL COMMENT 'หลักสูตรการศึกษา/หลักสูตรการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`field\` varchar(255) NULL COMMENT 'สาขาวิชา/สาขา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`startDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษา/วันเริ่มต้นการฝึกอบรม/วันเริ่มต้นการศึกษาดูงานในประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`endDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษา/วันสิ้นสุดการฝึกอบรม/วันสิ้นสุดการศึกษาดูงานในประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyPlace\` varchar(255) NULL COMMENT 'สถานที่ไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงาน/หัวข้อการไปศึกษาดูงานในประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyCountry\` varchar(255) NULL COMMENT 'ประเทศที่เดินทางไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyAbroadEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalPeriod\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการศึกษา/รวมระยะเวลาในการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`degreeLevel\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`degreeLevel\` varchar(255) NULL COMMENT 'ระดับปริญญา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`educationalInstitution\` \`educationalInstitution\` varchar(255) NULL COMMENT 'สถาบันการศึกษา/สถาบันการศึกษา_หน่วยงานผู้จัดการฝึกอบรม/สถานที่ไปศึกษาดูงานในประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_c95a104dc1c147cd9ffe676097a\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_4f93cbcfe04f319f043ca6bafe8\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_264f2b2fc644c7173484c3b67d9\` FOREIGN KEY (\`posLevelguarantorId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD CONSTRAINT \`FK_5a83bbe2bac1e79113df21ed6ef\` FOREIGN KEY (\`posTypeguarantorId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_5a83bbe2bac1e79113df21ed6ef\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_264f2b2fc644c7173484c3b67d9\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_4f93cbcfe04f319f043ca6bafe8\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP FOREIGN KEY \`FK_c95a104dc1c147cd9ffe676097a\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyEndDate\` varchar(255) NULL COMMENT 'วันสิ้นสุดการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyStartDate\` varchar(255) NULL COMMENT 'วันเริ่มต้นการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` CHANGE \`educationalInstitution\` \`educationalInstitution\` varchar(255) NULL COMMENT 'สถาบันการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`degreeLevel\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`degreeLevel\` varchar(10) NULL COMMENT 'ระดับปริญญา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`totalPeriod\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadEndDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadStartDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyAbroadTopic\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyCountry\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyTopic\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`studyPlace\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`endDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`startDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`field\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`course\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posTypeguarantorId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posLevelguarantorId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posTypeId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`posLevelId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingStartDate\` date NULL COMMENT 'วันเริ่มต้นการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingEndDate\` date NULL COMMENT 'วันสิ้นสุดการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`trainingCourseName\` varchar(255) NULL COMMENT 'หลักสูตรการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalTrainingTime\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`totalStudyPeriod\` varchar(40) NULL COMMENT 'รวมระยะเวลาในการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourTopic\` datetime NULL COMMENT 'หัวข้อการไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourPlace\` datetime NULL COMMENT 'สถานที่ไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourCountry\` varchar(255) NULL COMMENT 'ประเทศที่เดินทางไปศึกษาดูงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadTopic\` varchar(255) NULL COMMENT 'หัวข้อการไปศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadStartDate\` datetime NULL COMMENT 'วันเริ่มต้นการศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`studyTourAbroadEndDate\` datetime NULL COMMENT 'วันสิ้นสุดการศึกษาดูงานต่างประเทศ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`order\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง/เลขที่หนังสืออนุมัติ'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`fieldOfStudy\` varchar(255) NULL COMMENT 'สาขาวิชา'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`dateOrder\` datetime NULL COMMENT 'คำสั่งลงวันที่/หนังสืออนุมัติลงวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`courseOfStudy\` varchar(255) NULL COMMENT 'หลักสูตรการศึกษา'`);
}
}