Merge branch 'develop'
This commit is contained in:
commit
5658438ca5
6 changed files with 104 additions and 28 deletions
|
|
@ -59,6 +59,7 @@ import { RequestWithUser } from "../middlewares/user";
|
||||||
import { DevelopmentRisk, UpdateDevelopmentRisk } from "../entities/DevelopmentRisk";
|
import { DevelopmentRisk, UpdateDevelopmentRisk } from "../entities/DevelopmentRisk";
|
||||||
import { DevelopmentOther, UpdateDevelopmentOther } from "../entities/DevelopmentOther";
|
import { DevelopmentOther, UpdateDevelopmentOther } from "../entities/DevelopmentOther";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
|
import { Brackets } from "typeorm";
|
||||||
|
|
||||||
@Route("api/v1/development/main")
|
@Route("api/v1/development/main")
|
||||||
@Tags("Development")
|
@Tags("Development")
|
||||||
|
|
@ -1941,9 +1942,21 @@ export class DevelopmentController extends Controller {
|
||||||
.andWhere(status != undefined ? "development.status LIKE :status" : "1=1", {
|
.andWhere(status != undefined ? "development.status LIKE :status" : "1=1", {
|
||||||
status: `%${status}%`,
|
status: `%${status}%`,
|
||||||
})
|
})
|
||||||
.andWhere(keyword != undefined ? "development.projectName LIKE :keyword" : "1=1", {
|
.andWhere(
|
||||||
keyword: `%${keyword}%`,
|
keyword != undefined
|
||||||
|
? new Brackets ((qb) => {
|
||||||
|
qb.where("development.projectName LIKE :keyword")
|
||||||
|
.orWhere("development.root LIKE :keyword")
|
||||||
|
.orWhere("development.child1 LIKE :keyword")
|
||||||
|
.orWhere("development.child2 LIKE :keyword")
|
||||||
|
.orWhere("development.child3 LIKE :keyword")
|
||||||
|
.orWhere("development.child4 LIKE :keyword");
|
||||||
})
|
})
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
.select([
|
.select([
|
||||||
"development.id",
|
"development.id",
|
||||||
"development.projectName",
|
"development.projectName",
|
||||||
|
|
@ -2593,6 +2606,58 @@ export class DevelopmentController extends Controller {
|
||||||
return new HttpSuccess(getOrg);
|
return new HttpSuccess(getOrg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get("registry/{type}/{developmentId}")
|
||||||
|
async developmentDetail(
|
||||||
|
@Path() developmentId: string,
|
||||||
|
@Path() type: string,
|
||||||
|
@Request() request: RequestWithUser
|
||||||
|
) {
|
||||||
|
const getDevelopment = await this.developmentRepository.findOne({
|
||||||
|
where: { id: developmentId },
|
||||||
|
relations: [
|
||||||
|
"developmentProjectTypes",
|
||||||
|
"developmentProjectTechniquePlanneds",
|
||||||
|
"developmentProjectTechniqueActuals",
|
||||||
|
"developmentAddresss",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
if (!getDevelopment)
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||||
|
|
||||||
|
if (type.trim().toLocaleUpperCase() == "OFFICER") {
|
||||||
|
let _workflow = await new permission().Workflow(request, developmentId, "SYS_REGISTRY_OFFICER");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_REGISTRY_OFFICER");
|
||||||
|
} else if (type.trim().toLocaleUpperCase() == "USER") {
|
||||||
|
} else {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้");
|
||||||
|
}
|
||||||
|
|
||||||
|
let _getDevelopment: any = {
|
||||||
|
id: getDevelopment.id,
|
||||||
|
evaluationId: null,
|
||||||
|
target: null,
|
||||||
|
summary: null,
|
||||||
|
point: null,
|
||||||
|
name: getDevelopment.projectName,
|
||||||
|
achievement10: "มีผลการพัฒนาและมีการดำเนินการตามเป้าหมายการนำไปพัฒนางาน",
|
||||||
|
achievement5: "มีผลการพัฒนาแต่ยังไม่ได้ดำเนินการตามเป้าหมายการนำไปพัฒนางาน",
|
||||||
|
achievement0: "ไม่ได้ดำเนินการพัฒนา",
|
||||||
|
isDevelopment70: getDevelopment.isReasonActual70,
|
||||||
|
isDevelopment20: getDevelopment.isReasonActual20,
|
||||||
|
isDevelopment10: getDevelopment.isReasonActual10,
|
||||||
|
reasonDevelopment70: getDevelopment.reasonActual70,
|
||||||
|
reasonDevelopment20: getDevelopment.reasonActual20,
|
||||||
|
reasonDevelopment10: getDevelopment.reasonActual10,
|
||||||
|
selectType: "PROJECT",
|
||||||
|
selectTypeYear: getDevelopment.year,
|
||||||
|
selectTypeId: null,
|
||||||
|
developmentProjects : getDevelopment.developmentProjectTechniqueActuals
|
||||||
|
.map((x) => x.name)
|
||||||
|
.sort(),
|
||||||
|
};
|
||||||
|
return new HttpSuccess(_getDevelopment);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API upload User
|
* API upload User
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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,7 +322,8 @@ 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,
|
||||||
|
|
@ -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, "ไม่พบข้อมูลประวัติการฝึกอบรม/ดูงานนี้");
|
||||||
|
|
@ -390,11 +405,12 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
||||||
logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info",
|
logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info",
|
||||||
ip: req.ip,
|
ip: req.ip,
|
||||||
rootId: rootId?.orgRootId ?? null,
|
rootId: rootId?.orgRootId ?? null,
|
||||||
systemName: "evaluation",
|
systemName: "development",
|
||||||
startTimeStamp: timestamp,
|
startTimeStamp: timestamp,
|
||||||
endTimeStamp: new Date().toISOString(),
|
endTimeStamp: new Date().toISOString(),
|
||||||
processTime: performance.now() - start,
|
processTime: performance.now() - start,
|
||||||
|
|
|
||||||
|
|
@ -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\``);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue