move get
This commit is contained in:
parent
ed4d07a439
commit
f6bf6ef536
2 changed files with 34 additions and 127 deletions
|
|
@ -12,6 +12,7 @@ import {
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
Get,
|
Get,
|
||||||
|
Example
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
|
@ -19,7 +20,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { CreatePosExecutive, PosExecutive } from "../entities/PosExecutive";
|
import { CreatePosExecutive, PosExecutive } from "../entities/PosExecutive";
|
||||||
import { Position } from "../entities/Position";
|
import { Position } from "../entities/Position";
|
||||||
@Route("api/v1/org/pos")
|
@Route("api/v1/org/pos/executive")
|
||||||
@Tags("PosExecutive")
|
@Tags("PosExecutive")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(
|
||||||
|
|
@ -37,7 +38,7 @@ export class PosExecutiveController extends Controller {
|
||||||
* @summary ORG_041 - เพิ่มตำแหน่งทางการบริหาร (ADMIN) #44
|
* @summary ORG_041 - เพิ่มตำแหน่งทางการบริหาร (ADMIN) #44
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("executive")
|
@Post()
|
||||||
async createPosExecutive(
|
async createPosExecutive(
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: CreatePosExecutive,
|
requestBody: CreatePosExecutive,
|
||||||
|
|
@ -66,7 +67,7 @@ export class PosExecutiveController extends Controller {
|
||||||
*
|
*
|
||||||
* @param {string} id Id ตำแหน่งทางการบริหาร
|
* @param {string} id Id ตำแหน่งทางการบริหาร
|
||||||
*/
|
*/
|
||||||
@Put("executive/{id}")
|
@Put("{id}")
|
||||||
async updatePosExecutive(
|
async updatePosExecutive(
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body()
|
@Body()
|
||||||
|
|
@ -95,7 +96,7 @@ export class PosExecutiveController extends Controller {
|
||||||
*
|
*
|
||||||
* @param {string} id Id ตำแหน่งทางการบริหาร
|
* @param {string} id Id ตำแหน่งทางการบริหาร
|
||||||
*/
|
*/
|
||||||
@Delete("executive/{id}")
|
@Delete("{id}")
|
||||||
async deletePosExecutive(@Path() id: string) {
|
async deletePosExecutive(@Path() id: string) {
|
||||||
const delPosExecutive = await this.posExecutiveRepository.findOne({
|
const delPosExecutive = await this.posExecutiveRepository.findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
|
|
@ -119,7 +120,7 @@ export class PosExecutiveController extends Controller {
|
||||||
*
|
*
|
||||||
* @param {string} id Id ตำแหน่งทางการบริหาร
|
* @param {string} id Id ตำแหน่งทางการบริหาร
|
||||||
*/
|
*/
|
||||||
@Get("executive/{id}")
|
@Get("{id}")
|
||||||
async detailPosExecutive(@Path() id: string) {
|
async detailPosExecutive(@Path() id: string) {
|
||||||
|
|
||||||
const posExecutive = await this.posExecutiveRepository.findOne({
|
const posExecutive = await this.posExecutiveRepository.findOne({
|
||||||
|
|
@ -139,4 +140,32 @@ export class PosExecutiveController extends Controller {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API รายการตำแหน่งทางการบริหาร
|
||||||
|
*
|
||||||
|
* @summary ORG_026 - รายการตำแหน่งทางการบริหาร (ADMIN) #28
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get()
|
||||||
|
@Example([
|
||||||
|
{
|
||||||
|
id: "00000000-0000-0000-0000-000000000000",
|
||||||
|
posExecutiveName: "นักบริหาร",
|
||||||
|
posExecutivePriority: 1,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
async GetPosExecutive() {
|
||||||
|
try {
|
||||||
|
const posExecutive = await this.posExecutiveRepository.find({
|
||||||
|
select: ["id", "posExecutiveName", "posExecutivePriority"],
|
||||||
|
});
|
||||||
|
if (!posExecutive) {
|
||||||
|
return new HttpSuccess([]);
|
||||||
|
}
|
||||||
|
return new HttpSuccess(posExecutive);
|
||||||
|
} catch (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,128 +57,6 @@ export class PositionController extends Controller {
|
||||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||||
|
|
||||||
/**
|
|
||||||
* API รายการตำแหน่งทางการบริหาร
|
|
||||||
*
|
|
||||||
* @summary ORG_026 - รายการตำแหน่งทางการบริหาร (ADMIN) #28
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Get("executive")
|
|
||||||
@Example([
|
|
||||||
{
|
|
||||||
id: "00000000-0000-0000-0000-000000000000",
|
|
||||||
posExecutiveName: "นักบริหาร",
|
|
||||||
posExecutivePriority: 1,
|
|
||||||
},
|
|
||||||
])
|
|
||||||
async GetPosExecutive() {
|
|
||||||
try {
|
|
||||||
const posExecutive = await this.posExecutiveRepository.find({
|
|
||||||
select: ["id", "posExecutiveName", "posExecutivePriority"],
|
|
||||||
});
|
|
||||||
if (!posExecutive) {
|
|
||||||
return new HttpSuccess([]);
|
|
||||||
}
|
|
||||||
return new HttpSuccess(posExecutive);
|
|
||||||
} catch (error) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * API รายการประเภทตำแหน่ง
|
|
||||||
// *
|
|
||||||
// * @summary ORG_027 - รายการประเภทตำแหน่ง (ADMIN) #29
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
// @Get("type")
|
|
||||||
// @Example([
|
|
||||||
// {
|
|
||||||
// id: "00000000-0000-0000-0000-000000000000",
|
|
||||||
// posTypeName: "นักบริหาร",
|
|
||||||
// posTypeRank: 1,
|
|
||||||
// posLevels: [
|
|
||||||
// {
|
|
||||||
// id: "00000000-0000-0000-0000-000000000000",
|
|
||||||
// posLevelName: "นักบริหาร",
|
|
||||||
// posLevelRank: 1,
|
|
||||||
// posLevelAuthority: "HEAD",
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// ])
|
|
||||||
// async GetPosType() {
|
|
||||||
// try {
|
|
||||||
// const posType = await this.posTypeRepository.find({
|
|
||||||
// select: ["id", "posTypeName", "posTypeRank"],
|
|
||||||
// relations: ["posLevels"],
|
|
||||||
// });
|
|
||||||
// if (!posType) {
|
|
||||||
// return new HttpSuccess([]);
|
|
||||||
// }
|
|
||||||
// const mapPosType = posType.map((item) => ({
|
|
||||||
// id: item.id,
|
|
||||||
// posTypeName: item.posTypeName,
|
|
||||||
// posTypeRank: item.posTypeRank,
|
|
||||||
// posLevels: item.posLevels.map((posLevel) => ({
|
|
||||||
// id: posLevel.id,
|
|
||||||
// posLevelName: posLevel.posLevelName,
|
|
||||||
// posLevelRank: posLevel.posLevelRank,
|
|
||||||
// posLevelAuthority: posLevel.posLevelAuthority,
|
|
||||||
// })),
|
|
||||||
// }));
|
|
||||||
// return new HttpSuccess(mapPosType);
|
|
||||||
// } catch (error) {
|
|
||||||
// return error;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API รายการระดับตำแหน่ง
|
|
||||||
*
|
|
||||||
* @summary ORG_028 - รายการระดับตำแหน่ง (ADMIN) #30
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Get("level")
|
|
||||||
@Example([
|
|
||||||
{
|
|
||||||
id: "00000000-0000-0000-0000-000000000000",
|
|
||||||
posLevelName: "นักบริหาร",
|
|
||||||
posLevelRank: 1,
|
|
||||||
posLevelAuthority: "HEAD",
|
|
||||||
posTypes: {
|
|
||||||
id: "00000000-0000-0000-0000-000000000000",
|
|
||||||
posTypeName: "นักบริหาร",
|
|
||||||
posTypeRank: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
async GetPosLevel() {
|
|
||||||
try {
|
|
||||||
const posLevel = await this.posLevelRepository.find({
|
|
||||||
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority", "posTypeId"],
|
|
||||||
relations: ["posType"],
|
|
||||||
});
|
|
||||||
if (!posLevel) {
|
|
||||||
return new HttpSuccess([]);
|
|
||||||
}
|
|
||||||
const mapPosLevel = posLevel.map((item) => ({
|
|
||||||
id: item.id,
|
|
||||||
posLevelName: item.posLevelName,
|
|
||||||
posLevelRank: item.posLevelRank,
|
|
||||||
posLevelAuthority: item.posLevelAuthority,
|
|
||||||
posTypes: {
|
|
||||||
id: item.posType.id,
|
|
||||||
posTypeName: item.posType.posTypeName,
|
|
||||||
posTypeRank: item.posType.posTypeRank,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
return new HttpSuccess(mapPosLevel);
|
|
||||||
} catch (error) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มตำแหน่ง
|
* API เพิ่มตำแหน่ง
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue