api ค้นหารายการตำแหน่ง (ยังไม่เสร็จ)
This commit is contained in:
parent
d3cfe0855a
commit
a1226bfbfc
1 changed files with 69 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ import {
|
|||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
|
@ -23,6 +24,7 @@ import { PosType } from "../entities/PosType";
|
|||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { CreatePosDict, PosDict } from "../entities/PosDict";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Like } from "typeorm";
|
||||
@Route("api/v1/org/pos")
|
||||
@Tags("Position")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -246,5 +248,71 @@ export class PositionController extends Controller {
|
|||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API ค้นหารายการตำแหน่ง
|
||||
*
|
||||
* @summary ORG_029 - ค้นหารายการตำแหน่ง (ADMIN) #32
|
||||
*
|
||||
*/
|
||||
@Get("position")
|
||||
async findPosition(@Query("keyword") keyword: string, @Query("type") type: string){
|
||||
|
||||
// { id: "positionName", name: "ตำแหน่งในสายงาน" }
|
||||
// { id: "positionField", name: "สายงาน" }
|
||||
// { id: "positionType", name: "ประเภทตำแหน่ง" }
|
||||
// { id: "positionLevel", name: "ระดับตำแหน่ง" }
|
||||
// { id: "positionExecutive", name: "ตำแหน่งทางการบริหาร" }
|
||||
// { id: "positionExecutiveField", name: "ด้านทางการบริหาร" }
|
||||
// { id: "positionArea", name: "ด้าน/สาขา" }
|
||||
|
||||
try{
|
||||
let findPosDict: any;
|
||||
console.log("type: ", type)
|
||||
console.log("keyword: ", keyword)
|
||||
|
||||
switch(type){
|
||||
case "positionName":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posDictName: Like(`%${keyword}%`) } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
}
|
||||
case "positionField":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posDictField: Like(`%${keyword}%`) } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
}
|
||||
case "positionType":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posTypeId: Like(`%${keyword}%`) } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
}
|
||||
case "positionLevel":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posLevelId: Like(`%${keyword}%`) } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
}
|
||||
case "positionExecutive":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posExecutiveId: Like(`%${keyword}%`) } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
}
|
||||
case "positionExecutiveField":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posDictExecutiveField: Like(`%${keyword}%`) } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
}
|
||||
case "positionArea":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posDictArea: Like(`%${keyword}%`) } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
}
|
||||
}
|
||||
return new HttpSuccess(findPosDict);
|
||||
}
|
||||
catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue