สกจ มอบหมาย
This commit is contained in:
parent
41e82a92f9
commit
3d8b66d3cc
1 changed files with 29 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Body, Controller, Get, Post, Request, Route, Security, Tags } from "tsoa";
|
||||
import { Body, Controller, Get, Path, Post, Request, Route, Security, Tags } from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
|
|
@ -664,4 +664,32 @@ export class WorkflowController extends Controller {
|
|||
|
||||
return new HttpSuccess(_posMasters);
|
||||
}
|
||||
|
||||
/**
|
||||
* API เช็ค สกจ
|
||||
*
|
||||
* @summary เช็ค สกจ
|
||||
*
|
||||
*/
|
||||
@Get("keycloak/isofficer/{system}")
|
||||
async getIsOfficerByKeycloak(@Path() system: string, @Request() req: RequestWithUser) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: {
|
||||
keycloak: req.user.sub,
|
||||
},
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||
|
||||
const profileOfficer = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
posMasterAssigns: { assignId: system },
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
current_holderId: profile.id,
|
||||
},
|
||||
relations: ["orgChild1"],
|
||||
});
|
||||
if (!profileOfficer) return new HttpSuccess({ isOfficer: false, isStaff: false });
|
||||
let isOfficer = profileOfficer.orgChild1 == null ? false : profileOfficer.orgChild1.isOfficer;
|
||||
return new HttpSuccess({ isOfficer: isOfficer, isStaff: !isOfficer });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue