2026-04-27 10:45:39 +03:30
|
|
|
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
2026-05-07 20:30:24 +03:30
|
|
|
import { multerImageOptions } from '@/multer.config'
|
|
|
|
|
import {
|
|
|
|
|
Body,
|
|
|
|
|
Controller,
|
|
|
|
|
Get,
|
|
|
|
|
Param,
|
|
|
|
|
Patch,
|
|
|
|
|
Post,
|
|
|
|
|
UploadedFile,
|
|
|
|
|
UseInterceptors,
|
|
|
|
|
} from '@nestjs/common'
|
|
|
|
|
import { FileInterceptor } from '@nestjs/platform-express'
|
|
|
|
|
import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger'
|
2026-04-27 10:45:39 +03:30
|
|
|
import { CreateGoodDto, UpdateGoodDto } from './dto/good.dto'
|
2026-05-07 20:30:24 +03:30
|
|
|
import type {
|
|
|
|
|
ConsumerBusinessActivityGoodsServiceFindAllResponseDto,
|
|
|
|
|
ConsumerBusinessActivityGoodsServiceFindOneResponseDto,
|
|
|
|
|
} from './dto/goods-response.dto'
|
2026-04-27 10:45:39 +03:30
|
|
|
import { ConsumerBusinessActivityGoodsService } from './goods.service'
|
|
|
|
|
|
|
|
|
|
@ApiTags('ConsumerBusinessActivityGoods')
|
|
|
|
|
@Controller('consumer/business_activities/:businessActivityId/goods')
|
|
|
|
|
export class ConsumerBusinessActivityGoodsController {
|
|
|
|
|
constructor(private readonly service: ConsumerBusinessActivityGoodsService) {}
|
|
|
|
|
|
|
|
|
|
@Get()
|
|
|
|
|
async findAll(
|
|
|
|
|
@TokenAccount('userId') consumer_id: string,
|
|
|
|
|
@Param('businessActivityId') businessActivityId: string,
|
|
|
|
|
): Promise<ConsumerBusinessActivityGoodsServiceFindAllResponseDto> {
|
|
|
|
|
return this.service.findAll(consumer_id, businessActivityId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get(':id')
|
|
|
|
|
async findOne(
|
|
|
|
|
@TokenAccount('userId') consumer_id: string,
|
|
|
|
|
@Param('businessActivityId') businessActivityId: string,
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
): Promise<ConsumerBusinessActivityGoodsServiceFindOneResponseDto> {
|
|
|
|
|
return this.service.findOne(consumer_id, businessActivityId, id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post()
|
2026-05-07 20:30:24 +03:30
|
|
|
@UseInterceptors(FileInterceptor('image', multerImageOptions))
|
|
|
|
|
@ApiConsumes('multipart/form-data')
|
|
|
|
|
@ApiBody({
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
|
|
|
|
image: { type: 'string', format: 'binary' },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
create(
|
2026-04-27 10:45:39 +03:30
|
|
|
@Param('businessActivityId') businessActivityId: string,
|
|
|
|
|
@Body() data: CreateGoodDto,
|
2026-05-07 20:30:24 +03:30
|
|
|
@UploadedFile() file: Express.Multer.File,
|
|
|
|
|
) {
|
|
|
|
|
return this.service.create(businessActivityId, data, file)
|
2026-04-27 10:45:39 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch(':id')
|
2026-05-07 20:30:24 +03:30
|
|
|
@UseInterceptors(FileInterceptor('image', multerImageOptions))
|
|
|
|
|
@ApiConsumes('multipart/form-data')
|
|
|
|
|
@ApiBody({
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
|
|
|
|
image: { type: 'string', format: 'binary' },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
update(
|
2026-04-27 10:45:39 +03:30
|
|
|
@TokenAccount('userId') consumer_id: string,
|
|
|
|
|
@Param('businessActivityId') businessActivityId: string,
|
|
|
|
|
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Body() data: UpdateGoodDto,
|
2026-05-07 20:30:24 +03:30
|
|
|
@UploadedFile() file: Express.Multer.File,
|
|
|
|
|
) {
|
|
|
|
|
return this.service.update(consumer_id, businessActivityId, id, data, file)
|
2026-04-27 10:45:39 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Delete(':id')
|
|
|
|
|
// async delete(@Param('id') id: string) {
|
|
|
|
|
// return this.businessActivityAccountsService.delete(id)
|
|
|
|
|
// }
|
|
|
|
|
}
|