feat: add session to admin queue
parent
2b132c53a8
commit
fb7f925c78
|
@ -6,5 +6,6 @@ export interface UsersSession {
|
||||||
name: string;
|
name: string;
|
||||||
role: UserRole;
|
role: UserRole;
|
||||||
source?: AppSource;
|
source?: AppSource;
|
||||||
|
item_id?: string;
|
||||||
user_privilege_id: string;
|
user_privilege_id: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,10 @@ export class IndexQueueManager extends BaseIndexManager<Queue> {
|
||||||
end,
|
end,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
queryBuilder.andWhere(`${this.tableName}.item_queue_id = :item_queue_id`, {
|
||||||
|
item_queue_id: this.filterParam.item_queue_id,
|
||||||
|
});
|
||||||
|
|
||||||
if (this.filterParam.vip != null) {
|
if (this.filterParam.vip != null) {
|
||||||
queryBuilder.andWhere(`${this.tableName}.vip = :vip`, {
|
queryBuilder.andWhere(`${this.tableName}.vip = :vip`, {
|
||||||
vip: this.filterParam.vip,
|
vip: this.filterParam.vip,
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
import { Controller, Get, Param, Post, Query } from '@nestjs/common';
|
import {
|
||||||
|
Controller,
|
||||||
|
Get,
|
||||||
|
Param,
|
||||||
|
Post,
|
||||||
|
Query,
|
||||||
|
UnauthorizedException,
|
||||||
|
} from '@nestjs/common';
|
||||||
|
|
||||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
@ -9,18 +16,40 @@ import { Queue } from '../../domain/entities/queue.entity';
|
||||||
import { QueueDto } from './dto/queue.filter';
|
import { QueueDto } from './dto/queue.filter';
|
||||||
import { Pagination } from 'src/core/response';
|
import { Pagination } from 'src/core/response';
|
||||||
import { Public } from 'src/core/guards';
|
import { Public } from 'src/core/guards';
|
||||||
|
import { UserProvider } from 'src/core/sessions';
|
||||||
|
|
||||||
@ApiTags(`Queue Admin`)
|
@ApiTags(`Queue Admin`)
|
||||||
@Controller(`v1/${MODULE_NAME.QUEUE}-admin`)
|
@Controller(`v1/${MODULE_NAME.QUEUE}-admin`)
|
||||||
@ApiBearerAuth('JWT')
|
@ApiBearerAuth('JWT')
|
||||||
@Public(true)
|
@Public(false)
|
||||||
export class QueueAdminController {
|
export class QueueAdminController {
|
||||||
constructor(private orchestrator: QueueAdminOrchestrator) {}
|
constructor(
|
||||||
|
private orchestrator: QueueAdminOrchestrator,
|
||||||
|
private readonly userProvider: UserProvider,
|
||||||
|
) {}
|
||||||
|
|
||||||
@Get('queues')
|
@Get('queues')
|
||||||
@Pagination()
|
@Pagination()
|
||||||
async index(@Query() params: QueueDto): Promise<PaginationResponse<Queue>> {
|
async index(@Query() params: QueueDto): Promise<PaginationResponse<Queue>> {
|
||||||
return await this.orchestrator.index(params);
|
const queue_id = this.userProvider.user.item_id;
|
||||||
|
if (!queue_id) {
|
||||||
|
throw new UnauthorizedException({
|
||||||
|
error: 'USER_IS_NOT_ADMIN',
|
||||||
|
message: "Login user isn't admin, please login in admin account",
|
||||||
|
code: 20001,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return await this.orchestrator.index({ ...params, queue_id });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('queues/:id')
|
||||||
|
@Public(true)
|
||||||
|
@Pagination()
|
||||||
|
async indexPublic(
|
||||||
|
@Param('id') id: string,
|
||||||
|
@Query() params: QueueDto,
|
||||||
|
): Promise<PaginationResponse<Queue>> {
|
||||||
|
return await this.orchestrator.index({ ...params, queue_id: id });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('queues/:id/call')
|
@Post('queues/:id/call')
|
||||||
|
|
Loading…
Reference in New Issue