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 { 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user