ระบบคำสั่ง

This commit is contained in:
kittapath 2024-09-11 17:29:33 +07:00
parent 38fb907ac3
commit d5c9259b67
5 changed files with 629 additions and 0 deletions

99
src/entities/Command.ts Normal file
View file

@ -0,0 +1,99 @@
import { Entity, Column, JoinColumn, ManyToOne } from "typeorm";
import { EntityBase } from "./base/Base";
import { CommandType } from "./CommandType";
@Entity("command")
export class Command extends EntityBase {
// DRAFT = แบบร่าง
// PENDING = รอผู้มีอำนาจ
// WAITING = รอออกคำสั่ง
// REPORTED = ออกคำสั่งเสร็จสิ้น
// CANCEL = ยกเลิก
@Column({
nullable: true,
comment: "สถานะ",
length: 20,
default: null,
})
status: string;
@Column({
nullable: true,
comment: "คำสั่งเรื่อง",
length: 255,
default: null,
})
issue: string;
@Column({
nullable: true,
comment: "เลขที่คำสั่ง",
length: 255,
default: null,
})
commandNo: string;
@Column({
nullable: true,
comment: "ปี",
default: null,
})
commandYear: number;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่ลงนาม",
default: null,
})
commandAffectDate: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่คำสั่งมีผล",
default: null,
})
commandExcecuteDate: Date;
@Column({
nullable: true,
comment: "เนื้อหาคำสั่งส่วนต้น",
type: "text",
default: null,
})
detailHeader: string;
@Column({
nullable: true,
comment: "เนื้อหาคำสั่งส่วนกลาง",
type: "text",
default: null,
})
detailBody: string;
@Column({
nullable: true,
comment: "เนื้อหาคำสั่งส่วนท้าย",
type: "text",
default: null,
})
detailFooter: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง commandType",
})
commandTypeId: string;
@ManyToOne(() => CommandType, (commandType) => commandType.commands)
@JoinColumn({ name: "commandTypeId" })
commandType: CommandType;
}
export class CreateCommand {
@Column()
name: string;
}
// export type UpdateCommand = Partial<CreateCommand>;

View file

@ -0,0 +1,46 @@
import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Command } from "./Command";
@Entity("commandType")
export class CommandType extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อคำสั่ง",
length: 255,
default: null,
})
name: string;
@Column({
nullable: true,
comment: "ประเภทคำสั่ง",
length: 255,
default: null,
})
type: string;
@Column({
nullable: true,
comment: "รหัสคำสั่ง",
length: 255,
default: null,
})
code: string;
@OneToMany(() => Command, (command) => command.commandType)
commands: Command[];
}
export class CreateCommandType {
@Column()
name: string;
@Column()
type: string;
@Column()
code: string;
}
export type UpdateCommandType = Partial<CreateCommandType>;