fix #857
This commit is contained in:
parent
a648fb3f24
commit
964e938bb2
5 changed files with 49 additions and 24 deletions
|
|
@ -360,10 +360,18 @@ 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: {
|
||||||
|
development:{
|
||||||
|
developmentOthers: {
|
||||||
|
createdAt: "ASC"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (!getDevelopment) {
|
if (!getDevelopment) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
|
||||||
|
|
@ -408,6 +416,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
|
||||||
}))
|
}))
|
||||||
: [],
|
: [],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ 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")
|
||||||
|
|
@ -321,9 +322,10 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
||||||
const formattedData = development.map((item) => ({
|
const formattedData = development.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
citizenId: item.citizenId,
|
citizenId: item.citizenId,
|
||||||
fullName: item.prefix == null && item.firstName == null && item.lastName == null
|
fullName:
|
||||||
? ""
|
item.prefix == null && item.firstName == null && item.lastName == null
|
||||||
: `${item?.prefix}${item?.firstName} ${item?.lastName}`,
|
? ""
|
||||||
|
: `${item?.prefix}${item?.firstName} ${item?.lastName}`,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
year: item.development.year,
|
year: item.development.year,
|
||||||
root: item.development.root, //test
|
root: item.development.root, //test
|
||||||
|
|
@ -350,8 +352,21 @@ 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: ["development", "development.developmentOthers","posLevel", "posType"],
|
relations: [
|
||||||
|
"development",
|
||||||
|
"development.developmentOthers",
|
||||||
|
"development.developmentOthers.province",
|
||||||
|
"posLevel",
|
||||||
|
"posType",
|
||||||
|
],
|
||||||
where: { id: id, type: type },
|
where: { id: id, type: type },
|
||||||
|
order: {
|
||||||
|
development: {
|
||||||
|
developmentOthers: {
|
||||||
|
createdAt: "ASC",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!getDevelopment) {
|
if (!getDevelopment) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
|
||||||
|
|
@ -389,12 +404,13 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
||||||
getDevelopment.development != null ? getDevelopment.development.dateStudyStart : null,
|
getDevelopment.development != null ? getDevelopment.development.dateStudyStart : null,
|
||||||
dateStudyEnd:
|
dateStudyEnd:
|
||||||
getDevelopment.development != null ? getDevelopment.development.dateStudyEnd : null,
|
getDevelopment.development != null ? getDevelopment.development.dateStudyEnd : null,
|
||||||
academic: getDevelopment.development?.developmentOthers
|
academic: getDevelopment.development?.developmentOthers
|
||||||
? 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,
|
||||||
: []
|
}))
|
||||||
|
: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
return new HttpSuccess(formattedData);
|
return new HttpSuccess(formattedData);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ export class DevelopmentOther extends EntityBase {
|
||||||
development: Development;
|
development: Development;
|
||||||
|
|
||||||
@ManyToOne(() => Province, (province: Province) => province.developmentOthers)
|
@ManyToOne(() => Province, (province: Province) => province.developmentOthers)
|
||||||
@JoinColumn({ name: "developmentId" })
|
@JoinColumn({ name: "provinceActualId" })
|
||||||
province: Province;
|
province: Province;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class UpdateDevorderAddRelationProvince1734583427091 implements MigrationInterface {
|
|
||||||
name = 'UpdateDevorderAddRelationProvince1734583427091'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD CONSTRAINT \`FK_d5dfdb7ca0d11c0cdf3b3a55e6f\` FOREIGN KEY (\`developmentId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP FOREIGN KEY \`FK_d5dfdb7ca0d11c0cdf3b3a55e6f\``);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateDevelopmentAddRelationProvince1734586571465 implements MigrationInterface {
|
||||||
|
name = 'UpdateDevelopmentAddRelationProvince1734586571465'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD CONSTRAINT \`FK_47bbbecaea9b7b31d2536054656\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP FOREIGN KEY \`FK_47bbbecaea9b7b31d2536054656\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue