Merge branch 'develop' into adiDev
This commit is contained in:
commit
9c8fb66601
10 changed files with 182 additions and 83 deletions
102
.onedev-buildspec.yml
Normal file
102
.onedev-buildspec.yml
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
version: 37
|
||||||
|
jobs:
|
||||||
|
- name: CI for UAT
|
||||||
|
steps:
|
||||||
|
- !CheckoutStep
|
||||||
|
name: checkout code
|
||||||
|
cloneCredential: !DefaultCredential {}
|
||||||
|
withLfs: false
|
||||||
|
withSubmodules: false
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !GenerateChecksumStep
|
||||||
|
name: generate package checksum
|
||||||
|
files: package-lock.json yarn.lock
|
||||||
|
targetFile: checksum
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !SetupCacheStep
|
||||||
|
name: set up npm cache
|
||||||
|
key: node_modules_@file:checksum@
|
||||||
|
loadKeys:
|
||||||
|
- node_modules
|
||||||
|
paths:
|
||||||
|
- node_modules
|
||||||
|
uploadStrategy: UPLOAD_IF_NOT_HIT
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !SetBuildVersionStep
|
||||||
|
name: set build version
|
||||||
|
buildVersion: '@tag@'
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !CommandStep
|
||||||
|
name: build & test
|
||||||
|
runInContainer: true
|
||||||
|
image: node
|
||||||
|
interpreter: !DefaultInterpreter
|
||||||
|
commands: |
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
useTTY: true
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !BuildImageStep
|
||||||
|
name: build docker image
|
||||||
|
dockerfile: ./docker/Dockerfile
|
||||||
|
output: !RegistryOutput
|
||||||
|
tags: hrms-git.chin.in.th/bma-hrms/hrms-api-dev:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-dev:latest
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
triggers:
|
||||||
|
- !TagCreateTrigger
|
||||||
|
tags: uat-*
|
||||||
|
branches: main
|
||||||
|
retryCondition: never
|
||||||
|
maxRetries: 3
|
||||||
|
retryDelay: 30
|
||||||
|
timeout: 14400
|
||||||
|
- name: CI for PROD
|
||||||
|
steps:
|
||||||
|
- !CheckoutStep
|
||||||
|
name: checkout code
|
||||||
|
cloneCredential: !DefaultCredential {}
|
||||||
|
withLfs: false
|
||||||
|
withSubmodules: false
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !GenerateChecksumStep
|
||||||
|
name: generate package checksum
|
||||||
|
files: package-lock.json yarn.lock
|
||||||
|
targetFile: checksum
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !SetupCacheStep
|
||||||
|
name: set up npm cache
|
||||||
|
key: node_modules_@file:checksum@
|
||||||
|
loadKeys:
|
||||||
|
- node_modules
|
||||||
|
paths:
|
||||||
|
- node_modules
|
||||||
|
uploadStrategy: UPLOAD_IF_NOT_HIT
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !SetBuildVersionStep
|
||||||
|
name: set build version
|
||||||
|
buildVersion: '@tag@'
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !CommandStep
|
||||||
|
name: build & test
|
||||||
|
runInContainer: true
|
||||||
|
image: node
|
||||||
|
interpreter: !DefaultInterpreter
|
||||||
|
commands: |
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
useTTY: true
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
- !BuildImageStep
|
||||||
|
name: build docker image
|
||||||
|
dockerfile: ./docker/Dockerfile
|
||||||
|
output: !RegistryOutput
|
||||||
|
tags: hrms-git.bangkok.go.th/bma-hrms/hrms-api-dev:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-api-dev:latest
|
||||||
|
condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
|
||||||
|
triggers:
|
||||||
|
- !TagCreateTrigger
|
||||||
|
tags: prod-*
|
||||||
|
branches: main
|
||||||
|
retryCondition: never
|
||||||
|
maxRetries: 3
|
||||||
|
retryDelay: 30
|
||||||
|
timeout: 14400
|
||||||
|
|
@ -32,7 +32,6 @@ import { ActualPeople, CreateActualPeople } from "../entities/ActualPeople";
|
||||||
import { CreatePlannedPeople, PlannedPeople } from "../entities/PlannedPeople";
|
import { CreatePlannedPeople, PlannedPeople } from "../entities/PlannedPeople";
|
||||||
import { ActualGoal, CreateActualGoal } from "../entities/ActualGoal";
|
import { ActualGoal, CreateActualGoal } from "../entities/ActualGoal";
|
||||||
import { CreatePlannedGoal, PlannedGoal } from "../entities/PlannedGoal";
|
import { CreatePlannedGoal, PlannedGoal } from "../entities/PlannedGoal";
|
||||||
import { Province } from "../entities/Province";
|
|
||||||
import { PosType } from "../entities/PosType";
|
import { PosType } from "../entities/PosType";
|
||||||
import { PosLevel } from "../entities/PosLevel";
|
import { PosLevel } from "../entities/PosLevel";
|
||||||
import { PlannedGoalPosition } from "../entities/PlannedGoalPosition";
|
import { PlannedGoalPosition } from "../entities/PlannedGoalPosition";
|
||||||
|
|
@ -83,7 +82,6 @@ export class DevelopmentController extends Controller {
|
||||||
private actualGoalRepository = AppDataSource.getRepository(ActualGoal);
|
private actualGoalRepository = AppDataSource.getRepository(ActualGoal);
|
||||||
private plannedGoalRepository = AppDataSource.getRepository(PlannedGoal);
|
private plannedGoalRepository = AppDataSource.getRepository(PlannedGoal);
|
||||||
private plannedGoalPositionRepository = AppDataSource.getRepository(PlannedGoalPosition);
|
private plannedGoalPositionRepository = AppDataSource.getRepository(PlannedGoalPosition);
|
||||||
private provinceRepository = AppDataSource.getRepository(Province);
|
|
||||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||||
private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1);
|
private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1);
|
||||||
|
|
@ -1224,19 +1222,14 @@ export class DevelopmentController extends Controller {
|
||||||
// const before = structuredClone(development);
|
// const before = structuredClone(development);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
requestBody.developmentAddresss.map(async (x) => {
|
requestBody.developmentAddresss.map(async (x) => {
|
||||||
let _null: any = null;
|
|
||||||
const data = Object.assign(new DevelopmentAddress(), x);
|
const data = Object.assign(new DevelopmentAddress(), x);
|
||||||
if (x.provinceId != null) {
|
|
||||||
const chkProvince = await this.provinceRepository.findOne({
|
|
||||||
where: {
|
|
||||||
id: x.provinceId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (chkProvince == null) {
|
|
||||||
data.provinceId = _null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (x.address) {
|
if (x.address) {
|
||||||
|
await new CallAPI()
|
||||||
|
.GetData(request, `/org/metadata/province/${x.provinceId}`)
|
||||||
|
.then(async (item) => {
|
||||||
|
data.provinceName = item.name;
|
||||||
|
})
|
||||||
|
.catch(async (x) => {});
|
||||||
data.developmentId = development.id;
|
data.developmentId = development.id;
|
||||||
data.createdUserId = request.user.sub;
|
data.createdUserId = request.user.sub;
|
||||||
data.createdFullName = request.user.name;
|
data.createdFullName = request.user.name;
|
||||||
|
|
@ -1433,16 +1426,14 @@ export class DevelopmentController extends Controller {
|
||||||
if (!development) {
|
if (!development) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||||
}
|
}
|
||||||
if (requestBody.provinceActualId != null) {
|
|
||||||
const checkId = await this.provinceRepository.findOne({
|
|
||||||
where: { id: requestBody.provinceActualId },
|
|
||||||
});
|
|
||||||
if (!checkId) {
|
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลจังหวัดข้อมูลด้านวิชาการ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const before = structuredClone(development);
|
const before = structuredClone(development);
|
||||||
const data = Object.assign(new DevelopmentOther(), requestBody);
|
const data = Object.assign(new DevelopmentOther(), requestBody);
|
||||||
|
await new CallAPI()
|
||||||
|
.GetData(request, `/org/metadata/province/${requestBody.provinceActualId}`)
|
||||||
|
.then(async (item) => {
|
||||||
|
data.provinceActualName = item.name;
|
||||||
|
})
|
||||||
|
.catch(async (x) => {});
|
||||||
data.createdUserId = request.user.sub;
|
data.createdUserId = request.user.sub;
|
||||||
data.createdFullName = request.user.name;
|
data.createdFullName = request.user.name;
|
||||||
data.lastUpdateUserId = request.user.sub;
|
data.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -1496,6 +1487,12 @@ export class DevelopmentController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความเสี่ยงของโครงการ");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความเสี่ยงของโครงการ");
|
||||||
}
|
}
|
||||||
Object.assign(development, requestBody);
|
Object.assign(development, requestBody);
|
||||||
|
await new CallAPI()
|
||||||
|
.GetData(request, `/org/metadata/province/${requestBody.provinceActualId}`)
|
||||||
|
.then(async (item) => {
|
||||||
|
development.provinceActualName = item.name;
|
||||||
|
})
|
||||||
|
.catch(async (x) => {});
|
||||||
development.lastUpdateUserId = request.user.sub;
|
development.lastUpdateUserId = request.user.sub;
|
||||||
development.lastUpdateFullName = request.user.name;
|
development.lastUpdateFullName = request.user.name;
|
||||||
development.lastUpdatedAt = new Date();
|
development.lastUpdatedAt = new Date();
|
||||||
|
|
@ -1944,7 +1941,7 @@ export class DevelopmentController extends Controller {
|
||||||
})
|
})
|
||||||
.andWhere(
|
.andWhere(
|
||||||
keyword != undefined
|
keyword != undefined
|
||||||
? new Brackets ((qb) => {
|
? new Brackets((qb) => {
|
||||||
qb.where("development.projectName LIKE :keyword")
|
qb.where("development.projectName LIKE :keyword")
|
||||||
.orWhere("development.root LIKE :keyword")
|
.orWhere("development.root LIKE :keyword")
|
||||||
.orWhere("development.child1 LIKE :keyword")
|
.orWhere("development.child1 LIKE :keyword")
|
||||||
|
|
@ -2554,9 +2551,9 @@ export class DevelopmentController extends Controller {
|
||||||
reasonDevelopment70: x.development.reasonActual70,
|
reasonDevelopment70: x.development.reasonActual70,
|
||||||
reasonDevelopment20: x.development.reasonActual20,
|
reasonDevelopment20: x.development.reasonActual20,
|
||||||
reasonDevelopment10: x.development.reasonActual10,
|
reasonDevelopment10: x.development.reasonActual10,
|
||||||
isDevelopment70: false,
|
isDevelopment70: x.development.isReasonActual70,
|
||||||
isDevelopment20: false,
|
isDevelopment20: x.development.isReasonActual20,
|
||||||
isDevelopment10: false,
|
isDevelopment10: x.development.isReasonActual10,
|
||||||
developmentTarget: null,
|
developmentTarget: null,
|
||||||
developmentResults: null,
|
developmentResults: null,
|
||||||
developmentReport: null,
|
developmentReport: null,
|
||||||
|
|
@ -2610,7 +2607,7 @@ export class DevelopmentController extends Controller {
|
||||||
async developmentDetail(
|
async developmentDetail(
|
||||||
@Path() developmentId: string,
|
@Path() developmentId: string,
|
||||||
@Path() type: string,
|
@Path() type: string,
|
||||||
@Request() request: RequestWithUser
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const getDevelopment = await this.developmentRepository.findOne({
|
const getDevelopment = await this.developmentRepository.findOne({
|
||||||
where: { id: developmentId },
|
where: { id: developmentId },
|
||||||
|
|
@ -2625,13 +2622,17 @@ export class DevelopmentController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||||
|
|
||||||
if (type.trim().toLocaleUpperCase() == "OFFICER") {
|
if (type.trim().toLocaleUpperCase() == "OFFICER") {
|
||||||
let _workflow = await new permission().Workflow(request, developmentId, "SYS_REGISTRY_OFFICER");
|
let _workflow = await new permission().Workflow(
|
||||||
|
request,
|
||||||
|
developmentId,
|
||||||
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
);
|
||||||
if (_workflow == false) await new permission().PermissionGet(request, "SYS_REGISTRY_OFFICER");
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_REGISTRY_OFFICER");
|
||||||
} else if (type.trim().toLocaleUpperCase() == "USER") {
|
} else if (type.trim().toLocaleUpperCase() == "USER") {
|
||||||
} else {
|
} else {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้");
|
||||||
}
|
}
|
||||||
|
|
||||||
let _getDevelopment: any = {
|
let _getDevelopment: any = {
|
||||||
id: getDevelopment.id,
|
id: getDevelopment.id,
|
||||||
evaluationId: null,
|
evaluationId: null,
|
||||||
|
|
@ -2651,7 +2652,7 @@ export class DevelopmentController extends Controller {
|
||||||
selectType: "PROJECT",
|
selectType: "PROJECT",
|
||||||
selectTypeYear: getDevelopment.year,
|
selectTypeYear: getDevelopment.year,
|
||||||
selectTypeId: null,
|
selectTypeId: null,
|
||||||
developmentProjects : getDevelopment.developmentProjectTechniqueActuals
|
developmentProjects: getDevelopment.developmentProjectTechniqueActuals
|
||||||
.map((x) => x.name)
|
.map((x) => x.name)
|
||||||
.sort(),
|
.sort(),
|
||||||
};
|
};
|
||||||
|
|
@ -2698,11 +2699,12 @@ export class DevelopmentController extends Controller {
|
||||||
if (oldProfile.isDone == true) return;
|
if (oldProfile.isDone == true) return;
|
||||||
}
|
}
|
||||||
if (item["ประเภท"] == undefined) return;
|
if (item["ประเภท"] == undefined) return;
|
||||||
|
let development = Object.assign(new DevelopmentHistory(), oldProfile);
|
||||||
if (item["ประเภท"] == "ข้าราชการกรุงเทพมหานครสามัญ" || item["ประเภท"] == "ขรก.กทม. สามัญ") {
|
if (item["ประเภท"] == "ข้าราชการกรุงเทพมหานครสามัญ" || item["ประเภท"] == "ขรก.กทม. สามัญ") {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.GetData(request, `/org/unauthorize/officer/citizen/${item["รหัสประจำตัวประชาชน"]}`)
|
.GetData(request, `/org/unauthorize/officer/citizen/${item["รหัสประจำตัวประชาชน"]}`)
|
||||||
.then(async (x: any) => {
|
.then(async (x: any) => {
|
||||||
let development = Object.assign(new DevelopmentHistory(), x);
|
development = Object.assign(development, x);
|
||||||
development.dateStart =
|
development.dateStart =
|
||||||
item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"];
|
item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"];
|
||||||
development.dateEnd =
|
development.dateEnd =
|
||||||
|
|
@ -2738,7 +2740,6 @@ export class DevelopmentController extends Controller {
|
||||||
setLogDataDiff(request, { before, after: development });
|
setLogDataDiff(request, { before, after: development });
|
||||||
})
|
})
|
||||||
.catch(async (x) => {
|
.catch(async (x) => {
|
||||||
let development = new DevelopmentHistory();
|
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
development.prefix = item["คำนำหน้า"] == undefined ? null : item["คำนำหน้า"];
|
development.prefix = item["คำนำหน้า"] == undefined ? null : item["คำนำหน้า"];
|
||||||
development.firstName = item["ชื่อ"] == undefined ? null : item["ชื่อ"];
|
development.firstName = item["ชื่อ"] == undefined ? null : item["ชื่อ"];
|
||||||
|
|
@ -2784,12 +2785,9 @@ export class DevelopmentController extends Controller {
|
||||||
});
|
});
|
||||||
} else if (item["ประเภท"] == "ลูกจ้างประจำ") {
|
} else if (item["ประเภท"] == "ลูกจ้างประจำ") {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.GetData(
|
.GetData(request, `/org/unauthorize/employee/citizen/${item["รหัสประจำตัวประชาชน"]}`)
|
||||||
request,
|
|
||||||
`/org/unauthorize/employee-prem/citizen/${item["รหัสประจำตัวประชาชน"]}`,
|
|
||||||
)
|
|
||||||
.then(async (x: any) => {
|
.then(async (x: any) => {
|
||||||
let development = Object.assign(new DevelopmentHistory(), x);
|
development = Object.assign(development, x);
|
||||||
development.dateStart =
|
development.dateStart =
|
||||||
item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"];
|
item["วันที่เริ่มต้น"] == undefined ? null : item["วันที่เริ่มต้น"];
|
||||||
development.dateEnd =
|
development.dateEnd =
|
||||||
|
|
@ -2825,7 +2823,6 @@ export class DevelopmentController extends Controller {
|
||||||
setLogDataDiff(request, { before, after: development });
|
setLogDataDiff(request, { before, after: development });
|
||||||
})
|
})
|
||||||
.catch(async (x) => {
|
.catch(async (x) => {
|
||||||
let development = new DevelopmentHistory();
|
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
development.prefix = item["คำนำหน้า"] == undefined ? null : item["คำนำหน้า"];
|
development.prefix = item["คำนำหน้า"] == undefined ? null : item["คำนำหน้า"];
|
||||||
development.firstName = item["ชื่อ"] == undefined ? null : item["ชื่อ"];
|
development.firstName = item["ชื่อ"] == undefined ? null : item["ชื่อ"];
|
||||||
|
|
|
||||||
|
|
@ -360,18 +360,17 @@ export class DevelopmentEmployeeHistoryController extends Controller {
|
||||||
relations: [
|
relations: [
|
||||||
"development",
|
"development",
|
||||||
"development.developmentOthers",
|
"development.developmentOthers",
|
||||||
"development.developmentOthers.province",
|
|
||||||
"employeePosLevel",
|
"employeePosLevel",
|
||||||
"employeePosType",
|
"employeePosType",
|
||||||
],
|
],
|
||||||
where: { id: id, type: type },
|
where: { id: id, type: type },
|
||||||
order: {
|
order: {
|
||||||
development:{
|
development: {
|
||||||
developmentOthers: {
|
developmentOthers: {
|
||||||
createdAt: "ASC"
|
createdAt: "ASC",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
if (!getDevelopment) {
|
if (!getDevelopment) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
|
||||||
|
|
@ -416,7 +415,7 @@ export class DevelopmentEmployeeHistoryController extends Controller {
|
||||||
? getDevelopment.development.developmentOthers.map((dev) => ({
|
? getDevelopment.development.developmentOthers.map((dev) => ({
|
||||||
topicAcademic: dev.topicAcademic,
|
topicAcademic: dev.topicAcademic,
|
||||||
addressAcademic: dev.addressAcademic,
|
addressAcademic: dev.addressAcademic,
|
||||||
province: dev.province.name
|
province: dev.provinceActualName,
|
||||||
}))
|
}))
|
||||||
: [],
|
: [],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ import { PosLevel } from "../entities/PosLevel";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { Province } from "../entities/Province";
|
|
||||||
|
|
||||||
@Route("api/v1/development/history/officer")
|
@Route("api/v1/development/history/officer")
|
||||||
@Tags("DevelopmentOfficerHistory")
|
@Tags("DevelopmentOfficerHistory")
|
||||||
|
|
@ -352,13 +351,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
||||||
await new permission().PermissionGet(request, "SYS_DEV_HISTORY_OFFICER");
|
await new permission().PermissionGet(request, "SYS_DEV_HISTORY_OFFICER");
|
||||||
const type = "OFFICER";
|
const type = "OFFICER";
|
||||||
const getDevelopment = await this.developmentHistoryRepository.findOne({
|
const getDevelopment = await this.developmentHistoryRepository.findOne({
|
||||||
relations: [
|
relations: ["development", "development.developmentOthers", "posLevel", "posType"],
|
||||||
"development",
|
|
||||||
"development.developmentOthers",
|
|
||||||
"development.developmentOthers.province",
|
|
||||||
"posLevel",
|
|
||||||
"posType",
|
|
||||||
],
|
|
||||||
where: { id: id, type: type },
|
where: { id: id, type: type },
|
||||||
order: {
|
order: {
|
||||||
development: {
|
development: {
|
||||||
|
|
@ -408,7 +401,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
||||||
? getDevelopment.development.developmentOthers.map((dev) => ({
|
? getDevelopment.development.developmentOthers.map((dev) => ({
|
||||||
topicAcademic: dev.topicAcademic,
|
topicAcademic: dev.topicAcademic,
|
||||||
addressAcademic: dev.addressAcademic,
|
addressAcademic: dev.addressAcademic,
|
||||||
province: dev.province.name,
|
province: dev.provinceActualName,
|
||||||
}))
|
}))
|
||||||
: [],
|
: [],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, Double } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, Double } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Province } from "./Province";
|
|
||||||
import { ActualPeople, CreateActualPeople } from "./ActualPeople";
|
import { ActualPeople, CreateActualPeople } from "./ActualPeople";
|
||||||
import { CreatePlannedPeople, PlannedPeople } from "./PlannedPeople";
|
import { CreatePlannedPeople, PlannedPeople } from "./PlannedPeople";
|
||||||
import { ActualGoal, CreateActualGoal } from "./ActualGoal";
|
import { ActualGoal, CreateActualGoal } from "./ActualGoal";
|
||||||
|
|
@ -566,10 +565,6 @@ export class Development extends EntityBase {
|
||||||
})
|
})
|
||||||
provinceActualId: string;
|
provinceActualId: string;
|
||||||
|
|
||||||
@ManyToOne(() => Province, (province: Province) => province.developmentActuals)
|
|
||||||
@JoinColumn({ name: "provinceActualId" })
|
|
||||||
provinceActual: Province;
|
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
type: "datetime",
|
type: "datetime",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Development } from "./Development";
|
import { Development } from "./Development";
|
||||||
import { Province } from "./Province";
|
|
||||||
|
|
||||||
@Entity("developmentAddress")
|
@Entity("developmentAddress")
|
||||||
export class DevelopmentAddress extends EntityBase {
|
export class DevelopmentAddress extends EntityBase {
|
||||||
|
|
@ -19,9 +18,12 @@ export class DevelopmentAddress extends EntityBase {
|
||||||
})
|
})
|
||||||
provinceId: string;
|
provinceId: string;
|
||||||
|
|
||||||
@ManyToOne(() => Province, (province: Province) => province.developmentAddresss)
|
@Column({
|
||||||
@JoinColumn({ name: "provinceId" })
|
nullable: true,
|
||||||
province: Province;
|
comment: "โครงการ/หลักสูตรการฝึกอบรม",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
provinceName: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Development } from "./Development";
|
import { Development } from "./Development";
|
||||||
import { Province } from "./Province";
|
|
||||||
|
|
||||||
@Entity("developmentOther")
|
@Entity("developmentOther")
|
||||||
export class DevelopmentOther extends EntityBase {
|
export class DevelopmentOther extends EntityBase {
|
||||||
|
|
@ -26,6 +25,13 @@ export class DevelopmentOther extends EntityBase {
|
||||||
})
|
})
|
||||||
provinceActualId: string;
|
provinceActualId: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "จังหวัด(ข้อมูลวิชาการ)",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
provinceActualName: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "คีย์นอก(FK)ของตาราง development",
|
comment: "คีย์นอก(FK)ของตาราง development",
|
||||||
|
|
@ -36,10 +42,6 @@ export class DevelopmentOther extends EntityBase {
|
||||||
@ManyToOne(() => Development, (development: Development) => development.developmentOthers)
|
@ManyToOne(() => Development, (development: Development) => development.developmentOthers)
|
||||||
@JoinColumn({ name: "developmentId" })
|
@JoinColumn({ name: "developmentId" })
|
||||||
development: Development;
|
development: Development;
|
||||||
|
|
||||||
@ManyToOne(() => Province, (province: Province) => province.developmentOthers)
|
|
||||||
@JoinColumn({ name: "provinceActualId" })
|
|
||||||
province: Province;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateDevelopmentOther {
|
export class UpdateDevelopmentOther {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Development } from "./Development";
|
import { Development } from "./Development";
|
||||||
import { Province } from "./Province";
|
|
||||||
|
|
||||||
@Entity("developmentRisk")
|
@Entity("developmentRisk")
|
||||||
export class DevelopmentRisk extends EntityBase {
|
export class DevelopmentRisk extends EntityBase {
|
||||||
|
|
@ -47,9 +46,9 @@ export class DevelopmentRisk extends EntityBase {
|
||||||
})
|
})
|
||||||
developmentId: string;
|
developmentId: string;
|
||||||
|
|
||||||
@ManyToOne(() => Development, (development: Development) => development.developmentRisks)
|
@ManyToOne(() => Development, (development: Development) => development.developmentRisks)
|
||||||
@JoinColumn({ name: "developmentId" })
|
@JoinColumn({ name: "developmentId" })
|
||||||
development: Development;
|
development: Development;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateDevelopmentRisk {
|
export class UpdateDevelopmentRisk {
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,6 @@ export class Province extends EntityBase {
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@OneToMany(
|
|
||||||
() => DevelopmentAddress,
|
|
||||||
(developmentAddress: DevelopmentAddress) => developmentAddress.province,
|
|
||||||
)
|
|
||||||
developmentAddresss: DevelopmentAddress[];
|
|
||||||
|
|
||||||
@OneToMany(() => Development, (development: Development) => development.provinceActual)
|
|
||||||
developmentActuals: Development[];
|
|
||||||
|
|
||||||
@OneToMany(() => DevelopmentOther, (developmentOther: DevelopmentOther) => developmentOther.province)
|
|
||||||
developmentOthers: Development[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateProvince {
|
export class CreateProvince {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateDeleteDevProvincename1737111015155 implements MigrationInterface {
|
||||||
|
name = 'UpdateDeleteDevProvincename1737111015155'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP FOREIGN KEY \`FK_e2721b3f440256b56ce83a04fb2\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP FOREIGN KEY \`FK_47bbbecaea9b7b31d2536054656\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_bdafbb824b88c3bdb73adf7f220\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`provinceName\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD \`provinceActualName\` varchar(255) NULL COMMENT 'จังหวัด(ข้อมูลวิชาการ)'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP COLUMN \`provinceActualName\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`provinceName\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_bdafbb824b88c3bdb73adf7f220\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD CONSTRAINT \`FK_47bbbecaea9b7b31d2536054656\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD CONSTRAINT \`FK_e2721b3f440256b56ce83a04fb2\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue