role โครงสร้างอัตรากำลัง

This commit is contained in:
AdisakKanthawilang 2024-08-16 17:36:08 +07:00
parent deb8194b7f
commit 2ce5138a4f
9 changed files with 109 additions and 48 deletions

View file

@ -29,6 +29,8 @@ import { Position } from "../entities/Position";
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
import { EmployeePosition } from "../entities/EmployeePosition";
import { Like } from "typeorm/browser";
import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission";
@Route("api/v1/org/child1")
@Tags("OrgChild1")
@Security("bearerAuth")
@ -91,10 +93,8 @@ export class OrgChild1Controller {
*
*/
@Post()
async save(
@Body() requestBody: CreateOrgChild1,
@Request() request: { user: Record<string, any> },
) {
async save(@Body() requestBody: CreateOrgChild1, @Request() request: RequestWithUser) {
await new permission().PermissionCreate(request, "SYS_ORG");
const rootIdExits = await this.orgRootRepository.findOne({
where: { id: requestBody.orgRootId },
});
@ -186,8 +186,9 @@ export class OrgChild1Controller {
async Edit(
@Path() id: string,
@Body() requestBody: UpdateOrgChild1,
@Request() request: { user: Record<string, any> },
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_ORG");
const rootIdExits = await this.orgRootRepository.findOne({
where: { id: requestBody.orgRootId },
});
@ -320,7 +321,8 @@ export class OrgChild1Controller {
* @param {string} id id 1
*/
@Delete("{id}")
async delete(@Path() id: string) {
async delete(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request, "SYS_ORG");
const child1 = await this.child1Repository.findOne({ where: { id } });
if (!child1) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");