feat: add response DTOs for various services across modules

- Created response DTOs for ConfigService, AppService, AuthService, CatalogsService, AccountsService, BusinessActivityComplexesService, ComplexPosesService, SalesInvoicesService, BusinessActivitiesService, ConsumerBusinessActivityGoodsService, and others.
- Implemented Create, FindAll, FindOne, and Update response types for services in consumer, partners, and POS modules.
- Added request DTOs for creating and updating goods in the consumer business activities module.
- Introduced filtering DTO for partner licenses.
- Enhanced response mapping for partner license activations.
This commit is contained in:
2026-04-27 10:45:39 +03:30
parent 34793295c9
commit dee96b6e91
208 changed files with 8058 additions and 2349 deletions
@@ -11,12 +11,12 @@ export class consumerCustomersController {
constructor(private readonly service: consumerCustomersService) {}
@Get()
async findAll(@ConsumerInfo('id') consumerId: string) {
async findAll(@ConsumerInfo('id') consumerId: string): Promise<consumerCustomersServiceFindAllResponseDto> {
return this.service.findAll(consumerId)
}
@Get(':id')
async findOne(@ConsumerInfo('id') consumerId: string, @Param('id') id: string) {
async findOne(@ConsumerInfo('id') consumerId: string, @Param('id') id: string): Promise<consumerCustomersServiceFindOneResponseDto> {
return this.service.findOne(consumerId, id)
}
@@ -25,7 +25,7 @@ export class consumerCustomersController {
@ConsumerInfo('id') consumerId: string,
@Param('id') id: string,
@Body() data: UpdateCustomerLegalDto,
) {
): Promise<consumerCustomersServiceUpdateLegalResponseDto> {
return this.service.updateLegal(consumerId, id, data)
}
@@ -34,7 +34,9 @@ export class consumerCustomersController {
@ConsumerInfo('id') consumerId: string,
@Param('id') id: string,
@Body() data: UpdateCustomerIndividualDto,
) {
): Promise<consumerCustomersServiceUpdateIndividualResponseDto> {
return this.service.updateIndividual(consumerId, id, data)
}
}
import type { consumerCustomersServiceFindAllResponseDto, consumerCustomersServiceFindOneResponseDto, consumerCustomersServiceUpdateIndividualResponseDto, consumerCustomersServiceUpdateLegalResponseDto } from './dto/customers-response.dto'
@@ -16,7 +16,7 @@ export class consumerCustomersService {
type: true,
is_favorite: true,
created_at: true,
customer_individual: {
individual: {
select: {
first_name: true,
last_name: true,
@@ -25,7 +25,7 @@ export class consumerCustomersService {
economic_code: true,
},
},
customer_legal: {
legal: {
select: {
company_name: true,
registration_number: true,
@@ -39,20 +39,16 @@ export class consumerCustomersService {
return {
OR: [
{
customer_individual: {
complex: {
business_activity: {
consumer_id,
},
individual: {
business_activity: {
consumer_id,
},
},
},
{
customer_legal: {
complex: {
business_activity: {
consumer_id,
},
legal: {
business_activity: {
consumer_id,
},
},
},
@@ -95,17 +91,15 @@ export class consumerCustomersService {
const customer = await this.prisma.customer.update({
where: {
id: customer_id,
customer_legal: {
complex: {
business_activity: {
consumer_id,
},
legal: {
business_activity: {
consumer_id,
},
},
},
data: {
is_favorite: data.is_favorite,
customer_legal: {
legal: {
update: {
...data,
},
@@ -124,18 +118,16 @@ export class consumerCustomersService {
const customer = await this.prisma.customer.update({
where: {
id: customer_id,
customer_individual: {
complex: {
business_activity: {
consumer_id,
},
individual: {
business_activity: {
consumer_id,
},
},
},
data: {
is_favorite: data.is_favorite,
customer_individual: {
individual: {
update: {
...data,
},
@@ -0,0 +1,6 @@
import type { consumerCustomersService } from '../customers.service'
export type consumerCustomersServiceFindAllResponseDto = Awaited<ReturnType<consumerCustomersService['findAll']>>
export type consumerCustomersServiceFindOneResponseDto = Awaited<ReturnType<consumerCustomersService['findOne']>>
export type consumerCustomersServiceUpdateIndividualResponseDto = Awaited<ReturnType<consumerCustomersService['updateIndividual']>>
export type consumerCustomersServiceUpdateLegalResponseDto = Awaited<ReturnType<consumerCustomersService['updateLegal']>>
@@ -0,0 +1,4 @@
import type { CustomerSaleInvoicesService } from '../sale-invoices.service'
export type CustomerSaleInvoicesServiceFindAllResponseDto = Awaited<ReturnType<CustomerSaleInvoicesService['findAll']>>
export type CustomerSaleInvoicesServiceFindOneResponseDto = Awaited<ReturnType<CustomerSaleInvoicesService['findOne']>>
@@ -2,6 +2,7 @@ import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
import { Controller, Get, Param } from '@nestjs/common'
import { ApiTags } from '@nestjs/swagger'
import { CustomerSaleInvoicesService } from './sale-invoices.service'
import type { CustomerSaleInvoicesServiceFindAllResponseDto, CustomerSaleInvoicesServiceFindOneResponseDto } from './dto/sale-invoices-response.dto'
@ApiTags('customerSaleInvoices')
@Controller('consumer/customers/:customerId/sale-invoices')
@@ -12,7 +13,7 @@ export class CustomerSaleInvoicesController {
async findAll(
@TokenAccount('userId') userId: string,
@Param('customerId') customerId: string,
) {
): Promise<CustomerSaleInvoicesServiceFindAllResponseDto> {
return this.service.findAll(userId, customerId)
}
@@ -21,7 +22,7 @@ export class CustomerSaleInvoicesController {
@TokenAccount('userId') userId: string,
@Param('customerId') customerId: string,
@Param('id') id: string,
) {
): Promise<CustomerSaleInvoicesServiceFindOneResponseDto> {
return this.service.findOne(userId, customerId, id)
}
}
@@ -1,3 +1,5 @@
import { QUERY_CONSTANTS } from '@/common/queryConstants'
import consumer_mappersUtil from '@/common/utils/mappers/consumer_mappers.util'
import { SalesInvoiceSelect, SalesInvoiceWhereInput } from '@/generated/prisma/models'
import { PrismaService } from '@/prisma/prisma.service'
import { Injectable } from '@nestjs/common'
@@ -7,7 +9,7 @@ import { ResponseMapper } from 'common/response/response-mapper'
export class CustomerSaleInvoicesService {
constructor(private readonly prisma: PrismaService) {}
defaultSelect: SalesInvoiceSelect = {
private readonly defaultSelect: SalesInvoiceSelect = {
id: true,
code: true,
invoice_date: true,
@@ -36,8 +38,7 @@ export class CustomerSaleInvoicesService {
role: true,
consumer: {
select: {
first_name: true,
last_name: true,
...QUERY_CONSTANTS.CONSUMER.infoSelect,
},
},
account: {
@@ -62,7 +63,7 @@ export class CustomerSaleInvoicesService {
},
}
const [accounts, total] = await this.prisma.$transaction(async tx => [
const [saleInvoices, total] = await this.prisma.$transaction(async tx => [
await tx.salesInvoice.findMany({
where: salesWhere,
select: {
@@ -81,11 +82,17 @@ export class CustomerSaleInvoicesService {
}),
])
const mappedAccounts = accounts.map(account => {
const { _count, ...rest } = account
const mappedAccounts = saleInvoices.map(saleInvoice => {
const { _count, consumer_account, ...rest } = saleInvoice
const { consumer, ...restConsumerAccount } = consumer_account as any
const mappedConsumer = consumer_mappersUtil(consumer)
return {
...rest,
items_count: _count.items,
consumer_account: {
...restConsumerAccount,
consumer: mappedConsumer,
},
}
})
@@ -97,7 +104,7 @@ export class CustomerSaleInvoicesService {
}
async findOne(consumer_id: string, customer_id: string, id: string) {
const account = await this.prisma.salesInvoice.findUniqueOrThrow({
const saleInvoice = await this.prisma.salesInvoice.findUniqueOrThrow({
where: {
id,
customer_id,
@@ -111,7 +118,6 @@ export class CustomerSaleInvoicesService {
},
select: {
...this.defaultSelect,
items: {
select: {
id: true,
@@ -147,6 +153,17 @@ export class CustomerSaleInvoicesService {
},
},
})
return ResponseMapper.single(account)
const { _count, consumer_account, ...rest } = saleInvoice
const { consumer, ...restConsumerAccount } = consumer_account as any
const mappedConsumer = consumer_mappersUtil(consumer)
return ResponseMapper.single({
...rest,
items_count: _count.items,
consumer_account: {
...restConsumerAccount,
consumer: mappedConsumer,
},
})
}
}