update province
This commit is contained in:
parent
668b05a511
commit
19598f1f81
9 changed files with 64 additions and 67 deletions
|
|
@ -32,7 +32,6 @@ import { ActualPeople, CreateActualPeople } from "../entities/ActualPeople";
|
|||
import { CreatePlannedPeople, PlannedPeople } from "../entities/PlannedPeople";
|
||||
import { ActualGoal, CreateActualGoal } from "../entities/ActualGoal";
|
||||
import { CreatePlannedGoal, PlannedGoal } from "../entities/PlannedGoal";
|
||||
import { Province } from "../entities/Province";
|
||||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { PlannedGoalPosition } from "../entities/PlannedGoalPosition";
|
||||
|
|
@ -83,7 +82,6 @@ export class DevelopmentController extends Controller {
|
|||
private actualGoalRepository = AppDataSource.getRepository(ActualGoal);
|
||||
private plannedGoalRepository = AppDataSource.getRepository(PlannedGoal);
|
||||
private plannedGoalPositionRepository = AppDataSource.getRepository(PlannedGoalPosition);
|
||||
private provinceRepository = AppDataSource.getRepository(Province);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1);
|
||||
|
|
@ -1224,19 +1222,14 @@ export class DevelopmentController extends Controller {
|
|||
// const before = structuredClone(development);
|
||||
await Promise.all(
|
||||
requestBody.developmentAddresss.map(async (x) => {
|
||||
let _null: any = null;
|
||||
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) {
|
||||
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.createdUserId = request.user.sub;
|
||||
data.createdFullName = request.user.name;
|
||||
|
|
@ -1433,16 +1426,14 @@ export class DevelopmentController extends Controller {
|
|||
if (!development) {
|
||||
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 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.createdFullName = request.user.name;
|
||||
data.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -1496,6 +1487,12 @@ export class DevelopmentController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความเสี่ยงของโครงการ");
|
||||
}
|
||||
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.lastUpdateFullName = request.user.name;
|
||||
development.lastUpdatedAt = new Date();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue