hrms-api-org/src/controllers/ReportController.ts

95 lines
3.5 KiB
TypeScript

import {
Controller,
Get,
Post,
Put,
Delete,
Patch,
Route,
Security,
Tags,
Body,
Path,
Request,
Example,
SuccessResponse,
Response,
Query,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status";
import { PosExecutive } from "../entities/PosExecutive";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
import { CreatePosDict, PosDict } from "../entities/PosDict";
import HttpError from "../interfaces/http-error";
import { Equal, ILike, In, IsNull, Like, Not } from "typeorm";
import { CreatePosMaster, PosMaster } from "../entities/PosMaster";
import { OrgRevision } from "../entities/OrgRevision";
import { OrgRoot } from "../entities/OrgRoot";
import { OrgChild1 } from "../entities/OrgChild1";
import { OrgChild2 } from "../entities/OrgChild2";
import { OrgChild3 } from "../entities/OrgChild3";
import { OrgChild4 } from "../entities/OrgChild4";
import { Position } from "../entities/Position";
import { Brackets } from "typeorm/browser";
@Route("api/v1/org/report")
@Tags("Position")
@Security("bearerAuth")
@Response(
HttpStatusCode.INTERNAL_SERVER_ERROR,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
)
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
export class ReportController extends Controller {
private posExecutiveRepository = AppDataSource.getRepository(PosExecutive);
private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel);
private posDictRepository = AppDataSource.getRepository(PosDict);
private posMasterRepository = AppDataSource.getRepository(PosMaster);
private positionRepository = AppDataSource.getRepository(Position);
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1);
private child2Repository = AppDataSource.getRepository(OrgChild2);
private child3Repository = AppDataSource.getRepository(OrgChild3);
private child4Repository = AppDataSource.getRepository(OrgChild4);
/**
* API ค้นหารายการตำแหน่ง
*
* @summary ORG_029 - ค้นหารายการตำแหน่ง (ADMIN) #32
*
*/
@Get("position")
async findPosition() {
try {
// const getPosType = await this.posTypeRepository.findOne({
// select: ["id", "posTypeName", "posTypeRank"],
// relations: ["posLevels"],
// where: { id: id },
// });
// if (!getPosType) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
// }
// const mapGetPosType = {
// id: getPosType.id,
// posTypeName: getPosType.posTypeName,
// posTypeRank: getPosType.posTypeRank,
// posLevels: getPosType.posLevels.map((posLevel) => ({
// id: posLevel.id,
// posLevelName: posLevel.posLevelName,
// posLevelRank: posLevel.posLevelRank,
// posLevelAuthority: posLevel.posLevelAuthority,
// })),
// };
return new HttpSuccess();
} catch (error) {
return error;
}
}
}