update swagger done

This commit is contained in:
2024-11-27 07:44:45 +07:00
parent d5cd47f17a
commit 4a8fde1640
10 changed files with 477 additions and 255 deletions

View File

@ -8,6 +8,7 @@ import { Paging } from "../types/paging";
import CommonHelper from "../helpers/common";
import { Status } from "../types/status";
import { UserRole } from "../entity/users_roles";
import { RoleList } from "../types/role";
const log: Logger<ILogObj> = new Logger({ name: '[UserRoleController]', type: 'pretty' });
@ -15,6 +16,9 @@ export class UserRoleController {
static async list(req: Request, res: Response, next: NextFunction): Promise<Response> {
/*
#swagger.tags = ['User Roles']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['filter'] = {
in: 'query',
type: 'string'
@ -98,19 +102,46 @@ export class UserRoleController {
}
}
static async role(req: Request, res: Response, next: NextFunction): Promise<Response> {
/*
#swagger.tags = ['User Roles']
#swagger.security = [{
"bearerAuth": []
}]
*/
try {
const current_page = 1;
const total_count_data = CommonHelper.countObject(RoleList);
const list_data = CommonHelper.objectFlip(RoleList);
const count_data = CommonHelper.countObject(RoleList);
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
} catch (e: unknown) {
log.error(e);
const err = e as Error;
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
}
}
static async create(req: Request, res: Response, next: NextFunction): Promise<Response> {
/*
#swagger.tags = ['User Roles']
#swagger.parameters['body'] = {
in: 'body',
description: 'User role data',
#swagger.security = [{
"bearerAuth": []
}]
#swagger.requestBody = {
required: true,
schema: {
name: "Administrator",
roles: ["dashboard"],
status:"Y"
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/user_role"
}
}
}
}*/
}
*/
try {
const schema = Joi.object().keys({
@ -140,6 +171,9 @@ export class UserRoleController {
static async update(req: Request, res: Response, next: NextFunction): Promise<Response> {
/*
#swagger.tags = ['User Roles']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
in: 'path',
description: 'User role ID.',
@ -147,16 +181,17 @@ export class UserRoleController {
type: 'string'
}
#swagger.parameters['body'] = {
in: 'body',
description: 'User role data',
#swagger.requestBody = {
required: true,
schema: {
name: "Administrator",
roles: ["dashboard"],
status:"Y"
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/user_role"
}
}
}
}*/
}
*/
try {
const schema = Joi.object().keys({
@ -196,6 +231,9 @@ export class UserRoleController {
static async delete(req: Request, res: Response, next: NextFunction): Promise<Response> {
/*
#swagger.tags = ['User Roles']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
in: 'path',
description: 'User role ID.',
@ -230,6 +268,9 @@ export class UserRoleController {
static async restore(req: Request, res: Response, next: NextFunction): Promise<Response> {
/*
#swagger.tags = ['User Roles']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
in: 'path',
description: 'User role ID.',