swagger configurado na rota chavenfe

This commit is contained in:
unknown
2025-03-29 15:06:21 -03:00
parent 5e4ef04b4a
commit 32bd7c14b3
29 changed files with 709 additions and 241 deletions

View File

@@ -6,13 +6,24 @@ import { BillingDto } from './dto/billing.dto';
import { CustomerDto } from './dto/customer.dto';
import { ProductDto } from './dto/product.dto';
import { ILogger } from '../Log/ILogger';
import { RedisClientToken } from '../core/configs/cache/redis-client.adapter.provider';
import { IRedisClient } from '../core/configs/cache/IRedisClient';
import { getOrSetCache } from '../shared/cache.util';
@Injectable()
export class DataConsultService {
private readonly SELLERS_CACHE_KEY = 'data-consult:sellers';
private readonly SELLERS_TTL = 3600; // 1 hora
constructor(
private readonly repository: DataConsultRepository,
@Inject(RedisClientToken) private readonly redisClient: IRedisClient,
@Inject('LoggerService')
private readonly logger: ILogger
private readonly logger: ILogger,
) {}
/**
@@ -29,9 +40,17 @@ export class DataConsultService {
* @returns Array de SellerDto
*/
async sellers(): Promise<SellerDto[]> {
this.logger.log('Buscando todos os vendedores');
return this.repository.findSellers();
}
this.logger.log('Buscando vendedores com cache Redis...');
return getOrSetCache<SellerDto[]>(
this.redisClient,
this.SELLERS_CACHE_KEY,
this.SELLERS_TTL,
async () => {
this.logger.log('Cache de vendedores vazio. Buscando no banco...');
return this.repository.findSellers();
}
);
}
/**
* Obter todos os faturamentos