checkpoint
This commit is contained in:
parent
ba60192ec1
commit
d737ecdf11
11 changed files with 452 additions and 49 deletions
|
|
@ -5,7 +5,7 @@ import express from "express";
|
|||
import swaggerUi from "swagger-ui-express";
|
||||
import swaggerDocument from "./swagger.json";
|
||||
import error from "./middlewares/error";
|
||||
import { database } from "./database/data-source";
|
||||
import database from "./database/data-source";
|
||||
import { RegisterRoutes } from "./routes";
|
||||
|
||||
async function main() {
|
||||
|
|
|
|||
|
|
@ -1 +1,120 @@
|
|||
import { Controller, Get, Route, Security, Tags } from "tsoa";
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Patch,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Body,
|
||||
Path,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import { CreateOrgRoot, OrgRoot } from "../entities/OrgRoot";
|
||||
import database from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
||||
@Route("organization")
|
||||
@Tags("OrgRoot")
|
||||
// @Security("bearerAuth")
|
||||
export class OrgRootController extends Controller {
|
||||
private orgRootRepository = database.getRepository(OrgRoot);
|
||||
|
||||
/**
|
||||
* สร้างโครงสร้างระดับ Root
|
||||
*
|
||||
* @summary ORG_001 - สร้างโครงสร้างระดับ Root (ADMIN) #1
|
||||
*
|
||||
* @param {string} id id ข้อมูลการประเมิน
|
||||
*/
|
||||
@Post("root")
|
||||
@Example([
|
||||
{
|
||||
orgRootName: "string", //ชื่อหน่วยงาน
|
||||
orgRootShortName: "string", //อักษรย่อ
|
||||
orgRootCode: "string", //รหัสหน่วยงาน
|
||||
orgRootOrder: "number", //ลำดับที่ของหน่วยงาน
|
||||
orgRootPhoneEx: "string", //หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก
|
||||
orgRootPhoneIn: "string", //หมายเลขโทรศัพท์ที่ติดต่อจากภายใน
|
||||
orgRootFax: "string", //หมายเลขโทรสาร
|
||||
orgRootIsNormal: "boolean", //สถานะของหน่วยงาน
|
||||
},
|
||||
])
|
||||
async create(
|
||||
// @Path() id: string,
|
||||
@Body()
|
||||
requestBody: CreateOrgRoot,
|
||||
) {
|
||||
try {
|
||||
const orgRoot = Object.assign(new OrgRoot(), requestBody);
|
||||
if (!orgRoot) {
|
||||
return `not found data`;
|
||||
}
|
||||
|
||||
orgRoot.orgRootName = requestBody.orgRootName;
|
||||
orgRoot.orgRootShortName = requestBody.orgRootShortName;
|
||||
orgRoot.orgRootCode = requestBody.orgRootCode;
|
||||
orgRoot.orgRootOrder = requestBody.orgRootOrder;
|
||||
orgRoot.orgRootPhoneEx = requestBody.orgRootPhoneEx;
|
||||
orgRoot.orgRootPhoneIn = requestBody.orgRootPhoneIn;
|
||||
orgRoot.orgRootFax = requestBody.orgRootFax;
|
||||
orgRoot.orgRootIsNormal = requestBody.orgRootIsNormal;
|
||||
await this.orgRootRepository.save(orgRoot);
|
||||
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* แก้ไขโครงสร้างระดับ Root
|
||||
*
|
||||
* @summary ORG_002 - แก้ไขโครงสร้างระดับ Root (ADMIN) #2
|
||||
*
|
||||
* @param {string} id Guid, *Id root
|
||||
*/
|
||||
@Put("root/{id}")
|
||||
@Example([
|
||||
{
|
||||
orgRootName: "string", //ชื่อหน่วยงาน
|
||||
orgRootShortName: "string", //อักษรย่อ
|
||||
orgRootCode: "string", //รหัสหน่วยงาน
|
||||
orgRootOrder: "number", //ลำดับที่ของหน่วยงาน
|
||||
orgRootPhoneEx: "string", //หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก
|
||||
orgRootPhoneIn: "string", //หมายเลขโทรศัพท์ที่ติดต่อจากภายใน
|
||||
orgRootFax: "string", //หมายเลขโทรสาร
|
||||
orgRootIsNormal: "boolean", //สถานะของหน่วยงาน
|
||||
},
|
||||
])
|
||||
async update(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: CreateOrgRoot,
|
||||
) {
|
||||
try {
|
||||
const orgRoot = await this.orgRootRepository.findOne({ where: { id } });
|
||||
if (!orgRoot) {
|
||||
return `not found data`;
|
||||
}
|
||||
|
||||
orgRoot.orgRootName = requestBody.orgRootName;
|
||||
orgRoot.orgRootShortName = requestBody.orgRootShortName;
|
||||
orgRoot.orgRootCode = requestBody.orgRootCode;
|
||||
orgRoot.orgRootOrder = requestBody.orgRootOrder;
|
||||
orgRoot.orgRootPhoneEx = requestBody.orgRootPhoneEx;
|
||||
orgRoot.orgRootPhoneIn = requestBody.orgRootPhoneIn;
|
||||
orgRoot.orgRootFax = requestBody.orgRootFax;
|
||||
orgRoot.orgRootIsNormal = requestBody.orgRootIsNormal;
|
||||
await this.orgRootRepository.save(orgRoot);
|
||||
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,19 +83,19 @@ export class OrgChild1 extends EntityBase {
|
|||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: "tinyint",
|
||||
comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0
|
||||
default: true
|
||||
})
|
||||
orgChild1IsNormal: number;
|
||||
orgChild1IsNormal: boolean;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgRootId: string;
|
||||
orgRootId: string;
|
||||
|
||||
@ManyToOne(() => OrgRoot, orgRoot => orgRoot.orgChild1s)
|
||||
@JoinColumn({ name: "fkOrgRootId" })
|
||||
@JoinColumn({ name: "orgRootId" })
|
||||
orgRoot: OrgRoot;
|
||||
|
||||
//child table 2,3,4
|
||||
|
|
|
|||
|
|
@ -83,29 +83,29 @@ export class OrgChild2 extends EntityBase {
|
|||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: "tinyint",
|
||||
comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0
|
||||
default: true
|
||||
})
|
||||
orgChild2IsNormal: number;
|
||||
orgChild2IsNormal: boolean;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgRootId: string;
|
||||
orgRootId: string;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgChild1Id: string;
|
||||
orgChild1Id: string;
|
||||
|
||||
// @ManyToOne(() => OrgRoot, orgRoot => orgRoot.orgChild2s)
|
||||
// @JoinColumn({ name: "fkOrgRootId" })
|
||||
// @JoinColumn({ name: "orgRootId" })
|
||||
// orgRoot: OrgRoot;
|
||||
|
||||
@ManyToOne(() => OrgChild1, orgChild1 => orgChild1.orgChild2s)
|
||||
@JoinColumn({ name: "fkOrgChild1Id" })
|
||||
@JoinColumn({ name: "orgChild1Id" })
|
||||
orgChild1: OrgChild1;
|
||||
|
||||
//child table 3,4
|
||||
|
|
|
|||
|
|
@ -82,39 +82,39 @@ export class OrgChild3 extends EntityBase {
|
|||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: "tinyint",
|
||||
comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0
|
||||
default: true
|
||||
})
|
||||
orgChild3IsNormal: number;
|
||||
orgChild3IsNormal: boolean;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgRootId: string;
|
||||
orgRootId: string;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgChild1Id: string;
|
||||
orgChild1Id: string;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgChild2Id: string;
|
||||
orgChild2Id: string;
|
||||
|
||||
// @ManyToOne(() => OrgRoot, orgRoot => orgRoot.orgChild3s)
|
||||
// @JoinColumn({ name: "fkOrgRootId" })
|
||||
// @JoinColumn({ name: "orgRootId" })
|
||||
// orgRoot: OrgRoot;
|
||||
|
||||
// @ManyToOne(() => OrgChild1, orgChild1 => orgChild1.orgChild3s)
|
||||
// @JoinColumn({ name: "fkOrgChild1Id" })
|
||||
// @JoinColumn({ name: "orgChild1Id" })
|
||||
// orgChild1: OrgChild1;
|
||||
|
||||
@ManyToOne(() => OrgChild2, orgChild2 => orgChild2.orgChild3s)
|
||||
@JoinColumn({ name: "fkOrgChild2Id" })
|
||||
@JoinColumn({ name: "orgChild2Id" })
|
||||
orgChild2: OrgChild2;
|
||||
|
||||
//child table 4
|
||||
|
|
|
|||
|
|
@ -82,49 +82,49 @@ export class OrgChild4 extends EntityBase {
|
|||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: "tinyint",
|
||||
comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0
|
||||
default: true
|
||||
})
|
||||
orgChild4IsNormal: number;
|
||||
orgChild4IsNormal: boolean;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgRootId: string;
|
||||
orgRootId: string;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgChild1Id: string;
|
||||
orgChild1Id: string;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgChild2Id: string;
|
||||
orgChild2Id: string;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgChild3Id: string;
|
||||
orgChild3Id: string;
|
||||
|
||||
// @ManyToOne(() => OrgRoot, orgRoot => orgRoot.orgChild4s)
|
||||
// @JoinColumn({ name: "fkOrgRootId" })
|
||||
// @JoinColumn({ name: "orgRootId" })
|
||||
// orgRoot: OrgRoot;
|
||||
|
||||
// @ManyToOne(() => OrgChild1, orgChild1 => orgChild1.orgChild4s)
|
||||
// @JoinColumn({ name: "fkOrgChild1Id" })
|
||||
// @JoinColumn({ name: "orgChild1Id" })
|
||||
// orgChild1: OrgChild1;
|
||||
|
||||
// @ManyToOne(() => OrgChild2, orgChild2 => orgChild2.orgChild4s)
|
||||
// @JoinColumn({ name: "fkOrgChild2Id" })
|
||||
// @JoinColumn({ name: "orgChild2Id" })
|
||||
// orgChild2: OrgChild2;
|
||||
|
||||
@ManyToOne(() => OrgChild3, orgChild3 => orgChild3.orgChild4s)
|
||||
@JoinColumn({ name: "fkOrgChild3Id" })
|
||||
@JoinColumn({ name: "orgChild3Id" })
|
||||
orgChild3: OrgChild3;
|
||||
}
|
||||
export type UpdateOrgChild4 = Partial<OrgChild4>;
|
||||
|
|
|
|||
|
|
@ -84,16 +84,16 @@ export class OrgRoot extends EntityBase {
|
|||
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: "tinyint",
|
||||
comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0
|
||||
default: true
|
||||
})
|
||||
orgRootIsNormal: number;
|
||||
orgRootIsNormal: boolean;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
fkOrgRevisionId: string;
|
||||
orgRevisionId: string;
|
||||
|
||||
//child table 1,2,3,4
|
||||
@OneToMany(() => OrgChild1, orgChild1 => orgChild1.orgRoot)
|
||||
|
|
@ -111,3 +111,34 @@ export class OrgRoot extends EntityBase {
|
|||
}
|
||||
|
||||
export type UpdateOrgRoot = Partial<OrgRoot>;
|
||||
|
||||
export class CreateOrgRoot {
|
||||
|
||||
@Column()
|
||||
orgRootName: string;
|
||||
|
||||
@Column()
|
||||
orgRootShortName: string;
|
||||
|
||||
@Column()
|
||||
orgRootCode: string;
|
||||
|
||||
@Column()
|
||||
orgRootRank: OrgRootRank;
|
||||
|
||||
@Column()
|
||||
orgRootOrder: number;
|
||||
|
||||
@Column()
|
||||
orgRootPhoneEx: string;
|
||||
|
||||
@Column()
|
||||
orgRootPhoneIn: string;
|
||||
|
||||
@Column()
|
||||
orgRootFax: string;
|
||||
|
||||
@Column()
|
||||
orgRootIsNormal: boolean;
|
||||
|
||||
}
|
||||
|
|
|
|||
18
src/interfaces/http-success.ts
Normal file
18
src/interfaces/http-success.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import HttpStatus from "./http-status";
|
||||
|
||||
class HttpSuccess {
|
||||
/**
|
||||
* HTTP Status Code
|
||||
*/
|
||||
status: HttpStatus;
|
||||
message: string;
|
||||
result?: any;
|
||||
|
||||
constructor(result?: any) {
|
||||
this.status = HttpStatus.OK;
|
||||
this.message = "สำเร็จ";
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
||||
export default HttpSuccess;
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTableOrgGroup1706091448140 implements MigrationInterface {
|
||||
name = 'AddTableOrgGroup1706091448140'
|
||||
export class UpdateTableOrgGroup1706152326649 implements MigrationInterface {
|
||||
name = 'UpdateTableOrgGroup1706152326649'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`entity_base\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgChild4\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgChild4Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string', \`orgChild4ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string', \`orgChild4Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string', \`orgChild4Rank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับส่วนราชการ', \`orgChild4Order\` int NULL COMMENT 'ลำดับที่ของส่วนราชการภายใน Child เดียวกัน', \`orgChild4PhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgChild4PhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgChild4Fax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgChild4IsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน', \`fkOrgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`fkOrgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`fkOrgChild2Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`fkOrgChild3Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgChild3\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgChild3Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string', \`orgChild3ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string', \`orgChild3Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string', \`orgChild3Rank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับส่วนราชการ', \`orgChild3Order\` int NULL COMMENT 'ลำดับที่ของส่วนราชการภายใน Child เดียวกัน', \`orgChild3PhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgChild3PhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgChild3Fax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgChild3IsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน', \`fkOrgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`fkOrgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`fkOrgChild2Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgChild2\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgChild2Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string', \`orgChild2ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string', \`orgChild2Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string', \`orgChild2Rank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับส่วนราชการ', \`orgChild2Order\` int NULL COMMENT 'ลำดับที่ของส่วนราชการภายใน Child เดียวกัน', \`orgChild2PhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgChild2PhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgChild2Fax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgChild2IsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน', \`fkOrgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`fkOrgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgChild1\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgChild1Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string', \`orgChild1ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string', \`orgChild1Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string', \`orgChild1Rank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับส่วนราชการ', \`orgChild1Order\` int NULL COMMENT 'ลำดับที่ของส่วนราชการภายใน Child เดียวกัน', \`orgChild1PhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgChild1PhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgChild1Fax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgChild1IsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน', \`fkOrgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgRoot\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgRootName\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน' DEFAULT 'string', \`orgRootShortName\` varchar(16) NULL COMMENT 'ชื่อย่อหน่วยงาน' DEFAULT 'string', \`orgRootCode\` varchar(8) NULL COMMENT 'รหัสหน่วยงาน' DEFAULT 'string', \`orgRootRank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับของหน่วยงาน' DEFAULT 'department', \`orgRootOrder\` int NULL COMMENT 'ลำดับที่ของหน่วยงาน', \`orgRootPhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgRootPhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgRootFax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgRootIsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน', \`fkOrgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgChild4\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgChild4Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string', \`orgChild4ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string', \`orgChild4Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string', \`orgChild4Rank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับส่วนราชการ', \`orgChild4Order\` int NULL COMMENT 'ลำดับที่ของส่วนราชการภายใน Child เดียวกัน', \`orgChild4PhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgChild4PhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgChild4Fax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgChild4IsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน' DEFAULT 1, \`orgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild2Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild3Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgChild3\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgChild3Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string', \`orgChild3ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string', \`orgChild3Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string', \`orgChild3Rank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับส่วนราชการ', \`orgChild3Order\` int NULL COMMENT 'ลำดับที่ของส่วนราชการภายใน Child เดียวกัน', \`orgChild3PhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgChild3PhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgChild3Fax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgChild3IsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน' DEFAULT 1, \`orgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild2Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgChild2\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgChild2Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string', \`orgChild2ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string', \`orgChild2Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string', \`orgChild2Rank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับส่วนราชการ', \`orgChild2Order\` int NULL COMMENT 'ลำดับที่ของส่วนราชการภายใน Child เดียวกัน', \`orgChild2PhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgChild2PhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgChild2Fax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgChild2IsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน' DEFAULT 1, \`orgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild1Id\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgChild1\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgChild1Name\` varchar(255) NULL COMMENT 'ชื่อส่วนราชการ' DEFAULT 'string', \`orgChild1ShortName\` varchar(16) NULL COMMENT 'ชื่อย่อส่วนราชการ' DEFAULT 'string', \`orgChild1Code\` varchar(8) NULL COMMENT 'รหัสส่วนราชการ' DEFAULT 'string', \`orgChild1Rank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับส่วนราชการ', \`orgChild1Order\` int NULL COMMENT 'ลำดับที่ของส่วนราชการภายใน Child เดียวกัน', \`orgChild1PhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgChild1PhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgChild1Fax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgChild1IsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน' DEFAULT 1, \`orgRootId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgRoot\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgRootName\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน' DEFAULT 'string', \`orgRootShortName\` varchar(16) NULL COMMENT 'ชื่อย่อหน่วยงาน' DEFAULT 'string', \`orgRootCode\` varchar(8) NULL COMMENT 'รหัสหน่วยงาน' DEFAULT 'string', \`orgRootRank\` enum ('department', 'office', 'division', 'section') NULL COMMENT 'ระดับของหน่วยงาน' DEFAULT 'department', \`orgRootOrder\` int NULL COMMENT 'ลำดับที่ของหน่วยงาน', \`orgRootPhoneEx\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก', \`orgRootPhoneIn\` varchar(64) NULL COMMENT 'หมายเลขโทรศัพท์ที่ติดต่อจากภายใน', \`orgRootFax\` varchar(64) NULL COMMENT 'หมายเลขโทรสาร', \`orgRootIsNormal\` tinyint NULL COMMENT 'สถานะของหน่วยงาน' DEFAULT 1, \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`orgRevision\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgRevisionName\` varchar(255) NOT NULL DEFAULT 'string', \`orgRevisionIsCurrent\` tinyint NULL, \`orgRevisionCreatedAt\` datetime NULL, \`orgRevisionIsDraft\` tinyint NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_14edc901b52b66455dd4dd482e6\` FOREIGN KEY (\`fkOrgChild3Id\`) REFERENCES \`orgChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_04079b02cf09926cbe3e6409c75\` FOREIGN KEY (\`fkOrgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_616f862cd4f4135a33bd240e644\` FOREIGN KEY (\`fkOrgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD CONSTRAINT \`FK_71c1b84ce94a83cf5ee778ef463\` FOREIGN KEY (\`fkOrgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_36291e45193793ac8730d5b9ff4\` FOREIGN KEY (\`orgChild3Id\`) REFERENCES \`orgChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_abe35eefd8fb2bf682542c57b5e\` FOREIGN KEY (\`orgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_b3e512809e7e8dea0a6a1c0d95f\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD CONSTRAINT \`FK_9481ca31027bf02594ed533b765\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP FOREIGN KEY \`FK_71c1b84ce94a83cf5ee778ef463\``);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_616f862cd4f4135a33bd240e644\``);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_04079b02cf09926cbe3e6409c75\``);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_14edc901b52b66455dd4dd482e6\``);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP FOREIGN KEY \`FK_9481ca31027bf02594ed533b765\``);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_b3e512809e7e8dea0a6a1c0d95f\``);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_abe35eefd8fb2bf682542c57b5e\``);
|
||||
await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_36291e45193793ac8730d5b9ff4\``);
|
||||
await queryRunner.query(`DROP TABLE \`orgRevision\``);
|
||||
await queryRunner.query(`DROP TABLE \`orgRoot\``);
|
||||
await queryRunner.query(`DROP TABLE \`orgChild1\``);
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
import { Controller, ValidationService, FieldErrors, ValidateError, TsoaRoute, HttpStatusCodeLiteral, TsoaResponse, fetchMiddlewares } from '@tsoa/runtime';
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
import { OrgRootController } from './controllers/OrgRootController';
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
import { AppController } from './controllers/MyController';
|
||||
import { expressAuthentication } from './middlewares/auth';
|
||||
// @ts-ignore - no great way to install types from subpackage
|
||||
|
|
@ -11,6 +13,27 @@ import type { RequestHandler, Router } from 'express';
|
|||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
|
||||
const models: TsoaRoute.Models = {
|
||||
"OrgRootRank": {
|
||||
"dataType": "refEnum",
|
||||
"enums": ["department","office","division","section"],
|
||||
},
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
"CreateOrgRoot": {
|
||||
"dataType": "refObject",
|
||||
"properties": {
|
||||
"orgRootName": {"dataType":"string","required":true},
|
||||
"orgRootShortName": {"dataType":"string","required":true},
|
||||
"orgRootCode": {"dataType":"string","required":true},
|
||||
"orgRootRank": {"ref":"OrgRootRank","required":true},
|
||||
"orgRootOrder": {"dataType":"double","required":true},
|
||||
"orgRootPhoneEx": {"dataType":"string","required":true},
|
||||
"orgRootPhoneIn": {"dataType":"string","required":true},
|
||||
"orgRootFax": {"dataType":"string","required":true},
|
||||
"orgRootIsNormal": {"dataType":"boolean","required":true},
|
||||
},
|
||||
"additionalProperties": false,
|
||||
},
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
};
|
||||
const validationService = new ValidationService(models);
|
||||
|
||||
|
|
@ -21,6 +44,57 @@ export function RegisterRoutes(app: Router) {
|
|||
// NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
|
||||
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa
|
||||
// ###########################################################################################################
|
||||
app.post('/organization/root',
|
||||
...(fetchMiddlewares<RequestHandler>(OrgRootController)),
|
||||
...(fetchMiddlewares<RequestHandler>(OrgRootController.prototype.create)),
|
||||
|
||||
function OrgRootController_create(request: any, response: any, next: any) {
|
||||
const args = {
|
||||
requestBody: {"in":"body","name":"requestBody","required":true,"ref":"CreateOrgRoot"},
|
||||
};
|
||||
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
|
||||
let validatedArgs: any[] = [];
|
||||
try {
|
||||
validatedArgs = getValidatedArgs(args, request, response);
|
||||
|
||||
const controller = new OrgRootController();
|
||||
|
||||
|
||||
const promise = controller.create.apply(controller, validatedArgs as any);
|
||||
promiseHandler(controller, promise, response, undefined, next);
|
||||
} catch (err) {
|
||||
return next(err);
|
||||
}
|
||||
});
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
app.put('/organization/root/:id',
|
||||
...(fetchMiddlewares<RequestHandler>(OrgRootController)),
|
||||
...(fetchMiddlewares<RequestHandler>(OrgRootController.prototype.update)),
|
||||
|
||||
function OrgRootController_update(request: any, response: any, next: any) {
|
||||
const args = {
|
||||
id: {"in":"path","name":"id","required":true,"dataType":"string"},
|
||||
requestBody: {"in":"body","name":"requestBody","required":true,"ref":"CreateOrgRoot"},
|
||||
};
|
||||
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
|
||||
let validatedArgs: any[] = [];
|
||||
try {
|
||||
validatedArgs = getValidatedArgs(args, request, response);
|
||||
|
||||
const controller = new OrgRootController();
|
||||
|
||||
|
||||
const promise = controller.update.apply(controller, validatedArgs as any);
|
||||
promiseHandler(controller, promise, response, undefined, next);
|
||||
} catch (err) {
|
||||
return next(err);
|
||||
}
|
||||
});
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
app.get('/hello',
|
||||
authenticateMiddleware([{"bearerAuth":[]}]),
|
||||
...(fetchMiddlewares<RequestHandler>(AppController)),
|
||||
|
|
|
|||
163
src/swagger.json
163
src/swagger.json
|
|
@ -6,7 +6,62 @@
|
|||
"parameters": {},
|
||||
"requestBodies": {},
|
||||
"responses": {},
|
||||
"schemas": {},
|
||||
"schemas": {
|
||||
"OrgRootRank": {
|
||||
"enum": [
|
||||
"department",
|
||||
"office",
|
||||
"division",
|
||||
"section"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"CreateOrgRoot": {
|
||||
"properties": {
|
||||
"orgRootName": {
|
||||
"type": "string"
|
||||
},
|
||||
"orgRootShortName": {
|
||||
"type": "string"
|
||||
},
|
||||
"orgRootCode": {
|
||||
"type": "string"
|
||||
},
|
||||
"orgRootRank": {
|
||||
"$ref": "#/components/schemas/OrgRootRank"
|
||||
},
|
||||
"orgRootOrder": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"orgRootPhoneEx": {
|
||||
"type": "string"
|
||||
},
|
||||
"orgRootPhoneIn": {
|
||||
"type": "string"
|
||||
},
|
||||
"orgRootFax": {
|
||||
"type": "string"
|
||||
},
|
||||
"orgRootIsNormal": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"orgRootName",
|
||||
"orgRootShortName",
|
||||
"orgRootCode",
|
||||
"orgRootRank",
|
||||
"orgRootOrder",
|
||||
"orgRootPhoneEx",
|
||||
"orgRootPhoneIn",
|
||||
"orgRootFax",
|
||||
"orgRootIsNormal"
|
||||
],
|
||||
"type": "object",
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"securitySchemes": {
|
||||
"bearerAuth": {
|
||||
"type": "apiKey",
|
||||
|
|
@ -26,6 +81,112 @@
|
|||
}
|
||||
},
|
||||
"paths": {
|
||||
"/organization/root": {
|
||||
"post": {
|
||||
"operationId": "Create",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Ok",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {},
|
||||
"examples": {
|
||||
"Example 1": {
|
||||
"value": [
|
||||
{
|
||||
"orgRootName": "string",
|
||||
"orgRootShortName": "string",
|
||||
"orgRootCode": "string",
|
||||
"orgRootOrder": "number",
|
||||
"orgRootPhoneEx": "string",
|
||||
"orgRootPhoneIn": "string",
|
||||
"orgRootFax": "string",
|
||||
"orgRootIsNormal": "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "สร้างโครงสร้างระดับ Root",
|
||||
"summary": "ORG_001 - สร้างโครงสร้างระดับ Root (ADMIN) #1",
|
||||
"tags": [
|
||||
"OrgRoot"
|
||||
],
|
||||
"security": [],
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreateOrgRoot"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/organization/root/{id}": {
|
||||
"put": {
|
||||
"operationId": "Update",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Ok",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {},
|
||||
"examples": {
|
||||
"Example 1": {
|
||||
"value": [
|
||||
{
|
||||
"orgRootName": "string",
|
||||
"orgRootShortName": "string",
|
||||
"orgRootCode": "string",
|
||||
"orgRootOrder": "number",
|
||||
"orgRootPhoneEx": "string",
|
||||
"orgRootPhoneIn": "string",
|
||||
"orgRootFax": "string",
|
||||
"orgRootIsNormal": "boolean"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "แก้ไขโครงสร้างระดับ Root",
|
||||
"summary": "ORG_002 - แก้ไขโครงสร้างระดับ Root (ADMIN) #2",
|
||||
"tags": [
|
||||
"OrgRoot"
|
||||
],
|
||||
"security": [],
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Guid, *Id root",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreateOrgRoot"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/hello": {
|
||||
"get": {
|
||||
"operationId": "GET",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue