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:
@@ -0,0 +1,5 @@
|
||||
import type { CustomersService } from '../customers.service'
|
||||
|
||||
export type CustomersServiceCreateResponseDto = Awaited<ReturnType<CustomersService['create']>>
|
||||
export type CustomersServiceFindAllResponseDto = Awaited<ReturnType<CustomersService['findAll']>>
|
||||
export type CustomersServiceFindOneResponseDto = Awaited<ReturnType<CustomersService['findOne']>>
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { PosService } from '../pos.service'
|
||||
|
||||
export type PosServiceGetAccessibleResponseDto = Awaited<ReturnType<PosService['getAccessible']>>
|
||||
export type PosServiceGetInfoResponseDto = Awaited<ReturnType<PosService['getInfo']>>
|
||||
export type PosServiceGetMeResponseDto = Awaited<ReturnType<PosService['getMe']>>
|
||||
@@ -0,0 +1,3 @@
|
||||
import type { GoodCategoriesService } from '../good-categories.service'
|
||||
|
||||
export type GoodCategoriesServiceFindAllResponseDto = Awaited<ReturnType<GoodCategoriesService['findAll']>>
|
||||
@@ -1,15 +1,15 @@
|
||||
import { PosInfo } from '@/common/decorators/posInfo.decorator'
|
||||
import type { IPosPayload } from '@/common/models/posPayload.model'
|
||||
import { Controller, Get } from '@nestjs/common'
|
||||
import { GoodCategoriesService } from './good-categories.service'
|
||||
import type { IPosPayload } from '@/common/models/posPayload.model'
|
||||
|
||||
@Controller('pos/good_categories')
|
||||
export class GoodCategoriesController {
|
||||
constructor(private readonly goodCategoriesService: GoodCategoriesService) {}
|
||||
|
||||
@Get()
|
||||
findAll(@PosInfo() { complex_id, guild_id }: IPosPayload) {
|
||||
return this.goodCategoriesService.findAll(complex_id, guild_id)
|
||||
findAll(@PosInfo() { business_id, guild_id }: IPosPayload) {
|
||||
return this.goodCategoriesService.findAll(business_id, guild_id)
|
||||
}
|
||||
|
||||
// @Get(':id')
|
||||
|
||||
@@ -13,7 +13,7 @@ export class GoodCategoriesService {
|
||||
image_url: true,
|
||||
}
|
||||
|
||||
async findAll(complex_id: string, guild_id: string) {
|
||||
async findAll(business_activity_id: string, guild_id: string) {
|
||||
const categories = await this.prisma.goodCategory.findMany({
|
||||
where: {
|
||||
guild_id,
|
||||
@@ -27,7 +27,7 @@ export class GoodCategoriesService {
|
||||
OR: [
|
||||
{ is_default_guild_good: true },
|
||||
{
|
||||
complex_id,
|
||||
business_activity_id,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -48,15 +48,15 @@ export class GoodCategoriesService {
|
||||
)
|
||||
}
|
||||
|
||||
// findOne(categoryId: string, complex_id: string) {
|
||||
// findOne(categoryId: string, business_activity_id: string) {
|
||||
// return {}
|
||||
// }
|
||||
|
||||
// create(data: CreateGoodCategoryDto, complex_id: string) {
|
||||
// create(data: CreateGoodCategoryDto, business_activity_id: string) {
|
||||
// const category = this.prisma.goodCategory.create({
|
||||
// data: {
|
||||
// ...data,
|
||||
// complex_id,
|
||||
// business_activity_id,
|
||||
// },
|
||||
// })
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { GoodsService } from '../goods.service'
|
||||
|
||||
export type GoodsServiceCreateResponseDto = Awaited<ReturnType<GoodsService['create']>>
|
||||
export type GoodsServiceFindAllResponseDto = Awaited<ReturnType<GoodsService['findAll']>>
|
||||
export type GoodsServiceFindOneResponseDto = Awaited<ReturnType<GoodsService['findOne']>>
|
||||
@@ -1,20 +1,23 @@
|
||||
import { PosInfo } from '@/common/decorators/posInfo.decorator'
|
||||
import type { IPosPayload } from '@/common/models/posPayload.model'
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { GoodsService } from './goods.service'
|
||||
import type { IPosPayload } from '@/common/models/posPayload.model'
|
||||
|
||||
@Controller('pos/goods')
|
||||
export class GoodsController {
|
||||
constructor(private readonly goodsService: GoodsService) {}
|
||||
|
||||
@Get()
|
||||
findAll(@PosInfo() { complex_id, guild_id }: IPosPayload) {
|
||||
return this.goodsService.findAll(complex_id, guild_id)
|
||||
findAll(@PosInfo() { business_id, guild_id }: IPosPayload) {
|
||||
return this.goodsService.findAll(business_id, guild_id)
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@PosInfo() { complex_id, guild_id }: IPosPayload, @Param('id') goodId: string) {
|
||||
return this.goodsService.findOne(goodId, complex_id, guild_id)
|
||||
findOne(
|
||||
@PosInfo() { business_id, guild_id }: IPosPayload,
|
||||
@Param('id') goodId: string,
|
||||
) {
|
||||
return this.goodsService.findOne(goodId, business_id, guild_id)
|
||||
}
|
||||
|
||||
// @Post()
|
||||
|
||||
@@ -29,7 +29,7 @@ export class GoodsService {
|
||||
},
|
||||
}
|
||||
|
||||
async findAll(complex_id: string, guild_id: string) {
|
||||
async findAll(business_activity_id: string, guild_id: string) {
|
||||
const goods = await this.prisma.good.findMany({
|
||||
where: {
|
||||
OR: [
|
||||
@@ -40,7 +40,7 @@ export class GoodsService {
|
||||
},
|
||||
},
|
||||
{
|
||||
complex_id,
|
||||
business_activity_id,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -50,15 +50,13 @@ export class GoodsService {
|
||||
return ResponseMapper.list(goods)
|
||||
}
|
||||
|
||||
async findOne(good_id: string, complex_id: string, guild_id: string) {
|
||||
async findOne(good_id: string, business_activity_id: string, guild_id: string) {
|
||||
const good = await this.prisma.good.findUnique({
|
||||
where: {
|
||||
id: good_id,
|
||||
complex: {
|
||||
id: complex_id,
|
||||
business_activity: {
|
||||
guild_id,
|
||||
},
|
||||
business_activity: {
|
||||
id: business_activity_id,
|
||||
guild_id,
|
||||
},
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
@@ -67,12 +65,12 @@ export class GoodsService {
|
||||
return ResponseMapper.single(good)
|
||||
}
|
||||
|
||||
async create(data: CreateGoodDto, complex_id: string) {
|
||||
async create(data: CreateGoodDto, business_activity_id: string) {
|
||||
const { category_id, ...rest } = data
|
||||
|
||||
const dataToCreate = {
|
||||
...rest,
|
||||
complex_id,
|
||||
business_activity_id,
|
||||
connect: {
|
||||
category: {
|
||||
id: category_id,
|
||||
@@ -88,9 +86,9 @@ export class GoodsService {
|
||||
id: category_id,
|
||||
},
|
||||
},
|
||||
complex: {
|
||||
business_activity: {
|
||||
connect: {
|
||||
id: complex_id,
|
||||
id: business_activity_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,6 +2,11 @@ import { PosInfo } from '@/common/decorators/posInfo.decorator'
|
||||
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
||||
import { Controller, Get, Res } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import type {
|
||||
PosServiceGetAccessibleResponseDto,
|
||||
PosServiceGetInfoResponseDto,
|
||||
PosServiceGetMeResponseDto,
|
||||
} from './dto/pos-response.dto'
|
||||
import { PosService } from './pos.service'
|
||||
|
||||
@ApiTags('Pos')
|
||||
@@ -10,7 +15,10 @@ export class PosController {
|
||||
constructor(private service: PosService) {}
|
||||
|
||||
@Get()
|
||||
async getInfo(@PosInfo('pos_id') pos_id: string, @Res({ passthrough: true }) res) {
|
||||
async getInfo(
|
||||
@PosInfo('pos_id') pos_id: string,
|
||||
@Res({ passthrough: true }) res,
|
||||
): Promise<PosServiceGetInfoResponseDto> {
|
||||
const result = await this.service.getInfo(pos_id)
|
||||
|
||||
if (result) {
|
||||
@@ -27,12 +35,17 @@ export class PosController {
|
||||
}
|
||||
|
||||
@Get('/accessible')
|
||||
async getAccessiblePos(@TokenAccount('account_id') account_id) {
|
||||
async getAccessiblePos(
|
||||
@TokenAccount('account_id') account_id,
|
||||
): Promise<PosServiceGetAccessibleResponseDto> {
|
||||
return await this.service.getAccessible(account_id)
|
||||
}
|
||||
|
||||
@Get('/me')
|
||||
async getMe(@TokenAccount('account_id') account_id, @PosInfo('pos_id') pos_id: string) {
|
||||
async getMe(
|
||||
@TokenAccount('account_id') account_id,
|
||||
@PosInfo('pos_id') pos_id: string,
|
||||
): Promise<PosServiceGetMeResponseDto> {
|
||||
return await this.service.getMe(account_id, pos_id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class PosMiddleware implements NestMiddleware {
|
||||
complex: {
|
||||
business_activity: {
|
||||
consumer: {
|
||||
consumer_accounts: {
|
||||
accounts: {
|
||||
some: {
|
||||
id: account_id,
|
||||
},
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { QUERY_CONSTANTS } from '@/common/queryConstants'
|
||||
import consumer_mappersUtil from '@/common/utils/mappers/consumer_mappers.util'
|
||||
import { ConsumerStatus } from '@/generated/prisma/enums'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
@@ -95,7 +97,7 @@ export class PosService {
|
||||
complex: {
|
||||
business_activity: {
|
||||
consumer: {
|
||||
consumer_accounts: {
|
||||
accounts: {
|
||||
some: {
|
||||
id: account_id,
|
||||
},
|
||||
@@ -133,7 +135,7 @@ export class PosService {
|
||||
}
|
||||
|
||||
async getMe(account_id: string, pos_id: string) {
|
||||
const account = await this.prisma.consumerAccount.findUniqueOrThrow({
|
||||
const pos = await this.prisma.consumerAccount.findUniqueOrThrow({
|
||||
where: {
|
||||
id: account_id,
|
||||
consumer: {
|
||||
@@ -158,8 +160,10 @@ export class PosService {
|
||||
role: true,
|
||||
consumer: {
|
||||
select: {
|
||||
first_name: true,
|
||||
last_name: true,
|
||||
id: true,
|
||||
type: true,
|
||||
status: true,
|
||||
...QUERY_CONSTANTS.CONSUMER.infoSelect,
|
||||
},
|
||||
},
|
||||
account: {
|
||||
@@ -170,6 +174,11 @@ export class PosService {
|
||||
},
|
||||
})
|
||||
|
||||
return ResponseMapper.single(account)
|
||||
const { consumer, ...rest } = pos
|
||||
|
||||
return ResponseMapper.single({
|
||||
...rest,
|
||||
consumer: consumer_mappersUtil(consumer),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ export class CreateSalesInvoiceDto {
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
customer?: {
|
||||
customer_individual?: Omit<CustomerIndividual, 'complex_id' | 'customer_id'>
|
||||
customer_legal?: Omit<CustomerLegal, 'complex_id' | 'customer_id'>
|
||||
customer_individual?: Omit<CustomerIndividual, 'business_activity_id' | 'customer_id'>
|
||||
customer_legal?: Omit<CustomerLegal, 'business_activity_id' | 'customer_id'>
|
||||
customer_unknown?: {
|
||||
first_name: string
|
||||
last_name: string
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { SalesInvoicesService } from '../sales-invoices.service'
|
||||
|
||||
export type SalesInvoicesServiceCreateResponseDto = Awaited<ReturnType<SalesInvoicesService['create']>>
|
||||
export type SalesInvoicesServiceFindAllResponseDto = Awaited<ReturnType<SalesInvoicesService['findAll']>>
|
||||
export type SalesInvoicesServiceFindOneResponseDto = Awaited<ReturnType<SalesInvoicesService['findOne']>>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type { SalesInvoiceItemsService } from '../sales-invoice-items.service'
|
||||
|
||||
export type SalesInvoiceItemsServiceCreateResponseDto = Awaited<ReturnType<SalesInvoiceItemsService['create']>>
|
||||
export type SalesInvoiceItemsServiceFindAllResponseDto = Awaited<ReturnType<SalesInvoiceItemsService['findAll']>>
|
||||
export type SalesInvoiceItemsServiceFindOneResponseDto = Awaited<ReturnType<SalesInvoiceItemsService['findOne']>>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type { SalesInvoicePaymentsService } from '../sales-invoice-payments.service'
|
||||
|
||||
export type SalesInvoicePaymentsServiceCreateResponseDto = Awaited<ReturnType<SalesInvoicePaymentsService['create']>>
|
||||
export type SalesInvoicePaymentsServiceFindAllResponseDto = Awaited<ReturnType<SalesInvoicePaymentsService['findAll']>>
|
||||
export type SalesInvoicePaymentsServiceFindOneResponseDto = Awaited<ReturnType<SalesInvoicePaymentsService['findOne']>>
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common'
|
||||
|
||||
import { PosInfo } from '@/common/decorators/posInfo.decorator'
|
||||
import type { IPosPayload } from '@/common/models/posPayload.model'
|
||||
import { CreateSalesInvoiceDto } from './dto/create-sales-invoice.dto'
|
||||
import { SalesInvoicesService } from './sales-invoices.service'
|
||||
import type { IPosPayload } from '@/common/models/posPayload.model'
|
||||
|
||||
@Controller('pos/sales_invoices')
|
||||
export class SalesInvoicesController {
|
||||
|
||||
@@ -42,7 +42,7 @@ export class SalesInvoicesService {
|
||||
async create(data: CreateSalesInvoiceDto, posInfo: IPosPayload) {
|
||||
data.invoice_date = new Date(data.invoice_date).toISOString() as any
|
||||
|
||||
const { complex_id, pos_id, consumer_account_id } = posInfo
|
||||
const { business_id, pos_id, consumer_account_id } = posInfo
|
||||
|
||||
const salesInvoice = await this.prisma.$transaction(async $tx => {
|
||||
const payments = Object.entries(data.payments)
|
||||
@@ -71,8 +71,8 @@ export class SalesInvoicesService {
|
||||
const customer_individual = customer.customer_individual
|
||||
const customerIndividual = await $tx.customerIndividual.upsert({
|
||||
where: {
|
||||
complex_id_national_id: {
|
||||
complex_id,
|
||||
business_activity_id_national_id: {
|
||||
business_activity_id: business_id,
|
||||
national_id: customer_individual.national_id,
|
||||
},
|
||||
},
|
||||
@@ -83,9 +83,9 @@ export class SalesInvoicesService {
|
||||
type: CustomerType.INDIVIDUAL,
|
||||
},
|
||||
},
|
||||
complex: {
|
||||
business_activity: {
|
||||
connect: {
|
||||
id: complex_id,
|
||||
id: business_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -104,9 +104,9 @@ export class SalesInvoicesService {
|
||||
|
||||
const customerLegal = await $tx.customerLegal.upsert({
|
||||
where: {
|
||||
complex_id_registration_number: {
|
||||
complex_id,
|
||||
registration_number: customer_legal.registration_number,
|
||||
business_activity_id_economic_code: {
|
||||
business_activity_id: business_id,
|
||||
economic_code: customer_legal.economic_code,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
@@ -116,9 +116,9 @@ export class SalesInvoicesService {
|
||||
type: CustomerType.LEGAL,
|
||||
},
|
||||
},
|
||||
complex: {
|
||||
business_activity: {
|
||||
connect: {
|
||||
id: complex_id,
|
||||
id: business_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user