2024-04-04 18:05:18 +07:00
import {
Controller ,
Get ,
Post ,
Put ,
Delete ,
Route ,
Security ,
Tags ,
Body ,
Path ,
Request ,
Query ,
} from "tsoa" ;
import { AppDataSource } from "../database/data-source" ;
2024-04-04 19:59:28 +07:00
import { Brackets } from "typeorm" ;
2024-04-04 18:05:18 +07:00
import HttpSuccess from "../interfaces/http-success" ;
import HttpError from "../interfaces/http-error" ;
import HttpStatusCode from "../interfaces/http-status" ;
import {
2024-04-04 19:59:28 +07:00
CreateDevelopmentScholarship ,
DevelopmentScholarship ,
UpdateDevelopmentScholarship ,
2024-04-11 16:32:44 +07:00
UpdateDevelopmentScholarshipUser ,
2024-04-04 19:59:28 +07:00
} from "../entities/DevelopmentScholarship" ;
2024-04-04 18:05:18 +07:00
import { PosType } from "../entities/PosType" ;
import { PosLevel } from "../entities/PosLevel" ;
2024-04-10 11:53:25 +07:00
import CallAPI from "../interfaces/call-api" ;
2024-07-25 17:06:42 +07:00
import { RequestWithUser } from "../middlewares/user" ;
2024-09-03 15:18:30 +07:00
import { setLogDataDiff } from "../interfaces/utils" ;
2024-08-09 17:08:28 +07:00
import permission from "../interfaces/permission" ;
2024-04-04 18:05:18 +07:00
@Route ( "api/v1/development/scholarship" )
@Tags ( "DevelopmentScholarship" )
@Security ( "bearerAuth" )
export class DevelopmentScholarshipController extends Controller {
2024-04-04 19:59:28 +07:00
private developmentScholarshipRepository = AppDataSource . getRepository ( DevelopmentScholarship ) ;
2024-04-04 18:05:18 +07:00
private posTypeRepository = AppDataSource . getRepository ( PosType ) ;
private posLevelRepository = AppDataSource . getRepository ( PosLevel ) ;
2024-04-04 19:59:28 +07:00
/ * *
* API เ พ ิ ่ ม ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม
*
* @summary DEV_011 - เ พ ิ ่ ม ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม # 11
*
* /
@Post ( )
async CreateDevelopmentScholarship (
@Body ( ) requestBody : CreateDevelopmentScholarship ,
2024-07-25 17:06:42 +07:00
@Request ( ) request : RequestWithUser ,
2024-04-04 19:59:28 +07:00
) {
2024-08-09 17:08:28 +07:00
await new permission ( ) . PermissionCreate ( request , "SYS_DEV_SCHOLARSHIP" ) ;
2024-04-04 19:59:28 +07:00
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 , "ไม่พบข้อมูลระดับตำแหน่ง" ) ;
}
}
2024-07-26 16:30:38 +07:00
const before = null ;
2024-04-04 19:59:28 +07:00
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 ;
2024-09-03 14:59:53 +07:00
development . createdAt = new Date ( ) ;
development . lastUpdatedAt = new Date ( ) ;
2024-07-25 17:06:42 +07:00
await this . developmentScholarshipRepository . save ( development , { data : request } ) ;
2024-07-26 16:30:38 +07:00
setLogDataDiff ( request , { before , after : development } ) ;
2024-04-04 19:59:28 +07:00
return new HttpSuccess ( development . id ) ;
}
2024-04-04 18:05:18 +07:00
2024-04-04 19:59:28 +07:00
/ * *
* API แ ก ้ ไ ข ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม
*
* @summary DEV_012 - แ ก ้ ไ ข ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม # 12
*
2024-04-10 11:53:25 +07:00
* @param { string } id Id ข ้ า ร า ช ก า ร ฯ ท ี ่ ไ ด ้ ร ั บ ท ุ น ก า ร ศ ึ ก ษ า
2024-04-04 19:59:28 +07:00
* /
@Put ( "{id}" )
async UpdateDevelopmentScholarship (
@Path ( ) id : string ,
@Body ( ) requestBody : UpdateDevelopmentScholarship ,
2024-07-25 17:06:42 +07:00
@Request ( ) request : RequestWithUser ,
2024-04-04 19:59:28 +07:00
) {
2024-08-09 17:08:28 +07:00
await new permission ( ) . PermissionUpdate ( request , "SYS_DEV_SCHOLARSHIP" ) ;
2024-04-04 19:59:28 +07:00
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 , "ไม่พบข้อมูลระดับตำแหน่ง" ) ;
}
}
2024-07-25 17:06:42 +07:00
const before = structuredClone ( development ) ;
2024-04-04 19:59:28 +07:00
Object . assign ( development , requestBody ) ;
development . lastUpdateUserId = request . user . sub ;
development . lastUpdateFullName = request . user . name ;
2024-09-03 14:59:53 +07:00
development . lastUpdatedAt = new Date ( ) ;
2024-07-25 17:06:42 +07:00
await this . developmentScholarshipRepository . save ( development , { data : request } ) ;
setLogDataDiff ( request , { before , after : development } ) ;
2024-04-04 19:59:28 +07:00
return new HttpSuccess ( development . id ) ;
}
2024-04-04 18:05:18 +07:00
2024-04-04 19:59:28 +07:00
/ * *
* API ล บ ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม
*
* @summary DEV_013 - ล บ ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม # 13
*
2024-04-10 11:53:25 +07:00
* @param { string } id Id ข ้ า ร า ช ก า ร ฯ ท ี ่ ไ ด ้ ร ั บ ท ุ น ก า ร ศ ึ ก ษ า
2024-04-04 19:59:28 +07:00
* /
@Delete ( "{id}" )
2024-07-25 17:06:42 +07:00
async DeleteDevelopmentScholarship ( @Path ( ) id : string , @Request ( ) request : RequestWithUser ) {
2024-08-09 17:08:28 +07:00
await new permission ( ) . PermissionDelete ( request , "SYS_DEV_SCHOLARSHIP" ) ;
2024-04-04 19:59:28 +07:00
const development = await this . developmentScholarshipRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! development ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้" ) ;
}
2024-08-30 14:17:29 +07:00
2024-07-25 17:06:42 +07:00
await this . developmentScholarshipRepository . remove ( development , { data : request } ) ;
2024-04-04 19:59:28 +07:00
return new HttpSuccess ( ) ;
}
2024-04-04 18:05:18 +07:00
2024-04-04 19:59:28 +07:00
/ * *
* API ร า ย ก า ร ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม
*
* @summary DEV_014 - ร า ย ก า ร ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม # 14
*
* /
@Get ( )
async GetDevelopmentScholarshipLists (
2024-08-22 14:14:35 +07:00
@Request ( ) request : RequestWithUser ,
2024-04-04 19:59:28 +07:00
@Query ( "page" ) page : number = 1 ,
@Query ( "pageSize" ) pageSize : number = 10 ,
@Query ( "keyword" ) keyword? : string ,
@Query ( "year" ) year? : number ,
2024-04-05 10:19:28 +07:00
@Query ( "scholarshipType" ) scholarshipType? : string ,
2025-10-02 17:31:37 +07:00
@Query ( "sortBy" ) sortBy? : string ,
@Query ( "descending" ) descending? : boolean ,
2026-03-05 18:00:20 +07:00
@Query ( "citizenId" ) citizenId? : string ,
@Query ( "guarantorCitizenId" ) guarantorCitizenId? : string ,
2024-04-04 19:59:28 +07:00
) {
2025-06-16 21:34:15 +07:00
let _data = await new permission ( ) . PermissionOrgList ( request , "SYS_DEV_SCHOLARSHIP" ) ;
await new CallAPI ( )
. PostData ( request , "/org/finddna" , _data )
. then ( ( x ) = > {
_data = x ;
} )
. catch ( ( x ) = > { } ) ;
2025-12-16 14:14:39 +07:00
let _status :string = "" ;
2025-12-15 17:05:36 +07:00
if ( keyword && [ "กำลังศึกษา" , "เรียนไม่จบ" , "เรียนจบ" ] . includes ( keyword . trim ( ) ) ) {
const mapStatus : Record < string , string > = {
"กำลังศึกษา" : "PENDING" ,
"เรียนไม่จบ" : "NOTGRADUATE" ,
"เรียนจบ" : "GRADUATE" ,
} ;
2025-12-16 14:14:39 +07:00
_status = mapStatus [ keyword . trim ( ) ] ;
keyword = "" ;
2025-12-15 17:05:36 +07:00
}
2025-10-02 17:31:37 +07:00
let query = await AppDataSource . getRepository ( DevelopmentScholarship )
2024-04-04 19:59:28 +07:00
. createQueryBuilder ( "developmentScholarship" )
. leftJoinAndSelect ( "developmentScholarship.posLevel" , "posLevel" )
. leftJoinAndSelect ( "developmentScholarship.posType" , "posType" )
2025-12-16 14:14:39 +07:00
. andWhere (
_status != "" && keyword == ""
? "developmentScholarship.status = :status"
: "1=1" ,
{ status : _status } ,
)
2024-04-04 19:59:28 +07:00
. andWhere (
2024-04-05 10:27:01 +07:00
year !== 0 && year != null && year != undefined
2024-04-04 19:59:28 +07:00
? "developmentScholarship.scholarshipYear = :scholarshipYear"
: "1=1" ,
2024-04-05 10:19:28 +07:00
{ scholarshipYear : year } ,
2024-04-04 19:59:28 +07:00
)
2024-04-05 10:27:01 +07:00
. andWhere (
2026-03-05 18:00:20 +07:00
scholarshipType != null && scholarshipType != undefined && scholarshipType != "ALL"
2024-04-09 16:30:29 +07:00
? "developmentScholarship.scholarshipType = :scholarshipType"
: "1=1" ,
{ scholarshipType : scholarshipType } ,
)
2026-03-05 18:00:20 +07:00
. andWhere (
citizenId != null && citizenId != undefined && citizenId != ""
? "developmentScholarship.citizenId = :citizenId"
: "1=1" ,
{ citizenId : citizenId } ,
)
. andWhere (
guarantorCitizenId != null && guarantorCitizenId != undefined && guarantorCitizenId != ""
? "developmentScholarship.guarantorCitizenId = :guarantorCitizenId"
: "1=1" ,
{ guarantorCitizenId : guarantorCitizenId } ,
)
2024-04-04 19:59:28 +07:00
. andWhere (
2024-04-09 16:30:29 +07:00
new Brackets ( ( qb ) = > {
qb . where (
keyword != null && keyword != ""
? ` CONCAT(developmentScholarship.prefix, developmentScholarship.firstName," ",developmentScholarship.lastName) like '% ${ keyword } %' `
: "1=1" ,
{
keyword : ` % ${ keyword } % ` ,
} ,
)
2026-03-05 18:00:20 +07:00
. orWhere (
keyword != null && keyword != ""
? ` CONCAT(developmentScholarship.guarantorPrefix, developmentScholarship.guarantorFirstName," ",developmentScholarship.guarantorLastName) like '% ${ keyword } %' `
: "1=1" ,
{
keyword : ` % ${ keyword } % ` ,
} ,
)
2025-12-15 17:05:36 +07:00
. orWhere (
keyword != null && keyword != ""
? "developmentScholarship.citizenId LIKE :keyword"
: "1=1" ,
{
keyword : ` % ${ keyword } % ` ,
} ,
)
. orWhere (
keyword != null && keyword != ""
? "developmentScholarship.position LIKE :keyword"
: "1=1" ,
{
keyword : ` % ${ keyword } % ` ,
} ,
)
. orWhere (
keyword != null && keyword != ""
? "developmentScholarship.posExecutive 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 } % ` ,
} ,
) ;
2024-04-04 19:59:28 +07:00
} ) ,
)
2025-06-16 21:34:15 +07:00
. andWhere (
_data . root != undefined && _data . root != null
? _data . root [ 0 ] != null
? ` developmentScholarship.rootDnaId IN (:...root) `
: ` developmentScholarship.rootDnaId is null `
: "1=1" ,
{
root : _data.root ,
} ,
)
2025-10-02 17:31:37 +07:00
if ( sortBy ) {
if ( sortBy === "posType" ) {
query = query . orderBy (
` posType.posTypeName ` ,
descending ? "DESC" : "ASC"
) ;
2026-03-05 18:00:20 +07:00
}
else if ( sortBy === "posLevel" ) {
2025-10-02 17:31:37 +07:00
query = query . orderBy (
` posLevel.posLevelName ` ,
descending ? "DESC" : "ASC"
) ;
2026-03-05 18:00:20 +07:00
}
else if ( sortBy === "year" ) {
2025-10-02 17:31:37 +07:00
query = query . orderBy (
` developmentScholarship.scholarshipYear ` ,
descending ? "DESC" : "ASC"
) ;
2026-03-05 18:00:20 +07:00
}
else if ( sortBy === "fullName" ) {
2025-10-02 17:31:37 +07:00
query = query
. orderBy ( ` developmentScholarship.prefix ` , descending ? "DESC" : "ASC" )
. addOrderBy ( ` developmentScholarship.firstName ` , descending ? "DESC" : "ASC" )
. addOrderBy ( ` developmentScholarship.lastName ` , descending ? "DESC" : "ASC" )
2026-03-05 18:00:20 +07:00
}
else {
2025-10-02 17:31:37 +07:00
query = query . orderBy (
` developmentScholarship. ${ sortBy } ` ,
descending ? "DESC" : "ASC"
) ;
}
2026-03-05 18:00:20 +07:00
}
else {
query = query . orderBy ( "developmentScholarship.startDate" , "ASC" )
2025-10-02 17:31:37 +07:00
. addOrderBy ( "developmentScholarship.createdAt" , "DESC" )
}
const [ development , total ] = await query
2024-04-04 19:59:28 +07:00
. skip ( ( page - 1 ) * pageSize )
. take ( pageSize )
. getManyAndCount ( ) ;
2025-10-02 17:31:37 +07:00
2024-04-04 19:59:28 +07:00
const formattedData = development . map ( ( item ) = > ( {
id : item.id ,
2024-05-03 17:38:39 +07:00
year : item.scholarshipYear ,
2024-04-04 19:59:28 +07:00
citizenId : item.citizenId ,
2026-03-06 10:23:41 +07:00
fullName : ` ${ item . prefix ? ? "" } ${ item . firstName ? ? "" } ${ item . lastName ? ? "" } ` . trim ( ) ,
2024-04-04 19:59:28 +07:00
position : item.position ,
posType : item.posType ? item.posType.posTypeName : null ,
posLevel : item.posLevel ? item.posLevel.posLevelName : null ,
posExecutive : item.posExecutive ,
2024-12-11 13:51:56 +07:00
status : item.status ,
2026-03-05 18:00:20 +07:00
scholarshipType : item.scholarshipType ,
startDate : item.startDate ,
endDate : item.endDate ,
2026-03-06 10:23:41 +07:00
fullNameGuarantor : ` ${ item . guarantorPrefix ? ? "" } ${ item . guarantorFirstName ? ? "" } ${ item . guarantorLastName ? ? "" } ` . trim ( ) ,
2026-03-05 18:00:20 +07:00
guarantorCitizenId : item.guarantorCitizenId ,
2024-04-04 19:59:28 +07:00
} ) ) ;
2024-04-04 18:05:18 +07:00
2024-04-04 19:59:28 +07:00
return new HttpSuccess ( { data : formattedData , total } ) ;
}
2024-04-04 18:05:18 +07:00
2024-04-04 19:59:28 +07:00
/ * *
* API ร า ย ล ะ เ อ ี ย ด ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม
*
* @summary DEV_015 - ร า ย ล ะ เ อ ี ย ด ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม # 15
*
2024-04-10 11:53:25 +07:00
* @param { string } id Id ข ้ า ร า ช ก า ร ฯ ท ี ่ ไ ด ้ ร ั บ ท ุ น ก า ร ศ ึ ก ษ า
2024-04-04 19:59:28 +07:00
* /
@Get ( "{id}" )
2024-08-22 14:14:35 +07:00
async GetDevelopemtScholarshipById ( @Request ( ) request : RequestWithUser , @Path ( ) id : string ) {
2024-10-22 08:21:07 +07:00
//await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP"); //USER
2024-08-30 14:17:29 +07:00
const getDevelopment = await this . developmentScholarshipRepository . findOne ( {
relations : [ "posLevel" , "posType" , "posLevelguarantor" , "posTypeguarantor" ] ,
where : { id : id } ,
} ) ;
if ( ! getDevelopment ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้" ) ;
}
const formattedData = {
2025-06-16 21:34:15 +07:00
rootDnaId : getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null ,
2024-08-30 14:17:29 +07:00
rootId : getDevelopment.rootId ? getDevelopment.rootId : null ,
root : getDevelopment.root ? getDevelopment.root : null ,
org : getDevelopment.org ? getDevelopment.org : null ,
orgRootShortName : getDevelopment.orgRootShortName ? getDevelopment.orgRootShortName : null ,
orgRevisionId : getDevelopment.orgRevisionId ? getDevelopment.orgRevisionId : null ,
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 ,
posExecutive : getDevelopment.posExecutive ? getDevelopment.posExecutive : null ,
posLevelId : getDevelopment.posLevelId ? getDevelopment.posLevelId : null ,
posLevelName : getDevelopment.posLevel?.posLevelName
? getDevelopment . posLevel ? . posLevelName
: null ,
posTypeId : getDevelopment.posTypeId ? getDevelopment.posTypeId : null ,
posTypeName : getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null ,
2025-06-16 21:34:15 +07:00
guarantorRootDnaId : getDevelopment.guarantorRootDnaId
? getDevelopment . guarantorRootDnaId
: null ,
2024-08-30 14:17:29 +07:00
guarantorRootId : getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null ,
guarantorRoot : getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null ,
guarantorOrg : getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null ,
guarantorOrgRootShortName : getDevelopment.guarantorOrgRootShortName
? getDevelopment . guarantorOrgRootShortName
: null ,
guarantorOrgRevisionId : getDevelopment.guarantorOrgRevisionId
? getDevelopment . guarantorOrgRevisionId
: null ,
guarantorRank : getDevelopment.guarantorRank ? getDevelopment.guarantorRank : null ,
guarantorPrefix : getDevelopment.guarantorPrefix ? getDevelopment.guarantorPrefix : null ,
guarantorFirstName : getDevelopment.guarantorFirstName
? getDevelopment . guarantorFirstName
: null ,
guarantorLastName : getDevelopment.guarantorLastName ? getDevelopment.guarantorLastName : null ,
guarantorCitizenId : getDevelopment.guarantorCitizenId
? getDevelopment . guarantorCitizenId
: null ,
guarantorPosition : getDevelopment.guarantorPosition ? getDevelopment.guarantorPosition : null ,
guarantorPosExecutive : getDevelopment.guarantorPosExecutive
? getDevelopment . guarantorPosExecutive
: null ,
posLevelguarantorId : getDevelopment.posLevelguarantorId
? getDevelopment . posLevelguarantorId
: null ,
posLevelguarantorName : getDevelopment.posLevelguarantor?.posLevelName
? getDevelopment . posLevelguarantor ? . posLevelName
: null ,
posTypeguarantorId : getDevelopment.posTypeguarantorId
? getDevelopment . posTypeguarantorId
: null ,
posTypeguarantorName : getDevelopment.posTypeguarantor?.posTypeName
? getDevelopment . posTypeguarantor ? . posTypeName
: null ,
scholarshipYear : getDevelopment.scholarshipYear ? getDevelopment.scholarshipYear : null ,
budgetSource : getDevelopment.budgetSource ? getDevelopment.budgetSource : null ,
2025-10-08 17:26:09 +07:00
budgetSourceOther : getDevelopment.budgetSourceOther ? getDevelopment.budgetSourceOther : null ,
2024-08-30 14:17:29 +07:00
budgetApprove : getDevelopment.budgetApprove ? getDevelopment.budgetApprove : null ,
bookNo : getDevelopment.bookNo ? getDevelopment.bookNo : null ,
bookNoDate : getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null ,
bookApproveDate : getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null ,
2025-04-22 10:14:31 +07:00
useOfficialTime : getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null ,
2024-08-30 14:17:29 +07:00
changeDetail : getDevelopment.changeDetail ? getDevelopment.changeDetail : null ,
scholarshipType : getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null ,
fundType : getDevelopment.fundType ? getDevelopment.fundType : null ,
contractNo : getDevelopment.contractNo ? getDevelopment.contractNo : null ,
contractDate : getDevelopment.contractDate ? getDevelopment.contractDate : null ,
reportBackNo : getDevelopment.reportBackNo ? getDevelopment.reportBackNo : null ,
reportBackNoDate : getDevelopment.reportBackNoDate ? getDevelopment.reportBackNoDate : null ,
reportBackDate : getDevelopment.reportBackDate ? getDevelopment.reportBackDate : null ,
degreeLevel : getDevelopment.degreeLevel ? getDevelopment.degreeLevel : null ,
course : getDevelopment.course ? getDevelopment.course : null ,
field : getDevelopment.field ? getDevelopment.field : null ,
faculty : getDevelopment.faculty ? getDevelopment.faculty : null ,
educationalInstitution : getDevelopment.educationalInstitution
? getDevelopment . educationalInstitution
: null ,
startDate : getDevelopment.startDate ? getDevelopment.startDate : null ,
endDate : getDevelopment.endDate ? getDevelopment.endDate : null ,
studyPlace : getDevelopment.studyPlace ? getDevelopment.studyPlace : null ,
studyTopic : getDevelopment.studyTopic ? getDevelopment.studyTopic : null ,
studyStartDate : getDevelopment.studyStartDate ? getDevelopment.studyStartDate : null ,
studyEndDate : getDevelopment.studyEndDate ? getDevelopment.studyEndDate : null ,
studyCountry : getDevelopment.studyCountry ? getDevelopment.studyCountry : null ,
studyAbroadTopic : getDevelopment.studyAbroadTopic ? getDevelopment.studyAbroadTopic : null ,
studyAbroadStartDate : getDevelopment.studyAbroadStartDate
? getDevelopment . studyAbroadStartDate
: null ,
studyAbroadEndDate : getDevelopment.studyAbroadEndDate
? getDevelopment . studyAbroadEndDate
: null ,
totalPeriod : getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null ,
status : getDevelopment.status ? getDevelopment.status : null ,
profileId : getDevelopment.profileId ? getDevelopment.profileId : null ,
planType : getDevelopment.planType ? getDevelopment.planType : null ,
isNoUseBudget : getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null ,
} ;
return new HttpSuccess ( formattedData ) ;
}
2024-09-03 19:08:13 +07:00
/ * *
* API แ ก ้ ไ ข ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม
*
* @summary DEV_012 - แ ก ้ ไ ข ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม # 12
*
* @param { string } id Id ข ้ า ร า ช ก า ร ฯ ท ี ่ ไ ด ้ ร ั บ ท ุ น ก า ร ศ ึ ก ษ า
* /
@Put ( "admin/{id}" )
async UpdateDevelopmentScholarshipAdminById (
@Path ( ) id : string ,
@Body ( ) requestBody : UpdateDevelopmentScholarship ,
@Request ( ) request : RequestWithUser ,
) {
await new permission ( ) . PermissionUpdate ( request , "SYS_DEV_SCHOLARSHIP" ) ;
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 , "ไม่พบข้อมูลระดับตำแหน่ง" ) ;
}
}
const before = structuredClone ( development ) ;
Object . assign ( development , requestBody ) ;
development . lastUpdateUserId = request . user . sub ;
development . lastUpdateFullName = request . user . name ;
development . lastUpdatedAt = new Date ( ) ;
await this . developmentScholarshipRepository . save ( development , { data : request } ) ;
setLogDataDiff ( request , { before , after : development } ) ;
return new HttpSuccess ( development . id ) ;
}
2024-08-30 14:17:29 +07:00
/ * *
* API ร า ย ล ะ เ อ ี ย ด ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม ADMIN
*
* @summary DEV_015 - ร า ย ล ะ เ อ ี ย ด ท ุ น ก า ร ศ ึ ก ษ า / ฝ ึ ก อ บ ร ม # 15 ADMIN
*
* @param { string } id Id ข ้ า ร า ช ก า ร ฯ ท ี ่ ไ ด ้ ร ั บ ท ุ น ก า ร ศ ึ ก ษ า ADMIN
* /
@Get ( "admin/{id}" )
async GetDevelopemtScholarshipAdminById ( @Request ( ) request : RequestWithUser , @Path ( ) id : string ) {
2024-10-22 08:21:07 +07:00
let _workflow = await new permission ( ) . Workflow ( request , id , "SYS_DEV_SCHOLARSHIP" ) ;
if ( _workflow == false ) await new permission ( ) . PermissionGet ( request , "SYS_DEV_SCHOLARSHIP" ) ;
2024-04-04 19:59:28 +07:00
const getDevelopment = await this . developmentScholarshipRepository . findOne ( {
2024-04-09 16:30:29 +07:00
relations : [ "posLevel" , "posType" , "posLevelguarantor" , "posTypeguarantor" ] ,
2024-04-04 19:59:28 +07:00
where : { id : id } ,
} ) ;
if ( ! getDevelopment ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้" ) ;
}
2024-04-05 10:24:19 +07:00
const formattedData = {
2025-06-16 21:34:15 +07:00
rootDnaId : getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null ,
2024-04-18 16:17:37 +07:00
rootId : getDevelopment.rootId ? getDevelopment.rootId : null ,
root : getDevelopment.root ? getDevelopment.root : null ,
2024-04-17 17:31:07 +07:00
org : getDevelopment.org ? getDevelopment.org : null ,
2024-04-18 16:17:37 +07:00
orgRootShortName : getDevelopment.orgRootShortName ? getDevelopment.orgRootShortName : null ,
orgRevisionId : getDevelopment.orgRevisionId ? getDevelopment.orgRevisionId : null ,
2024-04-05 10:24:19 +07:00
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 ,
posExecutive : getDevelopment.posExecutive ? getDevelopment.posExecutive : null ,
posLevelId : getDevelopment.posLevelId ? getDevelopment.posLevelId : null ,
2024-04-09 16:30:29 +07:00
posLevelName : getDevelopment.posLevel?.posLevelName
? getDevelopment . posLevel ? . posLevelName
: null ,
2024-04-05 10:24:19 +07:00
posTypeId : getDevelopment.posTypeId ? getDevelopment.posTypeId : null ,
2024-04-05 12:17:07 +07:00
posTypeName : getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null ,
2025-06-16 21:34:15 +07:00
guarantorRootDnaId : getDevelopment.guarantorRootDnaId
? getDevelopment . guarantorRootDnaId
: null ,
2024-04-18 16:17:37 +07:00
guarantorRootId : getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null ,
guarantorRoot : getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null ,
guarantorOrg : getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null ,
guarantorOrgRootShortName : getDevelopment.guarantorOrgRootShortName
? getDevelopment . guarantorOrgRootShortName
: null ,
guarantorOrgRevisionId : getDevelopment.guarantorOrgRevisionId
? getDevelopment . guarantorOrgRevisionId
: null ,
2024-04-05 10:24:19 +07:00
guarantorRank : getDevelopment.guarantorRank ? getDevelopment.guarantorRank : null ,
guarantorPrefix : getDevelopment.guarantorPrefix ? getDevelopment.guarantorPrefix : null ,
2024-04-09 16:30:29 +07:00
guarantorFirstName : getDevelopment.guarantorFirstName
? getDevelopment . guarantorFirstName
: null ,
2024-04-05 10:24:19 +07:00
guarantorLastName : getDevelopment.guarantorLastName ? getDevelopment.guarantorLastName : null ,
2024-04-09 16:30:29 +07:00
guarantorCitizenId : getDevelopment.guarantorCitizenId
? getDevelopment . guarantorCitizenId
: null ,
2024-04-05 10:24:19 +07:00
guarantorPosition : getDevelopment.guarantorPosition ? getDevelopment.guarantorPosition : null ,
2024-04-09 16:30:29 +07:00
guarantorPosExecutive : getDevelopment.guarantorPosExecutive
? getDevelopment . guarantorPosExecutive
: null ,
posLevelguarantorId : getDevelopment.posLevelguarantorId
? getDevelopment . posLevelguarantorId
: null ,
posLevelguarantorName : getDevelopment.posLevelguarantor?.posLevelName
? getDevelopment . posLevelguarantor ? . posLevelName
: null ,
posTypeguarantorId : getDevelopment.posTypeguarantorId
? getDevelopment . posTypeguarantorId
: null ,
posTypeguarantorName : getDevelopment.posTypeguarantor?.posTypeName
? getDevelopment . posTypeguarantor ? . posTypeName
: null ,
2024-04-05 10:24:19 +07:00
scholarshipYear : getDevelopment.scholarshipYear ? getDevelopment.scholarshipYear : null ,
budgetSource : getDevelopment.budgetSource ? getDevelopment.budgetSource : null ,
budgetApprove : getDevelopment.budgetApprove ? getDevelopment.budgetApprove : null ,
bookNo : getDevelopment.bookNo ? getDevelopment.bookNo : null ,
bookNoDate : getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null ,
bookApproveDate : getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null ,
2025-04-22 10:14:31 +07:00
useOfficialTime : getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null ,
2024-04-05 10:24:19 +07:00
changeDetail : getDevelopment.changeDetail ? getDevelopment.changeDetail : null ,
scholarshipType : getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null ,
fundType : getDevelopment.fundType ? getDevelopment.fundType : null ,
contractNo : getDevelopment.contractNo ? getDevelopment.contractNo : null ,
contractDate : getDevelopment.contractDate ? getDevelopment.contractDate : null ,
reportBackNo : getDevelopment.reportBackNo ? getDevelopment.reportBackNo : null ,
reportBackNoDate : getDevelopment.reportBackNoDate ? getDevelopment.reportBackNoDate : null ,
reportBackDate : getDevelopment.reportBackDate ? getDevelopment.reportBackDate : null ,
degreeLevel : getDevelopment.degreeLevel ? getDevelopment.degreeLevel : null ,
course : getDevelopment.course ? getDevelopment.course : null ,
field : getDevelopment.field ? getDevelopment.field : null ,
faculty : getDevelopment.faculty ? getDevelopment.faculty : null ,
2024-04-09 16:30:29 +07:00
educationalInstitution : getDevelopment.educationalInstitution
? getDevelopment . educationalInstitution
: null ,
2024-04-05 10:24:19 +07:00
startDate : getDevelopment.startDate ? getDevelopment.startDate : null ,
endDate : getDevelopment.endDate ? getDevelopment.endDate : null ,
studyPlace : getDevelopment.studyPlace ? getDevelopment.studyPlace : null ,
studyTopic : getDevelopment.studyTopic ? getDevelopment.studyTopic : null ,
studyStartDate : getDevelopment.studyStartDate ? getDevelopment.studyStartDate : null ,
studyEndDate : getDevelopment.studyEndDate ? getDevelopment.studyEndDate : null ,
studyCountry : getDevelopment.studyCountry ? getDevelopment.studyCountry : null ,
studyAbroadTopic : getDevelopment.studyAbroadTopic ? getDevelopment.studyAbroadTopic : null ,
2024-04-09 16:30:29 +07:00
studyAbroadStartDate : getDevelopment.studyAbroadStartDate
? getDevelopment . studyAbroadStartDate
: null ,
studyAbroadEndDate : getDevelopment.studyAbroadEndDate
? getDevelopment . studyAbroadEndDate
: null ,
totalPeriod : getDevelopment.totalPeriod ? getDevelopment.totalPeriod : null ,
2024-04-09 21:59:23 +07:00
status : getDevelopment.status ? getDevelopment.status : null ,
2024-04-11 11:39:56 +07:00
profileId : getDevelopment.profileId ? getDevelopment.profileId : null ,
2024-04-11 16:32:44 +07:00
planType : getDevelopment.planType ? getDevelopment.planType : null ,
isNoUseBudget : getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null ,
2025-04-22 16:27:56 +07:00
budgetSourceOther : getDevelopment.budgetSourceOther ? getDevelopment.budgetSourceOther : null ,
2024-04-05 10:24:19 +07:00
} ;
return new HttpSuccess ( formattedData ) ;
2024-04-04 19:59:28 +07:00
}
2024-04-09 21:59:23 +07:00
2024-04-11 16:32:44 +07:00
/ * *
* API ร า ย ก า ร ท ุ น ข อ ง user
*
* @summary DEV_0 - ร า ย ก า ร ท ุ น ข อ ง user #
*
* @param { string } profileId profileId ข ้ า ร า ช ก า ร ฯ ท ี ่ ไ ด ้ ร ั บ ท ุ น ก า ร ศ ึ ก ษ า
* /
@Get ( "user/{profileId}" )
2024-04-19 09:28:57 +07:00
async GetDevelopemtScholarshipUserById (
@Path ( ) profileId : string ,
@Query ( "type" ) type ? : string | null ,
@Query ( "year" ) year? : number | null ,
) {
const getDevelopment = await AppDataSource . getRepository ( DevelopmentScholarship )
. createQueryBuilder ( "developmentScholarship" )
. andWhere ( "developmentScholarship.profileId = :profileId" , { profileId : profileId } )
. andWhere (
year !== 0 && year != null && year != undefined
? "developmentScholarship.scholarshipYear = :scholarshipYear"
: "1=1" ,
{ scholarshipYear : year } ,
)
. andWhere (
type != null && type != undefined
? "developmentScholarship.scholarshipType = :scholarshipType"
: "1=1" ,
{ scholarshipType : type } ,
)
. select ( [ "id" , "scholarshipYear" , "scholarshipYear" , "scholarshipType" , "fundType" ] )
2024-11-27 15:35:04 +07:00
. orderBy ( "developmentScholarship.createdAt" , "DESC" )
2024-04-19 09:28:57 +07:00
. getRawMany ( ) ;
2024-04-11 16:32:44 +07:00
2024-04-19 09:28:57 +07:00
return new HttpSuccess ( getDevelopment ) ;
2024-04-11 16:32:44 +07:00
}
2025-04-23 09:27:31 +07:00
/ * *
* API ร า ย ล ะ เ อ ี ย ด ท ุ น ข อ ง admin
*
* @summary DEV_0 - ร า ย ล ะ เ อ ี ย ด ท ุ น ข อ ง admin #
*
* @param { string } id id ร า ย ก า ร
* /
@Get ( "admin/detail/{id}" )
2025-06-16 21:34:15 +07:00
async GetDevelopemtScholarshipUserDetailAdminById (
@Request ( ) request : RequestWithUser ,
@Path ( ) id : string ,
) {
2025-04-23 09:27:31 +07:00
let _workflow = await new permission ( ) . Workflow ( request , id , "SYS_DEV_SCHOLARSHIP" ) ;
if ( _workflow == false ) await new permission ( ) . PermissionGet ( request , "SYS_DEV_SCHOLARSHIP" ) ;
const getDevelopment = await this . developmentScholarshipRepository . findOne ( {
where : { id : id } ,
select : [
"id" ,
"scholarshipYear" ,
"scholarshipType" ,
"fundType" ,
"bookNumber" ,
"bookDate" ,
"governmentDate" ,
"governmentEndDate" ,
"isGraduated" ,
"graduatedDate" ,
"graduatedReason" ,
"org" ,
] ,
} ) ;
if ( ! getDevelopment ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้" ) ;
}
return new HttpSuccess ( getDevelopment ) ;
}
2024-04-11 16:32:44 +07:00
/ * *
* API ร า ย ล ะ เ อ ี ย ด ท ุ น ข อ ง user
*
* @summary DEV_0 - ร า ย ล ะ เ อ ี ย ด ท ุ น ข อ ง user #
*
* @param { string } id id ร า ย ก า ร
* /
@Get ( "user/detail/{id}" )
async GetDevelopemtScholarshipUserDetailById ( @Path ( ) id : string ) {
const getDevelopment = await this . developmentScholarshipRepository . findOne ( {
where : { id : id } ,
select : [
"id" ,
"scholarshipYear" ,
"scholarshipType" ,
"fundType" ,
2024-04-17 13:42:26 +07:00
"bookNumber" ,
"bookDate" ,
2024-04-11 16:32:44 +07:00
"governmentDate" ,
2024-04-17 13:42:26 +07:00
"governmentEndDate" ,
2024-04-11 16:32:44 +07:00
"isGraduated" ,
"graduatedDate" ,
"graduatedReason" ,
2024-04-17 17:31:07 +07:00
"org" ,
2024-04-11 16:32:44 +07:00
] ,
} ) ;
if ( ! getDevelopment ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้" ) ;
}
return new HttpSuccess ( getDevelopment ) ;
}
/ * *
* API แ ก ้ ไ ข ร า ย ก า ร ท ุ น ข อ ง user
*
* @summary DEV_015 - แ ก ้ ไ ข ร า ย ก า ร ท ุ น ข อ ง user # 15
*
* @param { string } id ร า ย ก า ร
* /
@Put ( "user/detail/{id}" )
async UpdateDevelopemtScholarshipUserById (
@Path ( ) id : string ,
@Body ( ) requestBody : UpdateDevelopmentScholarshipUser ,
2024-07-25 17:06:42 +07:00
@Request ( ) request : RequestWithUser ,
2024-04-11 16:32:44 +07:00
) {
2024-08-30 14:17:29 +07:00
// await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP");
2024-04-11 16:32:44 +07:00
const getDevelopment = await this . developmentScholarshipRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! getDevelopment ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้" ) ;
}
2024-07-25 17:06:42 +07:00
const before = structuredClone ( getDevelopment ) ;
2024-04-11 16:32:44 +07:00
Object . assign ( getDevelopment , requestBody ) ;
getDevelopment . lastUpdateUserId = request . user . sub ;
getDevelopment . lastUpdateFullName = request . user . name ;
2024-09-03 14:59:53 +07:00
getDevelopment . lastUpdatedAt = new Date ( ) ;
2024-07-25 17:06:42 +07:00
await this . developmentScholarshipRepository . save ( getDevelopment , { data : request } ) ;
2025-04-23 09:27:31 +07:00
setLogDataDiff ( request , { before , after : getDevelopment } ) ;
return new HttpSuccess ( getDevelopment . id ) ;
}
/ * *
* API แ ก ้ ไ ข ร า ย ก า ร ท ุ น ข อ ง admin
*
* @summary DEV_015 - แ ก ้ ไ ข ร า ย ก า ร ท ุ น ข อ ง admin # 15
*
* @param { string } id ร า ย ก า ร
* /
@Put ( "admin/detail/{id}" )
async UpdateDevelopemtScholarshipAdminById (
@Path ( ) id : string ,
@Body ( ) requestBody : UpdateDevelopmentScholarshipUser ,
@Request ( ) request : RequestWithUser ,
) {
await new permission ( ) . PermissionUpdate ( request , "SYS_DEV_SCHOLARSHIP" ) ;
const getDevelopment = await this . developmentScholarshipRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! getDevelopment ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้" ) ;
}
const before = structuredClone ( getDevelopment ) ;
Object . assign ( getDevelopment , requestBody ) ;
getDevelopment . lastUpdateUserId = request . user . sub ;
getDevelopment . lastUpdateFullName = request . user . name ;
getDevelopment . lastUpdatedAt = new Date ( ) ;
await this . developmentScholarshipRepository . save ( getDevelopment , { data : request } ) ;
2024-07-25 17:06:42 +07:00
setLogDataDiff ( request , { before , after : getDevelopment } ) ;
2024-04-11 16:32:44 +07:00
return new HttpSuccess ( getDevelopment . id ) ;
}
2024-04-09 21:59:23 +07:00
/ * *
* API เ ป ล ี ่ ย น ส ถ า น ะ
*
* @summary DEV_0 - เ ป ล ี ่ ย น ส ถ า น ะ #
*
2024-04-10 11:53:25 +07:00
* @param { string } id Id ข ้ า ร า ช ก า ร ฯ ท ี ่ ไ ด ้ ร ั บ ท ุ น ก า ร ศ ึ ก ษ า
2024-04-09 21:59:23 +07:00
* @param { string } status status ส ถ า น ะ
* /
@Get ( "status/{id}/{status}" )
2024-04-10 11:53:25 +07:00
async ChangeStatusDevelopemtScholarshipById (
@Path ( ) id : string ,
@Path ( ) status : string ,
2024-07-25 17:06:42 +07:00
@Request ( ) request : RequestWithUser ,
2024-04-10 11:53:25 +07:00
) {
2024-04-09 21:59:23 +07:00
const getDevelopment = await this . developmentScholarshipRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! getDevelopment ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้" ) ;
}
const _status = status . trim ( ) . toUpperCase ( ) ;
getDevelopment . status = _status ;
2024-04-11 16:32:44 +07:00
getDevelopment . lastUpdateUserId = request . user . sub ;
getDevelopment . lastUpdateFullName = request . user . name ;
2024-05-03 17:38:39 +07:00
let scholarshipType = "" ;
2024-04-09 21:59:23 +07:00
if ( _status == "GRADUATE" ) {
2024-04-10 11:53:25 +07:00
if ( getDevelopment . scholarshipType != null ) {
switch ( getDevelopment . scholarshipType . trim ( ) . toUpperCase ( ) ) {
case "DOMESTICE" :
2024-05-03 17:38:39 +07:00
scholarshipType = "การศึกษาในประเทศ" ;
2024-04-10 11:53:25 +07:00
break ;
case "NOABROAD" :
2024-05-03 17:38:39 +07:00
scholarshipType =
2024-04-10 11:53:25 +07:00
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)" ;
break ;
case "ABROAD" :
2024-05-03 17:38:39 +07:00
scholarshipType =
2024-04-10 11:53:25 +07:00
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)" ;
break ;
case "EXECUTIVE" :
2024-05-03 17:38:39 +07:00
scholarshipType =
2024-04-10 11:53:25 +07:00
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)" ;
break ;
default :
break ;
}
}
2024-05-03 17:38:39 +07:00
let profileEdu = await new CallAPI ( )
2024-07-10 10:45:01 +07:00
. PostData ( request , "/org/profile/educations" , {
2024-05-03 17:38:39 +07:00
profileId : getDevelopment.profileId ,
institute : getDevelopment.educationalInstitution ,
startDate : getDevelopment.startDate ,
endDate : getDevelopment.endDate ,
finishDate : null ,
isEducation : false ,
degree : null ,
field : getDevelopment.field ,
fundName : 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 ,
} )
. then ( async ( x ) = > {
2024-07-25 17:06:42 +07:00
await this . developmentScholarshipRepository . save ( getDevelopment , { data : request } ) ;
2024-05-03 17:38:39 +07:00
} )
. catch ( ( error ) = > {
console . error ( "ไม่สามารถบันทึกลงทะเบียนประวัติได้" ) ;
} ) ;
2024-04-09 21:59:23 +07:00
} else if ( _status == "NOTGRADUATE" ) {
2024-05-03 17:38:39 +07:00
getDevelopment . status = _status ;
2024-09-03 14:59:53 +07:00
getDevelopment . lastUpdateUserId = request . user . sub ;
getDevelopment . lastUpdateFullName = request . user . name ;
getDevelopment . lastUpdatedAt = new Date ( ) ;
2024-07-25 17:06:42 +07:00
await this . developmentScholarshipRepository . save ( getDevelopment , { data : request } ) ;
2024-04-09 21:59:23 +07:00
} else {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบสถานะนี้ในระบบ" ) ;
}
return new HttpSuccess ( ) ;
}
2024-04-04 18:05:18 +07:00
}