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:
+2
-1
@@ -3,6 +3,7 @@ import { Body, Controller, Param, Post } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { PartnerBusinessActivityAccountsChargeService } from './accounts-charge.service'
|
||||
import { CreateBusinessActivityAccountsChargeDto } from './dto/accounts-charge.dto'
|
||||
import type { PartnerBusinessActivityAccountsChargeServiceCreateResponseDto } from './dto/accounts-charge-response.dto'
|
||||
|
||||
@ApiTags('PartnerConsumerBAAccountsCharge')
|
||||
@Controller(
|
||||
@@ -17,7 +18,7 @@ export class PartnerBusinessActivityAccountsChargeController {
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Body() data: CreateBusinessActivityAccountsChargeDto,
|
||||
) {
|
||||
): Promise<PartnerBusinessActivityAccountsChargeServiceCreateResponseDto> {
|
||||
return this.service.create(partnerId, consumerId, businessActivityId, data)
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -26,7 +26,18 @@ export class PartnerBusinessActivityAccountsChargeService {
|
||||
id: business_activity_id,
|
||||
consumer: {
|
||||
id: consumer_id,
|
||||
partner_id,
|
||||
OR: [
|
||||
{
|
||||
legal: {
|
||||
partner_id,
|
||||
},
|
||||
},
|
||||
{
|
||||
individual: {
|
||||
partner_id,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
OR: [
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import type { PartnerBusinessActivityAccountsChargeService } from '../accounts-charge.service'
|
||||
|
||||
export type PartnerBusinessActivityAccountsChargeServiceCreateResponseDto = Awaited<ReturnType<PartnerBusinessActivityAccountsChargeService['create']>>
|
||||
+6
-4
@@ -16,7 +16,7 @@ export class BusinessActivitiesController {
|
||||
async findAll(
|
||||
@PartnerInfo('id') partnerId: string,
|
||||
@Param('consumerId') consumerId: string,
|
||||
) {
|
||||
): Promise<BusinessActivitiesServiceFindAllResponseDto> {
|
||||
return this.businessActivitiesService.findAll(partnerId, consumerId)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export class BusinessActivitiesController {
|
||||
@PartnerInfo('id') partnerId: string,
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
): Promise<BusinessActivitiesServiceFindOneResponseDto> {
|
||||
return this.businessActivitiesService.findOne(partnerId, consumerId, id)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export class BusinessActivitiesController {
|
||||
@PartnerInfo('id') partnerId: string,
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Body() data: CreateBusinessActivitiesDto,
|
||||
) {
|
||||
): Promise<BusinessActivitiesServiceCreateResponseDto> {
|
||||
return this.businessActivitiesService.create(partnerId, consumerId, data)
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export class BusinessActivitiesController {
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdateBusinessActivityDto,
|
||||
) {
|
||||
): Promise<BusinessActivitiesServiceUpdateResponseDto> {
|
||||
return this.businessActivitiesService.update(partnerId, consumerId, id, data)
|
||||
}
|
||||
|
||||
@@ -53,3 +53,5 @@ export class BusinessActivitiesController {
|
||||
// return this.businessActivitiesService.delete(id)
|
||||
// }
|
||||
}
|
||||
|
||||
import type { BusinessActivitiesServiceCreateResponseDto, BusinessActivitiesServiceFindAllResponseDto, BusinessActivitiesServiceFindOneResponseDto, BusinessActivitiesServiceUpdateResponseDto } from './dto/business-activities-response.dto'
|
||||
@@ -15,7 +15,7 @@ export class BusinessActivitiesService {
|
||||
).toISOString()
|
||||
}
|
||||
|
||||
defaultSelect: BusinessActivitySelect = {
|
||||
private readonly defaultSelect: BusinessActivitySelect = {
|
||||
id: true,
|
||||
name: true,
|
||||
economic_code: true,
|
||||
@@ -49,6 +49,24 @@ export class BusinessActivitiesService {
|
||||
},
|
||||
}
|
||||
|
||||
private readonly defaultWhere = (partner_id: string, consumer_id: string) => ({
|
||||
consumer: {
|
||||
id: consumer_id,
|
||||
OR: [
|
||||
{
|
||||
legal: {
|
||||
partner_id,
|
||||
},
|
||||
},
|
||||
{
|
||||
individual: {
|
||||
partner_id,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
private readonly prepareBusinessActivityResponse = (businessActivity: any) => {
|
||||
const { license_activation, ...rest } = businessActivity
|
||||
const { license, ...license_activation_rest } = license_activation
|
||||
@@ -65,12 +83,7 @@ export class BusinessActivitiesService {
|
||||
|
||||
async findAll(partner_id: string, consumer_id: string) {
|
||||
const businessActivities = await this.prisma.businessActivity.findMany({
|
||||
where: {
|
||||
consumer: {
|
||||
id: consumer_id,
|
||||
partner_id,
|
||||
},
|
||||
},
|
||||
where: this.defaultWhere(partner_id, consumer_id),
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
return ResponseMapper.list(
|
||||
@@ -81,10 +94,7 @@ export class BusinessActivitiesService {
|
||||
async findOne(partner_id: string, consumer_id: string, id: string) {
|
||||
const businessActivity = await this.prisma.businessActivity.findUnique({
|
||||
where: {
|
||||
consumer: {
|
||||
id: consumer_id,
|
||||
partner_id,
|
||||
},
|
||||
...this.defaultWhere(partner_id, consumer_id),
|
||||
id,
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
@@ -171,7 +181,7 @@ export class BusinessActivitiesService {
|
||||
|
||||
async update(partner_id: string, consumer_id: string, id: string, data: any) {
|
||||
const businessActivity = await this.prisma.businessActivity.update({
|
||||
where: { id, consumer: { id: consumer_id, partner_id } },
|
||||
where: { ...this.defaultWhere(partner_id, consumer_id), id },
|
||||
data,
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
|
||||
+5
-4
@@ -3,6 +3,7 @@ import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { BusinessActivityComplexesService } from './complexes.service'
|
||||
import { CreateComplexDto, UpdateComplexDto } from './dto/complex.dto'
|
||||
import type { BusinessActivityComplexesServiceCreateResponseDto, BusinessActivityComplexesServiceFindAllResponseDto, BusinessActivityComplexesServiceFindOneResponseDto, BusinessActivityComplexesServiceUpdateResponseDto } from './dto/complexes-response.dto'
|
||||
|
||||
@ApiTags('PartnerBusinessActivityComplexes')
|
||||
@Controller(
|
||||
@@ -16,7 +17,7 @@ export class BusinessActivityComplexesController {
|
||||
@PartnerInfo('id') partnerId: string,
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
) {
|
||||
): Promise<BusinessActivityComplexesServiceFindAllResponseDto> {
|
||||
return this.service.findAll(partnerId, consumerId, businessActivityId)
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ export class BusinessActivityComplexesController {
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
): Promise<BusinessActivityComplexesServiceFindOneResponseDto> {
|
||||
return this.service.findOne(partnerId, consumerId, businessActivityId, id)
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ export class BusinessActivityComplexesController {
|
||||
@PartnerInfo('id') partnerId: string,
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Body() data: CreateComplexDto,
|
||||
) {
|
||||
): Promise<BusinessActivityComplexesServiceCreateResponseDto> {
|
||||
return this.service.create(partnerId, businessActivityId, data)
|
||||
}
|
||||
|
||||
@@ -46,7 +47,7 @@ export class BusinessActivityComplexesController {
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdateComplexDto,
|
||||
) {
|
||||
): Promise<BusinessActivityComplexesServiceUpdateResponseDto> {
|
||||
return this.service.update(partnerId, consumerId, businessActivityId, id, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,18 @@ export class BusinessActivityComplexesService {
|
||||
id: business_activity_id,
|
||||
consumer: {
|
||||
id: consumer_id,
|
||||
partner_id,
|
||||
OR: [
|
||||
{
|
||||
legal: {
|
||||
partner_id,
|
||||
},
|
||||
},
|
||||
{
|
||||
individual: {
|
||||
partner_id,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { BusinessActivityComplexesService } from '../complexes.service'
|
||||
|
||||
export type BusinessActivityComplexesServiceCreateResponseDto = Awaited<ReturnType<BusinessActivityComplexesService['create']>>
|
||||
export type BusinessActivityComplexesServiceFindAllResponseDto = Awaited<ReturnType<BusinessActivityComplexesService['findAll']>>
|
||||
export type BusinessActivityComplexesServiceFindOneResponseDto = Awaited<ReturnType<BusinessActivityComplexesService['findOne']>>
|
||||
export type BusinessActivityComplexesServiceUpdateResponseDto = Awaited<ReturnType<BusinessActivityComplexesService['update']>>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { ComplexPosesService } from '../poses.service'
|
||||
|
||||
export type ComplexPosesServiceCreateResponseDto = Awaited<ReturnType<ComplexPosesService['create']>>
|
||||
export type ComplexPosesServiceFindAllResponseDto = Awaited<ReturnType<ComplexPosesService['findAll']>>
|
||||
export type ComplexPosesServiceFindOneResponseDto = Awaited<ReturnType<ComplexPosesService['findOne']>>
|
||||
export type ComplexPosesServiceUpdateResponseDto = Awaited<ReturnType<ComplexPosesService['update']>>
|
||||
+5
-4
@@ -3,6 +3,7 @@ import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { CreatePosDto, UpdatePosDto } from './dto/pos.dto'
|
||||
import { ComplexPosesService } from './poses.service'
|
||||
import type { ComplexPosesServiceCreateResponseDto, ComplexPosesServiceFindAllResponseDto, ComplexPosesServiceFindOneResponseDto, ComplexPosesServiceUpdateResponseDto } from './dto/poses-response.dto'
|
||||
|
||||
@ApiTags('AdminComplexPoses')
|
||||
@Controller('partner/business_activities/:businessActivityId/complexes/:complexId/poses')
|
||||
@@ -14,7 +15,7 @@ export class ComplexPosesController {
|
||||
@PartnerInfo('id') partnerId: string,
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('complexId') complexId: string,
|
||||
) {
|
||||
): Promise<ComplexPosesServiceFindAllResponseDto> {
|
||||
return this.service.findAll(partnerId, businessActivityId, complexId)
|
||||
}
|
||||
|
||||
@@ -24,7 +25,7 @@ export class ComplexPosesController {
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('complexId') complexId: string,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
): Promise<ComplexPosesServiceFindOneResponseDto> {
|
||||
return this.service.findOne(partnerId, businessActivityId, complexId, id)
|
||||
}
|
||||
|
||||
@@ -34,7 +35,7 @@ export class ComplexPosesController {
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('complexId') complexId: string,
|
||||
@Body() data: CreatePosDto,
|
||||
) {
|
||||
): Promise<ComplexPosesServiceCreateResponseDto> {
|
||||
return this.service.create(partnerId, businessActivityId, complexId, data)
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ export class ComplexPosesController {
|
||||
@Param('complexId') complexId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdatePosDto,
|
||||
) {
|
||||
): Promise<ComplexPosesServiceUpdateResponseDto> {
|
||||
return this.service.update(partnerId, businessActivityId, complexId, id, data)
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { BusinessActivitiesService } from '../business-activities.service'
|
||||
|
||||
export type BusinessActivitiesServiceCreateResponseDto = Awaited<ReturnType<BusinessActivitiesService['create']>>
|
||||
export type BusinessActivitiesServiceFindAllResponseDto = Awaited<ReturnType<BusinessActivitiesService['findAll']>>
|
||||
export type BusinessActivitiesServiceFindOneResponseDto = Awaited<ReturnType<BusinessActivitiesService['findOne']>>
|
||||
export type BusinessActivitiesServiceUpdateResponseDto = Awaited<ReturnType<BusinessActivitiesService['update']>>
|
||||
Reference in New Issue
Block a user