แก้ ไข คำ สั่ง tab0
This commit is contained in:
parent
22ae951626
commit
5ccbdd1f61
3 changed files with 173 additions and 0 deletions
|
|
@ -503,4 +503,141 @@ export class CommandController extends Controller {
|
|||
await this.commandRepository.delete(command.id);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดรายการคำสั่ง tab0
|
||||
*
|
||||
* @summary API รายละเอียดรายการคำสั่ง tab0
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Get("tab0/{id}")
|
||||
async GetByIdTab0(@Path() id: string) {
|
||||
const command = await this.commandRepository.findOne({
|
||||
where: { id },
|
||||
});
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
|
||||
const _command = {
|
||||
id: command.id,
|
||||
isSignature: command.isSignature,
|
||||
status: command.status,
|
||||
isDraft: command.isDraft,
|
||||
isSign: command.isSign,
|
||||
};
|
||||
return new HttpSuccess(_command);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ทำคำสั่งใหม่
|
||||
*
|
||||
* @summary API ทำคำสั่งใหม่
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Put("sign/{id}")
|
||||
async PutSelectSign(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { sign: boolean },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const command = await this.commandRepository.findOne({ where: { id: id } });
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
command.isSignature = requestBody.sign;
|
||||
command.status = "DRAFT";
|
||||
command.lastUpdateUserId = request.user.sub;
|
||||
command.lastUpdateFullName = request.user.name;
|
||||
command.lastUpdatedAt = new Date();
|
||||
await this.commandRepository.save(command);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ทำคำสั่งใหม่
|
||||
*
|
||||
* @summary API ทำคำสั่งใหม่
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Put("draft/{id}")
|
||||
async PutSelectDraft(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { sign?: boolean },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const command = await this.commandRepository.findOne({ where: { id: id } });
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
command.isDraft = true;
|
||||
command.status = "PENDING";
|
||||
command.lastUpdateUserId = request.user.sub;
|
||||
command.lastUpdateFullName = request.user.name;
|
||||
command.lastUpdatedAt = new Date();
|
||||
await this.commandRepository.save(command);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ทำคำสั่งใหม่
|
||||
*
|
||||
* @summary API ทำคำสั่งใหม่
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Put("pending-check/{id}")
|
||||
async PutSelectPending_Check(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { sign?: boolean },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const command = await this.commandRepository.findOne({ where: { id: id } });
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
command.isSign = true;
|
||||
command.lastUpdateUserId = request.user.sub;
|
||||
command.lastUpdateFullName = request.user.name;
|
||||
command.lastUpdatedAt = new Date();
|
||||
await this.commandRepository.save(command);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ทำคำสั่งใหม่
|
||||
*
|
||||
* @summary API ทำคำสั่งใหม่
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Put("pending/{id}")
|
||||
async PutSelectPending(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { sign?: boolean },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const command = await this.commandRepository.findOne({ where: { id: id } });
|
||||
if (!command) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||
}
|
||||
command.isSign = true;
|
||||
if (new Date().getDate() > command.commandExcecuteDate.getDate()) {
|
||||
command.status = "WAITING";
|
||||
} else {
|
||||
command.status = "REPORTED";
|
||||
}
|
||||
command.lastUpdateUserId = request.user.sub;
|
||||
command.lastUpdateFullName = request.user.name;
|
||||
command.lastUpdatedAt = new Date();
|
||||
await this.commandRepository.save(command);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,24 @@ export class Command extends EntityBase {
|
|||
})
|
||||
isAttachment: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "ออกคำสั่งแบบ Digital Signature",
|
||||
default: null,
|
||||
})
|
||||
isSignature: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "ยืนยันทำแบบร่าง",
|
||||
default: false,
|
||||
})
|
||||
isDraft: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "ผู้มีอำนาจลงนาม",
|
||||
default: false,
|
||||
})
|
||||
isSign: boolean;
|
||||
|
||||
@ManyToOne(() => CommandType, (commandType) => commandType.commands)
|
||||
@JoinColumn({ name: "commandTypeId" })
|
||||
commandType: CommandType;
|
||||
|
|
|
|||
18
src/migration/1727151717676-update_command_add_isSign.ts
Normal file
18
src/migration/1727151717676-update_command_add_isSign.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateCommandAddIsSign1727151717676 implements MigrationInterface {
|
||||
name = 'UpdateCommandAddIsSign1727151717676'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`command\` ADD \`isSignature\` tinyint NULL COMMENT 'ออกคำสั่งแบบ Digital Signature'`);
|
||||
await queryRunner.query(`ALTER TABLE \`command\` ADD \`isDraft\` tinyint NOT NULL COMMENT 'ยืนยันทำแบบร่าง' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`command\` ADD \`isSign\` tinyint NOT NULL COMMENT 'ผู้มีอำนาจลงนาม' DEFAULT 0`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`command\` DROP COLUMN \`isSign\``);
|
||||
await queryRunner.query(`ALTER TABLE \`command\` DROP COLUMN \`isDraft\``);
|
||||
await queryRunner.query(`ALTER TABLE \`command\` DROP COLUMN \`isSignature\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue