fix: ajuste no endpoint de impressão de pedidos.
This commit is contained in:
@@ -5,6 +5,7 @@ import { SellerDto } from './dto/seller.dto';
|
||||
import { BillingDto } from './dto/billing.dto';
|
||||
import { CustomerDto } from './dto/customer.dto';
|
||||
import { ProductDto } from './dto/product.dto';
|
||||
import { RegionDto } from './dto/region.dto';
|
||||
import { CarrierDto, FindCarriersDto } from './dto/carrier.dto';
|
||||
import { ILogger } from '../Log/ILogger';
|
||||
import { RedisClientToken } from '../core/configs/cache/redis-client.adapter.provider';
|
||||
@@ -24,6 +25,8 @@ export class DataConsultService {
|
||||
private readonly CUSTOMERS_TTL = 3600;
|
||||
private readonly CARRIERS_CACHE_KEY = 'data-consult:carriers:all';
|
||||
private readonly CARRIERS_TTL = 3600;
|
||||
private readonly REGIONS_CACHE_KEY = 'data-consult:regions';
|
||||
private readonly REGIONS_TTL = 7200;
|
||||
|
||||
constructor(
|
||||
private readonly repository: DataConsultRepository,
|
||||
@@ -205,4 +208,26 @@ export class DataConsultService {
|
||||
throw new HttpException('Erro ao buscar transportadoras do pedido', HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obter todas as regiões cadastradas
|
||||
* @returns Array de RegionDto
|
||||
*/
|
||||
async getRegions(): Promise<RegionDto[]> {
|
||||
this.logger.log('Buscando todas as regiões');
|
||||
try {
|
||||
return getOrSetCache<RegionDto[]>(
|
||||
this.redisClient,
|
||||
this.REGIONS_CACHE_KEY,
|
||||
this.REGIONS_TTL,
|
||||
async () => {
|
||||
const regions = await this.repository.findRegions();
|
||||
return regions;
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
this.logger.error('Erro ao buscar regiões', error);
|
||||
throw new HttpException('Erro ao buscar regiões', HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user