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

45 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-08-27 16:37:42 +07:00
import { Controller, Route, Security, Tags, SuccessResponse, Response, Get } from "tsoa";
2024-03-26 09:47:17 +07:00
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import { BloodGroup } from "../entities/BloodGroup";
import { Gender } from "../entities/Gender";
import { Prefixe } from "../entities/Prefixe";
import { Relationship } from "../entities/Relationship";
import { Religion } from "../entities/Religion";
import { Rank } from "../entities/Rank";
@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 {
private bloodGroupRepo = AppDataSource.getRepository(BloodGroup);
private genderRepo = AppDataSource.getRepository(Gender);
private prefixeRepo = AppDataSource.getRepository(Prefixe);
private relationshipRepo = AppDataSource.getRepository(Relationship);
private religionRepo = AppDataSource.getRepository(Religion);
private rankRepo = AppDataSource.getRepository(Rank);
2024-03-26 09:47:17 +07:00
/**
* API
2024-03-26 09:47:17 +07:00
*
* @summary ORG_065 -
2024-03-26 09:47:17 +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();
const rank = await this.rankRepo.find();
return new HttpSuccess({ bloodGroups, genders, prefixs, relationships, religions, rank });
2024-03-26 09:47:17 +07:00
}
}