fixing path
This commit is contained in:
parent
400b9c0b28
commit
ba612f1b2b
12 changed files with 325 additions and 723 deletions
|
|
@ -21,12 +21,12 @@ import { Personal, PostPersonal } from "../entities/Personal";
|
|||
import permission from "../interfaces/permission";
|
||||
import { Assign } from "../entities/Assign";
|
||||
|
||||
@Route("api/v1/personal")
|
||||
@Route("api/v1/probation/personal")
|
||||
@Tags("Personal")
|
||||
@Security("bearerAuth")
|
||||
@Response(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class PersonalController extends Controller {
|
||||
|
|
@ -40,43 +40,25 @@ export class PersonalController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post("add")
|
||||
async AddPersonal(
|
||||
@Body() requestBody: PostPersonal,
|
||||
@Request() request: RequestWithUser
|
||||
) {
|
||||
async AddPersonal(@Body() requestBody: PostPersonal, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_PROBATION");
|
||||
|
||||
const checkPersonal: number = await this.personalRepository.count({
|
||||
where: { personal_id: requestBody.id },
|
||||
});
|
||||
if (checkPersonal > 0) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.BAD_REQUEST,
|
||||
"ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.BAD_REQUEST, "ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว");
|
||||
}
|
||||
|
||||
let organization = await (requestBody.orgChild4Name
|
||||
? requestBody.orgChild4Name + "/"
|
||||
: "");
|
||||
organization += await (requestBody.orgChild3Name
|
||||
? requestBody.orgChild3Name + "/"
|
||||
: "");
|
||||
organization += await (requestBody.orgChild2Name
|
||||
? requestBody.orgChild2Name + "/"
|
||||
: "");
|
||||
organization += await (requestBody.orgChild1Name
|
||||
? requestBody.orgChild1Name + "/"
|
||||
: "");
|
||||
organization += await (requestBody.orgRootName
|
||||
? requestBody.orgRootName
|
||||
: "");
|
||||
let organization = await (requestBody.orgChild4Name ? requestBody.orgChild4Name + "/" : "");
|
||||
organization += await (requestBody.orgChild3Name ? requestBody.orgChild3Name + "/" : "");
|
||||
organization += await (requestBody.orgChild2Name ? requestBody.orgChild2Name + "/" : "");
|
||||
organization += await (requestBody.orgChild1Name ? requestBody.orgChild1Name + "/" : "");
|
||||
organization += await (requestBody.orgRootName ? requestBody.orgRootName : "");
|
||||
|
||||
const personalData = Object.assign(new Personal());
|
||||
personalData.personal_id = requestBody.id;
|
||||
personalData.order_number = requestBody.order_number
|
||||
? requestBody.order_number
|
||||
: "";
|
||||
personalData.order_number = requestBody.order_number ? requestBody.order_number : "";
|
||||
personalData.probation_status = 1;
|
||||
personalData.createdUserId = request.user.sub;
|
||||
personalData.createdFullName = request.user.name;
|
||||
|
|
@ -87,12 +69,8 @@ export class PersonalController extends Controller {
|
|||
personalData.firstName = requestBody.firstName;
|
||||
personalData.lastName = requestBody.lastName;
|
||||
personalData.isProbation = requestBody.isProbation ? 1 : 0;
|
||||
personalData.positionLevelName = requestBody.posLevelName
|
||||
? requestBody.posLevelName
|
||||
: "";
|
||||
personalData.positionName = requestBody.position
|
||||
? requestBody.position
|
||||
: "";
|
||||
personalData.positionLevelName = requestBody.posLevelName ? requestBody.posLevelName : "";
|
||||
personalData.positionName = requestBody.position ? requestBody.position : "";
|
||||
personalData.positionLineName = requestBody.posLineName;
|
||||
personalData.positionTypeName = requestBody.posTypeName;
|
||||
personalData.posNo = requestBody.posNo ? requestBody.posNo : "";
|
||||
|
|
@ -122,10 +100,7 @@ export class PersonalController extends Controller {
|
|||
});
|
||||
|
||||
if (!lists) {
|
||||
return new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถแสดงข้อมูลได้"
|
||||
);
|
||||
return new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ไม่สามารถแสดงข้อมูลได้");
|
||||
}
|
||||
|
||||
let result: any = [];
|
||||
|
|
@ -148,7 +123,7 @@ export class PersonalController extends Controller {
|
|||
order_number: item.order_number,
|
||||
probation_status: item.probation_status,
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess(result);
|
||||
|
|
@ -161,10 +136,7 @@ export class PersonalController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("")
|
||||
async GetPersonal(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query() personal_id: string
|
||||
) {
|
||||
async GetPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
||||
await new permission().PermissionList(request, "SYS_PROBATION");
|
||||
const person = await this.personalRepository.findOne({
|
||||
where: { personal_id: personal_id },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue