role โครงสร้างอัตรากำลัง
This commit is contained in:
parent
deb8194b7f
commit
2ce5138a4f
9 changed files with 109 additions and 48 deletions
|
|
@ -28,6 +28,8 @@ import { PosMaster } from "../entities/PosMaster";
|
|||
import { Position } from "../entities/Position";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||
import permission from "../interfaces/permission";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
|
||||
@Route("api/v1/org/root")
|
||||
@Tags("OrgRoot")
|
||||
|
|
@ -97,8 +99,9 @@ export class OrgRootController extends Controller {
|
|||
// @Path() id: string,
|
||||
@Body()
|
||||
requestBody: CreateOrgRoot,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_ORG");
|
||||
const validOrgRootRanks = ["DEPARTMENT", "OFFICE", "DIVISION", "SECTION"];
|
||||
if (!validOrgRootRanks.includes(requestBody.orgRootRank.toUpperCase())) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRootRank");
|
||||
|
|
@ -178,11 +181,12 @@ export class OrgRootController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: CreateOrgRoot,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
const validOrgRootRanks = ["DEPARTMENT", "OFFICE", "DIVISION", "SECTION"];
|
||||
if (!validOrgRootRanks.includes(requestBody.orgRootRank.toUpperCase())) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRootRank");
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRo otRank");
|
||||
}
|
||||
|
||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||
|
|
@ -322,7 +326,8 @@ export class OrgRootController extends Controller {
|
|||
* @param {string} id Guid, *Id root
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async delete(@Path() id: string) {
|
||||
async delete(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_ORG");
|
||||
const orgRoot = await this.orgRootRepository.findOne({ where: { id } });
|
||||
if (!orgRoot) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้างระดับ Root นี้");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue