bug search org_053
This commit is contained in:
parent
38f44d8f36
commit
73bd1bc604
1 changed files with 93 additions and 2 deletions
|
|
@ -24,7 +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 { In, IsNull, Like, Not } from "typeorm";
|
||||
import { ILike, In, IsNull, Like, Not } from "typeorm";
|
||||
import { CreatePosMaster, PosMaster } from "../entities/PosMaster";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
|
|
@ -774,11 +774,20 @@ export class PositionController extends Controller {
|
|||
orgChild4Id: body.id,
|
||||
};
|
||||
}
|
||||
|
||||
const keywordCondition = {}
|
||||
? {
|
||||
posMasterNoPrefix: Like(`%${body.keyword}%`),
|
||||
positionName: Like(`%${body.keyword}%`),
|
||||
posTypeName: Like(`%${body.keyword}%`),
|
||||
posLevelName: Like(`%${body.keyword}%`),
|
||||
}
|
||||
: {};
|
||||
|
||||
const posMaster = await this.posMasterRepository.find({
|
||||
where: {
|
||||
...typeCondition,
|
||||
...checkChildConditions,
|
||||
...keywordCondition,
|
||||
},
|
||||
skip: (body.page - 1) * body.pageSize,
|
||||
take: body.pageSize,
|
||||
|
|
@ -988,4 +997,86 @@ export class PositionController extends Controller {
|
|||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API เพิ่มตำแหน่งทางการบริหาร
|
||||
*
|
||||
* @summary ORG_041 - เพิ่มตำแหน่งทางการบริหาร (ADMIN) #44
|
||||
*
|
||||
*/
|
||||
@Post("executive")
|
||||
async createPosExecutive(
|
||||
@Body()
|
||||
requestBody: CreatePosMaster,
|
||||
@Request() request: { user: Record<string, any> }
|
||||
) {
|
||||
const posExecutive = Object.assign(new PosExecutive(), requestBody);
|
||||
if (!posExecutive) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
posExecutive.createdUserId = request.user.sub;
|
||||
posExecutive.createdFullName = request.user.name;
|
||||
posExecutive.lastUpdateUserId = request.user.sub;
|
||||
posExecutive.lastUpdateFullName = request.user.name;
|
||||
await this.posExecutiveRepository.save(posExecutive);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขตำแหน่งทางการบริหาร
|
||||
*
|
||||
* @summary ORG_042 - แก้ไขตำแหน่งทางการบริหาร (ADMIN) #45
|
||||
*
|
||||
* @param {string} id Id ตำแหน่งทางการบริหาร
|
||||
*/
|
||||
@Put("executive/{id}")
|
||||
async updatePosExecutive(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: CreatePosMaster,
|
||||
@Request() request: { user: Record<string, any> }
|
||||
) {
|
||||
const posExecutive = Object.assign(new PosExecutive(), requestBody);
|
||||
if (!posExecutive) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
||||
}
|
||||
try {
|
||||
posExecutive.lastUpdateUserId = request.user.sub;
|
||||
posExecutive.lastUpdateFullName = request.user.name;
|
||||
await this.posExecutiveRepository.save(posExecutive);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API ลบอัตรากำลัง
|
||||
*
|
||||
* @summary ORG_043 - ลบตำแหน่งทางการบริหาร (ADMIN) #46
|
||||
*
|
||||
* @param {string} id Id ตำแหน่ง
|
||||
*/
|
||||
@Delete("executive/{id}")
|
||||
async deletePosExecutive(@Path() id: string) {
|
||||
const delPosExecutive = await this.posExecutiveRepository.findOne({
|
||||
where: { id },
|
||||
});
|
||||
if (!delPosExecutive) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งตามไอดีนี้ : " + id);
|
||||
}
|
||||
try {
|
||||
await this.positionRepository.delete({ posExecutiveId: id });
|
||||
await this.posExecutiveRepository.delete({ id });
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue