fix
This commit is contained in:
parent
de27e1941b
commit
644a1e9b5d
2 changed files with 8 additions and 13 deletions
|
|
@ -16,7 +16,6 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { AuthRoleAttr, CreateAuthRoleAttr, UpdateAuthRoleAttr } from "../entities/AuthRoleAttr";
|
||||
import { AuthRole } from "../entities/AuthRole";
|
||||
import { AuthSys } from "../entities/AuthSys";
|
||||
|
|
@ -111,15 +110,7 @@ export class AuthRoleAttrController extends Controller {
|
|||
|
||||
@Delete("{roleAttrId}")
|
||||
public async deleteRole(@Path() roleAttrId: string) {
|
||||
let result: any;
|
||||
try {
|
||||
result = await this.authRoleAttrRepo.delete({ id: roleAttrId });
|
||||
} catch {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบข้อมูลได้",
|
||||
);
|
||||
}
|
||||
const result = await this.authRoleAttrRepo.delete({ id: roleAttrId });
|
||||
if (result.affected == undefined || result.affected <= 0)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { AuthRole, CreateAuthRole, UpdateAuthRole } from "../entities/AuthRole";
|
||||
|
||||
@Route("api/v1/org/auth/authRole")
|
||||
|
|
@ -44,7 +45,6 @@ export class AuthRoleController extends Controller {
|
|||
|
||||
@Post()
|
||||
public async newAuthRole(@Request() req: RequestWithUser, @Body() body: CreateAuthRole) {
|
||||
|
||||
const data = new AuthRole();
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
|
|
@ -78,8 +78,12 @@ export class AuthRoleController extends Controller {
|
|||
|
||||
@Delete("{roleId}")
|
||||
public async deleteRole(@Path() roleId: string) {
|
||||
const result = await this.authRoleRepo.delete({ id: roleId });
|
||||
|
||||
let result: any;
|
||||
try {
|
||||
result = await this.authRoleRepo.delete({ id: roleId });
|
||||
} catch {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้");
|
||||
}
|
||||
if (result.affected == undefined || result.affected <= 0)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue