migrate db

This commit is contained in:
kittapath 2025-01-07 10:56:23 +07:00
parent 7891429d77
commit b349dd5944
6 changed files with 52 additions and 17 deletions

View file

@ -317,6 +317,7 @@ export class CommandController extends Controller {
command.detailBody = commandType.detailBody;
command.detailFooter = commandType.detailFooter;
command.isAttachment = commandType.isAttachment;
command.isUploadAttachment = commandType.isUploadAttachment;
command.status = "NEW";
command.issue = commandType.name;
command.createdUserId = request.user.sub;
@ -358,6 +359,7 @@ export class CommandController extends Controller {
detailFooter: command.detailFooter,
isBangkok: command.isBangkok,
isAttachment: command.isAttachment,
isUploadAttachment: command.isUploadAttachment,
commandAffectDate: command.commandAffectDate,
commandExcecuteDate: command.commandExcecuteDate,
commandTypeName: command.commandType?.name || null,
@ -963,6 +965,7 @@ export class CommandController extends Controller {
isDraft: command.isDraft,
isSign: command.isSign,
isAttachment: command.isAttachment,
isUploadAttachment: command.isUploadAttachment,
isSalary: command.commandType ? command.commandType.isSalary : null,
};
return new HttpSuccess(_command);
@ -1853,6 +1856,7 @@ export class CommandController extends Controller {
command.detailBody = commandType.detailBody;
command.detailFooter = commandType.detailFooter;
command.isAttachment = commandType.isAttachment;
command.isUploadAttachment = commandType.isUploadAttachment;
command.status = "NEW";
command.issue = commandType.name;
(command.commandAffectDate = requestBody.commandAffectDate
@ -4501,6 +4505,7 @@ export class CommandController extends Controller {
isDraft: command.isDraft,
isSign: command.isSign,
isAttachment: command.isAttachment,
isUploadAttachment: command.isUploadAttachment,
};
return new HttpSuccess(_command);
}

View file

@ -54,6 +54,7 @@ export class CommandTypeController extends Controller {
"detailFooter",
"subtitle",
"isAttachment",
"isUploadAttachment",
"createdAt",
"lastUpdatedAt",
"createdFullName",
@ -74,7 +75,7 @@ export class CommandTypeController extends Controller {
async GetAdmin(
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string | null ,
@Query("keyword") keyword?: string | null,
@Query() isActive?: boolean | null,
) {
const [commandTypes, total] = await this.commandTypeRepository
@ -88,19 +89,15 @@ export class CommandTypeController extends Controller {
)
.andWhere(
new Brackets((qb) => {
qb.where(
keyword != null && keyword != "" ? "commandType.name LIKE :keyword" : "1=1",
{
keyword: `%${keyword}%`,
},
)
.orWhere(
qb.where(keyword != null && keyword != "" ? "commandType.name LIKE :keyword" : "1=1", {
keyword: `%${keyword}%`,
}).orWhere(
keyword != null && keyword != "" ? "commandType.detailBody LIKE :keyword" : "1=1",
{
keyword: `%${keyword}%`,
},
)
})
);
}),
)
.orderBy("commandType.order", "ASC")
.skip((page - 1) * pageSize)
@ -133,6 +130,7 @@ export class CommandTypeController extends Controller {
"detailFooter",
"subtitle",
"isAttachment",
"isUploadAttachment",
],
});
if (!_commandType) {
@ -153,14 +151,14 @@ export class CommandTypeController extends Controller {
detailFooter: _commandType.detailFooter,
subtitle: _commandType.subtitle,
isAttachment: _commandType.isAttachment,
isUploadAttachment: _commandType.isUploadAttachment,
name1: "๑. ..........................ประธาน",
name2: "๒. ..........................กรรมการ",
name3: "๓. ..........................กรรมการ",
name4: "๔. ..........................กรรมการ",
};
_commandType = _commandType10;
}
else if (["C-PM-21", "C-PM-23"].includes(_commandType.code)) {
} else if (["C-PM-21", "C-PM-23"].includes(_commandType.code)) {
let _commandType21and23: any;
_commandType21and23 = {
id: _commandType.id,
@ -175,6 +173,7 @@ export class CommandTypeController extends Controller {
detailFooter: _commandType.detailFooter,
subtitle: _commandType.subtitle,
isAttachment: _commandType.isAttachment,
isUploadAttachment: _commandType.isUploadAttachment,
name1: "๑. ..........................ประธาน",
name2: "๒. ..........................กรรมการ",
name3: "๓. ..........................กรรมการ",
@ -191,9 +190,9 @@ export class CommandTypeController extends Controller {
amount: "",
dateRetire: "",
dateExecute: "",
remark: ""
}
]
remark: "",
},
],
};
_commandType = _commandType21and23;
}

View file

@ -410,8 +410,8 @@ export class ImportDataController extends Controller {
profileSalary.profileEmployeeId = _item.id;
profileSalary.refCommandNo = item.MP_COMMAND_NUM;
profileSalary.posNo = item.POS_NUM_NAME + item.POS_NUM_CODE;
profileSalary.position = item.FLAG_TO_NAME;
profileSalary.positionLine = item.WORK_LINE_NAME;
// profileSalary.position = item.FLAG_TO_NAME;
profileSalary.position = item.WORK_LINE_NAME;
profileSalary.positionPathSide = item.SPECIALIST_NAME;
profileSalary.positionExecutive = item.ADMIN_NAME;
profileSalary.templateDoc = item.REMARK;

View file

@ -109,6 +109,12 @@ export class Command extends EntityBase {
})
isAttachment: boolean;
@Column({
comment: "อัปโหลดบัญชีแนบท้าย",
default: true,
})
isUploadAttachment: boolean;
@Column({
comment: "ออกคำสั่งแบบ Digital Signature",
default: null,

View file

@ -80,6 +80,12 @@ export class CommandType extends EntityBase {
})
isAttachment: boolean;
@Column({
comment: "อัปโหลดบัญชีแนบท้าย",
default: false,
})
isUploadAttachment: boolean;
@Column({
comment: "สถานะแก้ไขเงินเดือน",
default: true,
@ -126,6 +132,9 @@ export class CreateCommandType {
@Column()
isAttachment: boolean;
@Column()
isUploadAttachment: boolean;
@Column()
isSalary?: boolean | null;
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableCommandtypeAddIsUploadAttachment1736221443955 implements MigrationInterface {
name = 'UpdateTableCommandtypeAddIsUploadAttachment1736221443955'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`commandType\` ADD \`isUploadAttachment\` tinyint NOT NULL COMMENT 'อัปโหลดบัญชีแนบท้าย' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`command\` ADD \`isUploadAttachment\` tinyint NOT NULL COMMENT 'อัปโหลดบัญชีแนบท้าย' DEFAULT 1`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`command\` DROP COLUMN \`isUploadAttachment\``);
await queryRunner.query(`ALTER TABLE \`commandType\` DROP COLUMN \`isUploadAttachment\``);
}
}