migrate
This commit is contained in:
parent
8a36a6c977
commit
6fc0c04a9b
4 changed files with 202 additions and 6 deletions
|
|
@ -27,6 +27,7 @@ import {
|
|||
UpdateDevelopment5,
|
||||
UpdateDevelopment7,
|
||||
UpdateDevelopment8,
|
||||
UpdateDevelopment8_1,
|
||||
} from "../entities/Development";
|
||||
import { ActualPeople, CreateActualPeople } from "../entities/ActualPeople";
|
||||
import { CreatePlannedPeople, PlannedPeople } from "../entities/PlannedPeople";
|
||||
|
|
@ -60,12 +61,14 @@ import { FileInterceptor } from "@nestjs/platform-express";
|
|||
import * as xlsx from "xlsx";
|
||||
import { addLogSequence, setLogDataDiff } from "../interfaces/utils";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { DevelopmentRisk } from "../entities/DevelopmentRisk";
|
||||
|
||||
@Route("api/v1/development/main")
|
||||
@Tags("Development")
|
||||
@Security("bearerAuth")
|
||||
export class DevelopmentController extends Controller {
|
||||
private developmentRepository = AppDataSource.getRepository(Development);
|
||||
private developmentRiskRepository = AppDataSource.getRepository(DevelopmentRisk);
|
||||
private developmentAddresssRepository = AppDataSource.getRepository(DevelopmentAddress);
|
||||
private developmentEvaluationRepository = AppDataSource.getRepository(DevelopmentEvaluation);
|
||||
private developmentProjectTypeRepository = AppDataSource.getRepository(DevelopmentProjectType);
|
||||
|
|
@ -1410,10 +1413,11 @@ export class DevelopmentController extends Controller {
|
|||
await this.developmentRepository.save(development, { data: request });
|
||||
return new HttpSuccess(development.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6
|
||||
* API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab7
|
||||
*
|
||||
* @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 #
|
||||
* @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab7 #
|
||||
*
|
||||
* @param {string} id Id โครงการ
|
||||
*/
|
||||
|
|
@ -1434,6 +1438,38 @@ export class DevelopmentController extends Controller {
|
|||
return new HttpSuccess(_getDevelopment);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab8
|
||||
*
|
||||
* @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab8 #
|
||||
*
|
||||
* @param {string} id Id โครงการ
|
||||
*/
|
||||
@Get("tab8/{id}")
|
||||
async GetDevelopemtTab8ById(@Path() id: string) {
|
||||
const getDevelopment = await this.developmentRepository.findOne({
|
||||
relations: ["developmentRisks"],
|
||||
where: { id: id },
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
}
|
||||
let _getDevelopment = {
|
||||
developmentRisks:
|
||||
getDevelopment.developmentRisks == null
|
||||
? null
|
||||
: getDevelopment.developmentRisks.sort((a, b) =>
|
||||
(a.id == null ? "" : a.id).localeCompare(
|
||||
b.id == null ? "" : b.id,
|
||||
),
|
||||
),
|
||||
expect: getDevelopment.expect,
|
||||
};
|
||||
|
||||
return new HttpSuccess(_getDevelopment);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขโครงการ/หลักสูตรการฝึกอบรม tab8
|
||||
*
|
||||
|
|
@ -1460,6 +1496,82 @@ export class DevelopmentController extends Controller {
|
|||
await this.developmentRepository.save(development, { data: request });
|
||||
return new HttpSuccess(development.id);
|
||||
}
|
||||
/**
|
||||
* API เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab8-1
|
||||
*
|
||||
* @summary DEV_00 - เพิ่มโครงการ/หลักสูตรการฝึกอบรมtab8-1 #
|
||||
*
|
||||
* @param {string} id Id โครงการ
|
||||
*/
|
||||
@Put("tab8_1_add/{id}")
|
||||
async CreateDevelopmenttab8_1(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: UpdateDevelopment8_1,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const development = await this.developmentRepository.findOne({
|
||||
where: { id },
|
||||
});
|
||||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
}
|
||||
const before = structuredClone(development);
|
||||
const data = Object.assign(new DevelopmentEvaluation(), requestBody);
|
||||
data.createdUserId = request.user.sub;
|
||||
data.createdFullName = request.user.name;
|
||||
data.lastUpdateUserId = request.user.sub;
|
||||
data.lastUpdateFullName = request.user.name;
|
||||
data.developmentId = development.id;
|
||||
await this.developmentEvaluationRepository.save(data, { data: request });
|
||||
setLogDataDiff(request, { before, after: development });
|
||||
return new HttpSuccess(data.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบโครงการ/หลักสูตรการฝึกอบรมtab8-1
|
||||
*
|
||||
* @summary DEV_00 - ลบโครงการ/หลักสูตรการฝึกอบรมtab8-1 #
|
||||
*
|
||||
* @param {string} id Id รายการ
|
||||
*/
|
||||
@Delete("tab8_1/{id}")
|
||||
async DeleteDevelopmenttab8_1(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
const development = await this.developmentEvaluationRepository.findOne({
|
||||
where: { id },
|
||||
});
|
||||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้เกี่ยวข้องเป้าหมายตามแผน");
|
||||
}
|
||||
await this.developmentEvaluationRepository.remove(development, { data: request });
|
||||
return new HttpSuccess(development.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab8-1
|
||||
*
|
||||
* @summary DEV_00 - แก้ไขโครงการ/หลักสูตรการฝึกอบรมtab8-1 #
|
||||
*
|
||||
* @param {string} id Id รายการ
|
||||
*/
|
||||
@Put("tab8_1_edit/{id}")
|
||||
async UpdateDevelopmenttab8_1(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: UpdateDevelopment8_1,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const development = await this.developmentEvaluationRepository.findOne({
|
||||
where: { id },
|
||||
});
|
||||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
}
|
||||
Object.assign(development, requestBody);
|
||||
development.lastUpdateUserId = request.user.sub;
|
||||
development.lastUpdateFullName = request.user.name;
|
||||
|
||||
await this.developmentEvaluationRepository.save(development, { data: request });
|
||||
return new HttpSuccess(development.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ค้นหาโครงการ
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue