บันทึกลงทะเบียนประวัติ

This commit is contained in:
Kittapath 2024-04-10 11:53:25 +07:00
parent 166c919bbe
commit b8e1c93cb4
3 changed files with 77 additions and 7 deletions

View file

@ -24,6 +24,7 @@ import {
} from "../entities/DevelopmentScholarship";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
import CallAPI from "../interfaces/call-api";
@Route("api/v1/development/scholarship")
@Tags("DevelopmentScholarship")
@ -75,7 +76,7 @@ export class DevelopmentScholarshipController extends Controller {
*
* @summary DEV_012 - / #12
*
* @param {string} id Id
* @param {string} id Id
*/
@Put("{id}")
async UpdateDevelopmentScholarship(
@ -117,7 +118,7 @@ export class DevelopmentScholarshipController extends Controller {
*
* @summary DEV_013 - / #13
*
* @param {string} id Id
* @param {string} id Id
*/
@Delete("{id}")
async DeleteDevelopmentScholarship(@Path() id: string) {
@ -224,7 +225,7 @@ export class DevelopmentScholarshipController extends Controller {
*
* @summary DEV_015 - / #15
*
* @param {string} id Id
* @param {string} id Id
*/
@Get("{id}")
async GetDevelopemtScholarshipById(@Path() id: string) {
@ -321,11 +322,15 @@ export class DevelopmentScholarshipController extends Controller {
*
* @summary DEV_0 - #
*
* @param {string} id Id
* @param {string} id Id
* @param {string} status status
*/
@Get("status/{id}/{status}")
async ChangeStatusDevelopemtScholarshipById(@Path() id: string, @Path() status: string) {
async ChangeStatusDevelopemtScholarshipById(
@Path() id: string,
@Path() status: string,
@Request() request: { user: Record<string, any> },
) {
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
@ -335,12 +340,53 @@ export class DevelopmentScholarshipController extends Controller {
const _status = status.trim().toUpperCase();
getDevelopment.status = _status;
if (_status == "GRADUATE") {
//xxxxxxxxxxxxxxxxxxxบันทึกลงทะเบียน
if (getDevelopment.scholarshipType != null) {
switch (getDevelopment.scholarshipType.trim().toUpperCase()) {
case "DOMESTICE":
getDevelopment.scholarshipType = "การศึกษาในประเทศ";
break;
case "NOABROAD":
getDevelopment.scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)";
break;
case "ABROAD":
getDevelopment.scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)";
break;
case "EXECUTIVE":
getDevelopment.scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)";
break;
default:
break;
}
}
let profileEdu = await new CallAPI().PostData(request, "org/profile/educations", {
profileId: getDevelopment.profileId,
institute: getDevelopment.educationalInstitution,
startDate: getDevelopment.startDate,
endDate: getDevelopment.endDate,
finishDate: null,
isEducation: false,
degree: null,
field: getDevelopment.field,
fundName: getDevelopment.scholarshipType,
gpa: null,
country: getDevelopment.studyCountry,
other: null,
duration: getDevelopment.totalPeriod,
durationYear: 0,
note: null,
educationLevel: getDevelopment.degreeLevel,
educationLevelId: null,
isDate: false,
positionPath: null,
positionPathId: null,
});
} else if (_status == "NOTGRADUATE") {
} else {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบสถานะนี้ในระบบ");
}
await this.developmentScholarshipRepository.remove(getDevelopment);
return new HttpSuccess();
}

View file

@ -5,6 +5,14 @@ import { PosType } from "./PosType";
@Entity("developmentScholarship")
export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
comment: "id profile",
length: 40,
default: null,
})
profileId: string;
@Column({
// PENDING = ค่าเริ่มต้น
// GRADUATE = สำเร็จการศึกษา
@ -423,6 +431,7 @@ export class DevelopmentScholarship extends EntityBase {
totalPeriod: string;
}
export class CreateDevelopmentScholarship {
profileId: string | null;
rank?: string | null;
prefix: string | null;
firstName: string | null;
@ -475,6 +484,7 @@ export class CreateDevelopmentScholarship {
}
export class UpdateDevelopmentScholarship {
profileId: string | null;
rank?: string | null;
prefix: string | null;
firstName: string | null;

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableScholarshipAddProfileId1712721970803 implements MigrationInterface {
name = 'UpdateTableScholarshipAddProfileId1712721970803'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`profileId\` varchar(40) NULL COMMENT 'id profile'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`profileId\``);
}
}