Merge branch 'adiDev' into develop
This commit is contained in:
commit
ed4d07a439
1 changed files with 35 additions and 6 deletions
|
|
@ -11,13 +11,13 @@ import {
|
|||
Request,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Get,
|
||||
} 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 HttpError from "../interfaces/http-error";
|
||||
import { CreatePosMaster, PosMaster } from "../entities/PosMaster";
|
||||
import { CreatePosExecutive, PosExecutive } from "../entities/PosExecutive";
|
||||
import { Position } from "../entities/Position";
|
||||
@Route("api/v1/org/pos")
|
||||
@Tags("PosExecutive")
|
||||
|
|
@ -40,7 +40,7 @@ export class PosExecutiveController extends Controller {
|
|||
@Post("executive")
|
||||
async createPosExecutive(
|
||||
@Body()
|
||||
requestBody: CreatePosMaster,
|
||||
requestBody: CreatePosExecutive,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const posExecutive = Object.assign(new PosExecutive(), requestBody);
|
||||
|
|
@ -70,16 +70,17 @@ export class PosExecutiveController extends Controller {
|
|||
async updatePosExecutive(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: CreatePosMaster,
|
||||
requestBody: CreatePosExecutive,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const posExecutive = Object.assign(new PosExecutive(), requestBody);
|
||||
const posExecutive = await this.posExecutiveRepository.findOne({where: {id: id}});
|
||||
if (!posExecutive) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
|
||||
}
|
||||
try {
|
||||
posExecutive.lastUpdateUserId = request.user.sub;
|
||||
posExecutive.lastUpdateFullName = request.user.name;
|
||||
this.posExecutiveRepository.merge(posExecutive, requestBody);
|
||||
await this.posExecutiveRepository.save(posExecutive);
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
|
|
@ -92,7 +93,7 @@ export class PosExecutiveController extends Controller {
|
|||
*
|
||||
* @summary ORG_043 - ลบตำแหน่งทางการบริหาร (ADMIN) #46
|
||||
*
|
||||
* @param {string} id Id ตำแหน่ง
|
||||
* @param {string} id Id ตำแหน่งทางการบริหาร
|
||||
*/
|
||||
@Delete("executive/{id}")
|
||||
async deletePosExecutive(@Path() id: string) {
|
||||
|
|
@ -110,4 +111,32 @@ export class PosExecutiveController extends Controller {
|
|||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดตำแหน่งทางการบริหาร
|
||||
*
|
||||
* @summary ORG_044 - รายละเอียดตำแหน่งทางการบริหาร (ADMIN) #47
|
||||
*
|
||||
* @param {string} id Id ตำแหน่งทางการบริหาร
|
||||
*/
|
||||
@Get("executive/{id}")
|
||||
async detailPosExecutive(@Path() id: string) {
|
||||
|
||||
const posExecutive = await this.posExecutiveRepository.findOne({
|
||||
where: { id },
|
||||
select:[
|
||||
"id",
|
||||
"posExecutiveName",
|
||||
"posExecutivePriority"
|
||||
]
|
||||
});
|
||||
if (!posExecutive) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
try {
|
||||
return new HttpSuccess(posExecutive);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue