2024-03-26 09:47:17 +07:00
|
|
|
import {
|
|
|
|
|
Controller,
|
|
|
|
|
Post,
|
|
|
|
|
Put,
|
|
|
|
|
Delete,
|
|
|
|
|
Route,
|
|
|
|
|
Security,
|
|
|
|
|
Tags,
|
|
|
|
|
Body,
|
|
|
|
|
Path,
|
|
|
|
|
Request,
|
|
|
|
|
SuccessResponse,
|
|
|
|
|
Response,
|
|
|
|
|
Get,
|
|
|
|
|
Query,
|
|
|
|
|
Example,
|
|
|
|
|
} from "tsoa";
|
|
|
|
|
import { AppDataSource } from "../database/data-source";
|
|
|
|
|
import HttpSuccess from "../interfaces/http-success";
|
|
|
|
|
import HttpStatus from "../interfaces/http-status";
|
|
|
|
|
import HttpError from "../interfaces/http-error";
|
|
|
|
|
import { Profile, CreateProfile, UpdateProfile, ProfileHistory } from "../entities/Profile";
|
|
|
|
|
import { Brackets, IsNull, Like, Not } from "typeorm";
|
|
|
|
|
import { OrgRevision } from "../entities/OrgRevision";
|
|
|
|
|
import { PosMaster } from "../entities/PosMaster";
|
|
|
|
|
import { PosLevel } from "../entities/PosLevel";
|
|
|
|
|
import { PosType } from "../entities/PosType";
|
|
|
|
|
import { calculateRetireDate, calculateRetireYear } from "../interfaces/utils";
|
|
|
|
|
import { RequestWithUser } from "../middlewares/user";
|
2024-03-26 13:57:02 +07:00
|
|
|
import { BloodGroup } from "../entities/BloodGroup";
|
|
|
|
|
import { EducationLevel } from "../entities/EducationLevel";
|
|
|
|
|
import { Gender } from "../entities/Gender";
|
|
|
|
|
import { Prefixe } from "../entities/Prefixe";
|
|
|
|
|
import { Relationship } from "../entities/Relationship";
|
|
|
|
|
import { Religion } from "../entities/Religion";
|
2024-03-26 23:07:55 +07:00
|
|
|
import { Rank } from "../entities/Rank";
|
2024-03-26 13:57:02 +07:00
|
|
|
|
|
|
|
|
@Route("api/v1/org/metadata")
|
2024-03-26 09:47:17 +07:00
|
|
|
@Tags("Profile")
|
|
|
|
|
@Security("bearerAuth")
|
|
|
|
|
@Response(
|
|
|
|
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
|
|
|
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
|
|
|
)
|
|
|
|
|
@SuccessResponse(HttpStatus.OK, "สำเร็จ")
|
|
|
|
|
export class MainController extends Controller {
|
2024-03-26 13:57:02 +07:00
|
|
|
private bloodGroupRepo = AppDataSource.getRepository(BloodGroup);
|
|
|
|
|
private educationLevelRepo = AppDataSource.getRepository(EducationLevel);
|
|
|
|
|
private genderRepo = AppDataSource.getRepository(Gender);
|
|
|
|
|
private prefixeRepo = AppDataSource.getRepository(Prefixe);
|
|
|
|
|
private relationshipRepo = AppDataSource.getRepository(Relationship);
|
|
|
|
|
private religionRepo = AppDataSource.getRepository(Religion);
|
2024-03-26 23:07:55 +07:00
|
|
|
private rankRepo = AppDataSource.getRepository(Rank);
|
2024-03-26 09:47:17 +07:00
|
|
|
/**
|
2024-03-26 13:57:02 +07:00
|
|
|
* API ข้อมูลหลัก
|
2024-03-26 09:47:17 +07:00
|
|
|
*
|
2024-03-26 13:57:02 +07:00
|
|
|
* @summary ORG_065 - ข้อมูลหลัก
|
2024-03-26 09:47:17 +07:00
|
|
|
*
|
|
|
|
|
*/
|
2024-03-26 13:57:02 +07:00
|
|
|
@Get("main/person")
|
|
|
|
|
async getMainPerson() {
|
|
|
|
|
const bloodGroups = await this.bloodGroupRepo.find();
|
|
|
|
|
const genders = await this.genderRepo.find();
|
|
|
|
|
const prefixs = await this.prefixeRepo.find();
|
|
|
|
|
const relationships = await this.relationshipRepo.find();
|
|
|
|
|
const religions = await this.religionRepo.find();
|
2024-03-26 23:07:55 +07:00
|
|
|
const rank = await this.rankRepo.find();
|
2024-03-26 13:57:02 +07:00
|
|
|
|
2024-03-26 23:07:55 +07:00
|
|
|
return new HttpSuccess({ bloodGroups, genders, prefixs, relationships, religions, rank });
|
2024-03-26 09:47:17 +07:00
|
|
|
}
|
|
|
|
|
}
|