Merge branch 'develop'

This commit is contained in:
kittapath 2024-12-19 11:46:01 +07:00
commit 757783c96f
6 changed files with 68 additions and 16 deletions

View file

@ -91,6 +91,17 @@ export class DevelopmentController extends Controller {
private strategyChild4Repository = AppDataSource.getRepository(StrategyChild4);
private strategyChild5Repository = AppDataSource.getRepository(StrategyChild5);
/**
* API
*
* @summary
*
*/
@Get("clear-db")
async ClearDb() {
return new HttpSuccess();
}
/**
* API /
*

View file

@ -327,15 +327,17 @@ export class DevelopmentEmployeeHistoryController extends Controller {
const formattedData = development.map((item) => ({
id: item.id,
citizenId: item.citizenId,
fullName: item.prefix != null && item.firstName != null && item.lastName != null
? `${item?.prefix}${item?.firstName} ${item?.lastName}`
: "",
fullName:
item.prefix != null && item.firstName != null && item.lastName != null
? `${item?.prefix}${item?.firstName} ${item?.lastName}`
: "",
position: item.position,
year: item.development.year,
posType: item.employeePosType ? item.employeePosType.posTypeName : null,
posLevel: item.employeePosType && item.employeePosLevel
? `${item.employeePosType.posTypeShortName} ${item.employeePosLevel.posLevelName}`
: null,
posLevel:
item.employeePosType && item.employeePosLevel
? `${item.employeePosType.posTypeShortName} ${item.employeePosLevel.posLevelName}`
: null,
projectName: item.development.projectName,
}));
@ -355,7 +357,12 @@ export class DevelopmentEmployeeHistoryController extends Controller {
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_HISTORY_EMP");
const type = "EMPLOYEE";
const getDevelopment = await this.developmentHistoryRepository.findOne({
relations: ["development", "employeePosLevel", "employeePosType"],
relations: [
"development",
"development.developmentOthers",
"employeePosLevel",
"employeePosType",
],
where: { id: id, type: type },
});
if (!getDevelopment) {
@ -389,14 +396,20 @@ export class DevelopmentEmployeeHistoryController extends Controller {
dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null,
dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null,
totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null,
addressAcademic:
getDevelopment.development != null ? getDevelopment.development.addressAcademic : null,
topicAcademic:
getDevelopment.development != null ? getDevelopment.development.topicAcademic : null,
// addressAcademic:
// getDevelopment.development != null ? getDevelopment.development.addressAcademic : null,
// topicAcademic:
// getDevelopment.development != null ? getDevelopment.development.topicAcademic : null,
dateStudyStart:
getDevelopment.development != null ? getDevelopment.development.dateStudyStart : null,
dateStudyEnd:
getDevelopment.development != null ? getDevelopment.development.dateStudyEnd : null,
academic: getDevelopment.development?.developmentOthers
? getDevelopment.development.developmentOthers.map((dev) => ({
topicAcademic: dev.topicAcademic,
addressAcademic: dev.addressAcademic,
}))
: [],
};
return new HttpSuccess(formattedData);

View file

@ -350,7 +350,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
await new permission().PermissionGet(request, "SYS_DEV_HISTORY_OFFICER");
const type = "OFFICER";
const getDevelopment = await this.developmentHistoryRepository.findOne({
relations: ["development", "posLevel", "posType"],
relations: ["development", "development.developmentOthers","posLevel", "posType"],
where: { id: id, type: type },
});
if (!getDevelopment) {
@ -381,14 +381,20 @@ export class DevelopmentOfficerHistoryController extends Controller {
dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null,
dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null,
totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null,
addressAcademic:
getDevelopment.development != null ? getDevelopment.development.addressAcademic : null,
topicAcademic:
getDevelopment.development != null ? getDevelopment.development.topicAcademic : null,
// addressAcademic:
// getDevelopment.development != null ? getDevelopment.development.addressAcademic : null,
// topicAcademic:
// getDevelopment.development != null ? getDevelopment.development.topicAcademic : null,
dateStudyStart:
getDevelopment.development != null ? getDevelopment.development.dateStudyStart : null,
dateStudyEnd:
getDevelopment.development != null ? getDevelopment.development.dateStudyEnd : null,
academic: getDevelopment.development?.developmentOthers
? getDevelopment.development.developmentOthers.map(dev => ({
topicAcademic: dev.topicAcademic,
addressAcademic: dev.addressAcademic
}))
: []
};
return new HttpSuccess(formattedData);

View file

@ -36,6 +36,10 @@ export class DevelopmentOther extends EntityBase {
@ManyToOne(() => Development, (development: Development) => development.developmentOthers)
@JoinColumn({ name: "developmentId" })
development: Development;
@ManyToOne(() => Province, (province: Province) => province.developmentOthers)
@JoinColumn({ name: "developmentId" })
province: Province;
}
export class UpdateDevelopmentOther {

View file

@ -2,6 +2,7 @@ import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Development } from "./Development";
import { DevelopmentAddress } from "./DevelopmentAddress";
import { DevelopmentOther } from "./DevelopmentOther";
@Entity("province")
export class Province extends EntityBase {
@ -21,6 +22,9 @@ export class Province extends EntityBase {
@OneToMany(() => Development, (development: Development) => development.provinceActual)
developmentActuals: Development[];
@OneToMany(() => DevelopmentOther, (developmentOther: DevelopmentOther) => developmentOther.province)
developmentOthers: Development[];
}
export class CreateProvince {

View file

@ -0,0 +1,14 @@
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\``);
}
}