add sort
This commit is contained in:
parent
bd00213596
commit
00f76bbd2b
14 changed files with 187 additions and 166 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
Patch,
|
||||
Path,
|
||||
Post,
|
||||
Put,
|
||||
Request,
|
||||
Route,
|
||||
Security,
|
||||
|
|
@ -44,12 +45,12 @@ export class StrategyController extends Controller {
|
|||
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
|
||||
],
|
||||
order: {
|
||||
createdAt: "ASC",
|
||||
order: "ASC",
|
||||
strategyChild2s: {
|
||||
createdAt: "ASC",
|
||||
order: "ASC",
|
||||
strategyChild3s: {
|
||||
createdAt: "ASC",
|
||||
strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } },
|
||||
order: "ASC",
|
||||
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -59,25 +60,30 @@ export class StrategyController extends Controller {
|
|||
id: item.id,
|
||||
level: 1,
|
||||
name: item.strategyChild1Name,
|
||||
order: item.order,
|
||||
children: item.strategyChild2s.map((child2) => ({
|
||||
id: child2.id,
|
||||
level: 2,
|
||||
name: child2.strategyChild2Name,
|
||||
order: child2.order,
|
||||
children: child2.strategyChild3s
|
||||
? child2.strategyChild3s.map((child3) => ({
|
||||
id: child3.id,
|
||||
level: 3,
|
||||
name: child3.strategyChild3Name,
|
||||
order: child3.order,
|
||||
children: child3.strategyChild4s
|
||||
? child3.strategyChild4s.map((child4) => ({
|
||||
id: child4.id,
|
||||
level: 4,
|
||||
name: child4.strategyChild4Name,
|
||||
order: child4.order,
|
||||
children: child4.strategyChild5s
|
||||
? child4.strategyChild5s.map((child5) => ({
|
||||
id: child5.id,
|
||||
level: 5,
|
||||
name: child5.strategyChild5Name,
|
||||
order: child5.order,
|
||||
}))
|
||||
: [],
|
||||
}))
|
||||
|
|
@ -110,12 +116,12 @@ export class StrategyController extends Controller {
|
|||
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
|
||||
],
|
||||
order: {
|
||||
createdAt: "ASC",
|
||||
order: "ASC",
|
||||
strategyChild2s: {
|
||||
createdAt: "ASC",
|
||||
order: "ASC",
|
||||
strategyChild3s: {
|
||||
createdAt: "ASC",
|
||||
strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } },
|
||||
order: "ASC",
|
||||
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -129,25 +135,30 @@ export class StrategyController extends Controller {
|
|||
id: item.id,
|
||||
level: 1,
|
||||
name: item.strategyChild1Name,
|
||||
order: item.order,
|
||||
children: item.strategyChild2s.map((child2) => ({
|
||||
id: child2.id,
|
||||
level: 2,
|
||||
name: child2.strategyChild2Name,
|
||||
order: child2.order,
|
||||
children: child2.strategyChild3s
|
||||
? child2.strategyChild3s.map((child3) => ({
|
||||
id: child3.id,
|
||||
level: 3,
|
||||
name: child3.strategyChild3Name,
|
||||
order: child3.order,
|
||||
children: child3.strategyChild4s
|
||||
? child3.strategyChild4s.map((child4) => ({
|
||||
id: child4.id,
|
||||
level: 4,
|
||||
name: child4.strategyChild4Name,
|
||||
order: child4.order,
|
||||
children: child4.strategyChild5s
|
||||
? child4.strategyChild5s.map((child5) => ({
|
||||
id: child5.id,
|
||||
level: 5,
|
||||
name: child5.strategyChild5Name,
|
||||
order: child5.order,
|
||||
}))
|
||||
: [],
|
||||
}))
|
||||
|
|
@ -170,12 +181,12 @@ export class StrategyController extends Controller {
|
|||
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
|
||||
],
|
||||
order: {
|
||||
createdAt: "ASC",
|
||||
order: "ASC",
|
||||
strategyChild2s: {
|
||||
createdAt: "ASC",
|
||||
order: "ASC",
|
||||
strategyChild3s: {
|
||||
createdAt: "ASC",
|
||||
strategyChild4s: { createdAt: "ASC", strategyChild5s: { createdAt: "ASC" } },
|
||||
order: "ASC",
|
||||
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -189,25 +200,30 @@ export class StrategyController extends Controller {
|
|||
id: item.id,
|
||||
level: 1,
|
||||
name: item.strategyChild1Name,
|
||||
order: item.order,
|
||||
children: item.strategyChild2s.map((child2) => ({
|
||||
id: child2.id,
|
||||
level: 2,
|
||||
name: child2.strategyChild2Name,
|
||||
order: child2.order,
|
||||
children: child2.strategyChild3s
|
||||
? child2.strategyChild3s.map((child3) => ({
|
||||
id: child3.id,
|
||||
level: 3,
|
||||
name: child3.strategyChild3Name,
|
||||
order: child3.order,
|
||||
children: child3.strategyChild4s
|
||||
? child3.strategyChild4s.map((child4) => ({
|
||||
id: child4.id,
|
||||
level: 4,
|
||||
name: child4.strategyChild4Name,
|
||||
order: child4.order,
|
||||
children: child4.strategyChild5s
|
||||
? child4.strategyChild5s.map((child5) => ({
|
||||
id: child5.id,
|
||||
level: 5,
|
||||
name: child5.strategyChild5Name,
|
||||
order: child5.order,
|
||||
}))
|
||||
: [],
|
||||
}))
|
||||
|
|
@ -237,22 +253,30 @@ export class StrategyController extends Controller {
|
|||
|
||||
switch (body.levelnode) {
|
||||
case 0:
|
||||
const ckOrder = await this.strategy1Repo.findOne({
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
strategyRepo = this.strategy1Repo;
|
||||
strategyRepo = this.strategy1Repo;
|
||||
repoSave = this.strategy1Repo;
|
||||
strategyChild = new StrategyChild1();
|
||||
strategyChild.strategyChild1Name = body.name;
|
||||
strategyChild.order = ckOrder ? ckOrder.order + 1 : 1;
|
||||
break;
|
||||
case 1:
|
||||
strategyRepo = this.strategy1Repo;
|
||||
repoSave = this.strategy2Repo;
|
||||
strategyChild = new StrategyChild2();
|
||||
strategyChild.strategyChild2Name = body.name;
|
||||
strategyChild.order = 1;
|
||||
if (body.idnode) {
|
||||
const chk1 = await this.strategy1Repo.findOne({
|
||||
where: { id: body.idnode },
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
if (chk1) {
|
||||
strategyChild.strategyChild1Id = chk1.id;
|
||||
strategyChild.order = chk1 ? chk1.order + 1 : 1;
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
|
||||
}
|
||||
|
|
@ -263,13 +287,16 @@ export class StrategyController extends Controller {
|
|||
repoSave = this.strategy3Repo;
|
||||
strategyChild = new StrategyChild3();
|
||||
strategyChild.strategyChild3Name = body.name;
|
||||
strategyChild.order = 1;
|
||||
if (body.idnode) {
|
||||
const chk2 = await this.strategy2Repo.findOne({
|
||||
where: { id: body.idnode },
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
if (chk2) {
|
||||
strategyChild.strategyChild1Id = chk2.strategyChild1Id;
|
||||
strategyChild.strategyChild2Id = chk2.id;
|
||||
strategyChild.order = chk2 ? chk2.order + 1 : 1;
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
|
||||
}
|
||||
|
|
@ -280,14 +307,17 @@ export class StrategyController extends Controller {
|
|||
repoSave = this.strategy4Repo;
|
||||
strategyChild = new StrategyChild4();
|
||||
strategyChild.strategyChild4Name = body.name;
|
||||
strategyChild.order = 1;
|
||||
if (body.idnode) {
|
||||
const chk3 = await this.strategy3Repo.findOne({
|
||||
where: { id: body.idnode },
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
if (chk3) {
|
||||
strategyChild.strategyChild1Id = chk3.strategyChild1Id;
|
||||
strategyChild.strategyChild2Id = chk3.strategyChild2Id;
|
||||
strategyChild.strategyChild3Id = chk3.id;
|
||||
strategyChild.order = chk3 ? chk3.order + 1 : 1;
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
|
||||
}
|
||||
|
|
@ -298,15 +328,18 @@ export class StrategyController extends Controller {
|
|||
repoSave = this.strategy5Repo;
|
||||
strategyChild = new StrategyChild5();
|
||||
strategyChild.strategyChild5Name = body.name;
|
||||
strategyChild.order = 1;
|
||||
if (body.idnode) {
|
||||
const chk4 = await this.strategy4Repo.findOne({
|
||||
where: { id: body.idnode },
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
if (chk4) {
|
||||
strategyChild.strategyChild1Id = chk4.strategyChild1Id;
|
||||
strategyChild.strategyChild2Id = chk4.strategyChild2Id;
|
||||
strategyChild.strategyChild3Id = chk4.strategyChild3Id;
|
||||
strategyChild.strategyChild4Id = chk4.id;
|
||||
strategyChild.order = chk4 ? chk4.order + 1 : 1;
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
|
||||
}
|
||||
|
|
@ -621,4 +654,89 @@ export class StrategyController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API เรียงลำดับ
|
||||
*
|
||||
* @summary เรียงลำดับ (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("sort")
|
||||
async sortNode(
|
||||
@Body() requestBody: { strategy: number; strategyId: string[]; id: string | null },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
switch (requestBody.strategy) {
|
||||
case 1: {
|
||||
const data = await this.strategy1Repo.find();
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy1.");
|
||||
}
|
||||
const sortLevel = data.map((data) => ({
|
||||
...data,
|
||||
level: requestBody.strategyId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.strategy1Repo.save(sortLevel);
|
||||
return new HttpSuccess(sortLevel);
|
||||
}
|
||||
case 2: {
|
||||
const data = await this.strategy2Repo.find({
|
||||
where: { id: requestBody.id ?? "" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy2.");
|
||||
}
|
||||
const sortLevel = data.map((data) => ({
|
||||
...data,
|
||||
level: requestBody.strategyId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.strategy2Repo.save(sortLevel);
|
||||
return new HttpSuccess(sortLevel);
|
||||
}
|
||||
case 3: {
|
||||
const data = await this.strategy3Repo.find({
|
||||
where: { id: requestBody.id ?? "" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy3.");
|
||||
}
|
||||
const sortLevel = data.map((data) => ({
|
||||
...data,
|
||||
level: requestBody.strategyId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.strategy3Repo.save(sortLevel);
|
||||
return new HttpSuccess(sortLevel);
|
||||
}
|
||||
case 4: {
|
||||
const data = await this.strategy4Repo.find({
|
||||
where: { id: requestBody.id ?? "" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy4.");
|
||||
}
|
||||
const sortLevel = data.map((data) => ({
|
||||
...data,
|
||||
level: requestBody.strategyId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.strategy4Repo.save(sortLevel);
|
||||
return new HttpSuccess(sortLevel);
|
||||
}
|
||||
case 5: {
|
||||
const data = await this.strategy5Repo.find({
|
||||
where: { id: requestBody.id ?? "" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy5.");
|
||||
}
|
||||
const sortLevel = data.map((data) => ({
|
||||
...data,
|
||||
level: requestBody.strategyId.indexOf(data.id) + 1,
|
||||
}));
|
||||
await this.strategy5Repo.save(sortLevel);
|
||||
return new HttpSuccess(sortLevel);
|
||||
}
|
||||
default:
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,13 @@ export class StrategyChild1 extends EntityBase {
|
|||
})
|
||||
strategyChild1Name: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับความสำคัญ",
|
||||
default: null,
|
||||
})
|
||||
order: number;
|
||||
|
||||
@OneToMany(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild1)
|
||||
strategyChild2s: StrategyChild2[];
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,13 @@ export class StrategyChild2 extends EntityBase {
|
|||
})
|
||||
strategyChild1Id: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับความสำคัญ",
|
||||
default: null,
|
||||
})
|
||||
order: number;
|
||||
|
||||
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild2s)
|
||||
@JoinColumn({ name: "strategyChild1Id" })
|
||||
strategyChild1: StrategyChild1;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ export class StrategyChild3 extends EntityBase {
|
|||
})
|
||||
strategyChild2Id: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับความสำคัญ",
|
||||
default: null,
|
||||
})
|
||||
order: number;
|
||||
|
||||
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild3s)
|
||||
@JoinColumn({ name: "strategyChild1Id" })
|
||||
strategyChild1: StrategyChild1;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@ export class StrategyChild4 extends EntityBase {
|
|||
})
|
||||
strategyChild3Id: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับความสำคัญ",
|
||||
default: null,
|
||||
})
|
||||
order: number;
|
||||
|
||||
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild4s)
|
||||
@JoinColumn({ name: "strategyChild1Id" })
|
||||
strategyChild1: StrategyChild1;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,13 @@ export class StrategyChild5 extends EntityBase {
|
|||
})
|
||||
strategyChild4Id: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับความสำคัญ",
|
||||
default: null,
|
||||
})
|
||||
order: number;
|
||||
|
||||
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild5s)
|
||||
@JoinColumn({ name: "strategyChild1Id" })
|
||||
strategyChild1: StrategyChild1;
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateDevelopmentHisAddIsDoneIDP1727719189429 implements MigrationInterface {
|
||||
name = 'UpdateDevelopmentHisAddIsDoneIDP1727719189429'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`isDoneIDP\` tinyint NOT NULL COMMENT 'บันทึก IDP ที่ทะเบียนประวัติ' DEFAULT 0`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`isDoneIDP\``);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateDevelopmentAddIsReasonActual701727753251629 implements MigrationInterface {
|
||||
name = 'UpdateDevelopmentAddIsReasonActual701727753251629'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned70\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 70 แผน' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned20\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 20 แผน' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual70\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 70 จริง' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual20\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 20 จริง' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual20\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual70\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned20\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned70\``);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateDevelopmentAddIsReasonActual101727755044851 implements MigrationInterface {
|
||||
name = 'UpdateDevelopmentAddIsReasonActual101727755044851'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง' DEFAULT 0`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateDeleteDevProvincename1737111015155 implements MigrationInterface {
|
||||
name = 'UpdateDeleteDevProvincename1737111015155'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP FOREIGN KEY \`FK_e2721b3f440256b56ce83a04fb2\``);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP FOREIGN KEY \`FK_47bbbecaea9b7b31d2536054656\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_bdafbb824b88c3bdb73adf7f220\``);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`provinceName\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม'`);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD \`provinceActualName\` varchar(255) NULL COMMENT 'จังหวัด(ข้อมูลวิชาการ)'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP COLUMN \`provinceActualName\``);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`provinceName\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_bdafbb824b88c3bdb73adf7f220\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD CONSTRAINT \`FK_47bbbecaea9b7b31d2536054656\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD CONSTRAINT \`FK_e2721b3f440256b56ce83a04fb2\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class Updatedevadddna1738201344610 implements MigrationInterface {
|
||||
name = 'Updatedevadddna1738201344610'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX \`FK_e2721b3f440256b56ce83a04fb2\` ON \`developmentAddress\``);
|
||||
await queryRunner.query(`DROP INDEX \`FK_47bbbecaea9b7b31d2536054656\` ON \`developmentOther\``);
|
||||
await queryRunner.query(`DROP INDEX \`FK_bdafbb824b88c3bdb73adf7f220\` ON \`development\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child1'`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child2'`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child3'`);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child4'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4DnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3DnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2DnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1DnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootDnaId\``);
|
||||
await queryRunner.query(`CREATE INDEX \`FK_bdafbb824b88c3bdb73adf7f220\` ON \`development\` (\`provinceActualId\`)`);
|
||||
await queryRunner.query(`CREATE INDEX \`FK_47bbbecaea9b7b31d2536054656\` ON \`developmentOther\` (\`provinceActualId\`)`);
|
||||
await queryRunner.query(`CREATE INDEX \`FK_e2721b3f440256b56ce83a04fb2\` ON \`developmentAddress\` (\`provinceId\`)`);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateView1739444714910 implements MigrationInterface {
|
||||
name = 'UpdateView1739444714910'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE VIEW \`view_dev_scholarship\` AS SELECT MAX(\`rootId\`) AS rootId,
|
||||
MAX(\`root\`) AS root,\`degreeLevel\`,
|
||||
COUNT(*) AS numberOfRecords,
|
||||
COUNT(DISTINCT \`scholarshipType\`) AS numberOfScholarshipTypes,
|
||||
SUM(\`budgetApprove\`) AS totalBudgetApprove
|
||||
FROM \`developmentScholarship\`
|
||||
GROUP BY \`rootId\`,\`degreeLevel\`
|
||||
`);
|
||||
await queryRunner.query(`INSERT INTO \`bma_ehr_development_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_development_demo","VIEW","view_dev_scholarship","SELECT MAX(`rootId`) AS rootId, \n MAX(`root`) AS root,`degreeLevel`,\n COUNT(*) AS numberOfRecords, \n COUNT(DISTINCT `scholarshipType`) AS numberOfScholarshipTypes,\n SUM(`budgetApprove`) AS totalBudgetApprove\n FROM `developmentScholarship`\n GROUP BY `rootId`,`degreeLevel`"]);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DELETE FROM \`bma_ehr_development_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_dev_scholarship","bma_ehr_development_demo"]);
|
||||
await queryRunner.query(`DROP VIEW \`view_dev_scholarship\``);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateViewDevScholarship1739446719623 implements MigrationInterface {
|
||||
name = 'UpdateViewDevScholarship1739446719623'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE VIEW \`view_dev_scholarship\` AS SELECT MAX(\`rootId\`) AS rootId,
|
||||
MAX(\`root\`) AS root,\`degreeLevel\`,
|
||||
COUNT(*) AS numberOfRecords,
|
||||
COUNT(DISTINCT \`scholarshipType\`) AS numberOfScholarshipTypes,
|
||||
SUM(\`budgetApprove\`) AS totalBudgetApprove
|
||||
FROM \`developmentScholarship\`
|
||||
GROUP BY \`rootId\`,\`degreeLevel\`
|
||||
`);
|
||||
await queryRunner.query(`INSERT INTO \`bma_ehr_development_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_development_demo","VIEW","view_dev_scholarship","SELECT MAX(`rootId`) AS rootId, \n MAX(`root`) AS root,`degreeLevel`,\n COUNT(*) AS numberOfRecords, \n COUNT(DISTINCT `scholarshipType`) AS numberOfScholarshipTypes,\n SUM(`budgetApprove`) AS totalBudgetApprove\n FROM `developmentScholarship`\n GROUP BY `rootId`,`degreeLevel`"]);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DELETE FROM \`bma_ehr_development_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_dev_scholarship","bma_ehr_development_demo"]);
|
||||
await queryRunner.query(`DROP VIEW \`view_dev_scholarship\``);
|
||||
}
|
||||
|
||||
}
|
||||
22
src/migration/1743061489009-update_strategyadddorder.ts
Normal file
22
src/migration/1743061489009-update_strategyadddorder.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateStrategyadddorder1743061489009 implements MigrationInterface {
|
||||
name = 'UpdateStrategyadddorder1743061489009'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild2\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild1\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD \`order\` int NULL COMMENT 'ลำดับความสำคัญ'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP COLUMN \`order\``);
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild1\` DROP COLUMN \`order\``);
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild2\` DROP COLUMN \`order\``);
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP COLUMN \`order\``);
|
||||
await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP COLUMN \`order\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue