fix: change register ticket body
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
9977a7456a
commit
86251f43a2
|
@ -84,6 +84,9 @@ export class QueueItemModel
|
||||||
@JoinColumn({ name: 'ticket_id' })
|
@JoinColumn({ name: 'ticket_id' })
|
||||||
ticket: QueueTicket;
|
ticket: QueueTicket;
|
||||||
|
|
||||||
|
@Column('varchar')
|
||||||
|
ticket_id: string;
|
||||||
|
|
||||||
@OneToMany(() => QueueModel, (model) => model.item, {
|
@OneToMany(() => QueueModel, (model) => model.item, {
|
||||||
onDelete: 'CASCADE',
|
onDelete: 'CASCADE',
|
||||||
onUpdate: 'CASCADE',
|
onUpdate: 'CASCADE',
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { QueueModel } from '../models/queue.model';
|
import { QueueItemModel, QueueModel } from '../models/queue.model';
|
||||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
||||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
||||||
|
|
||||||
|
@ -22,7 +22,19 @@ export class QueueService extends BaseDataService<QueueModel> {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(QueueModel, CONNECTION_NAME.DEFAULT)
|
@InjectRepository(QueueModel, CONNECTION_NAME.DEFAULT)
|
||||||
private repo: Repository<QueueModel>,
|
private repo: Repository<QueueModel>,
|
||||||
|
|
||||||
|
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
|
||||||
|
private item: Repository<QueueItemModel>,
|
||||||
) {
|
) {
|
||||||
super(repo);
|
super(repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getTicketItems(ticket_id: string, item_id: string) {
|
||||||
|
return this.item.findOneOrFail({
|
||||||
|
where: {
|
||||||
|
ticket_id,
|
||||||
|
item_id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { Queue } from './entities/queue.entity';
|
||||||
import { QueueService } from '../data/services/queue.service';
|
import { QueueService } from '../data/services/queue.service';
|
||||||
import { RegisterQueueManager } from './usecases/register-queue.manager';
|
import { RegisterQueueManager } from './usecases/register-queue.manager';
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
|
import { RegisterQueueDto } from '../infrastructure/controllers/dto/register-queue.dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class QueueOrchestrator {
|
export class QueueOrchestrator {
|
||||||
|
@ -26,8 +27,16 @@ export class QueueOrchestrator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(data): Promise<Queue> {
|
async create(data: RegisterQueueDto): Promise<Queue> {
|
||||||
this.registerQueueManager.setData(data);
|
const queue = await this.queueService.getTicketItems(
|
||||||
|
data.ticket_id,
|
||||||
|
data.item_id,
|
||||||
|
);
|
||||||
|
const queueRequest: any = {
|
||||||
|
qty: data.qty,
|
||||||
|
item_id: queue.id,
|
||||||
|
};
|
||||||
|
this.registerQueueManager.setData(queueRequest);
|
||||||
this.registerQueueManager.setService(this.queueService, TABLE_NAME.QUEUE);
|
this.registerQueueManager.setService(this.queueService, TABLE_NAME.QUEUE);
|
||||||
await this.registerQueueManager.execute();
|
await this.registerQueueManager.execute();
|
||||||
return this.registerQueueManager.getResult();
|
return this.registerQueueManager.getResult();
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { QueueModel } from '../../data/models/queue.model';
|
||||||
import { generateRandom } from 'src/modules/transaction/vip-code/domain/usecases/managers/helpers/generate-random.helper';
|
import { generateRandom } from 'src/modules/transaction/vip-code/domain/usecases/managers/helpers/generate-random.helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RegisterQueueManager extends BaseCreateManager<Queue> {
|
export class RegisterQueueManager extends BaseCreateManager<QueueModel> {
|
||||||
async beforeProcess(): Promise<void> {
|
async beforeProcess(): Promise<void> {
|
||||||
Object.assign(this.data, {
|
Object.assign(this.data, {
|
||||||
status: STATUS.WAITING,
|
status: STATUS.WAITING,
|
||||||
|
|
|
@ -7,6 +7,11 @@ export class RegisterQueueDto {
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
item_id: string;
|
item_id: string;
|
||||||
|
|
||||||
|
@ApiProperty({ name: 'ticket_id', required: true })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
ticket_id: string;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
Loading…
Reference in New Issue