checkpoint
This commit is contained in:
parent
ba60192ec1
commit
d737ecdf11
11 changed files with 452 additions and 49 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue