2026-04-18 12:14:19 +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 } from '@nestjs/swagger'
|
|
|
|
|
import { CreateGuildGoodDto, UpdateGuildGoodDto } from './dto/create-good.dto'
|
2026-03-07 11:25:11 +03:30
|
|
|
import { GoodsService } from './goods.service'
|
|
|
|
|
|
|
|
|
|
@Controller('admin/guilds/:guildId/goods')
|
|
|
|
|
export class GoodsController {
|
|
|
|
|
constructor(private readonly goodsService: GoodsService) {}
|
|
|
|
|
|
|
|
|
|
@Get()
|
|
|
|
|
findAll(@Param('guildId') guildId: string) {
|
|
|
|
|
return this.goodsService.findAll(guildId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get(':id')
|
|
|
|
|
findOne(@Param('guildId') guildId: string, @Param('id') goodId: string) {
|
|
|
|
|
return this.goodsService.findOne(guildId, goodId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post()
|
2026-05-07 20:30:24 +03:30
|
|
|
@UseInterceptors(FileInterceptor('image', multerImageOptions))
|
2026-04-18 12:14:19 +03:30
|
|
|
@ApiConsumes('multipart/form-data')
|
|
|
|
|
@ApiBody({
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
|
|
|
|
image: { type: 'string', format: 'binary' },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
create(@Body() data: CreateGuildGoodDto, @UploadedFile() file: Express.Multer.File) {
|
|
|
|
|
return this.goodsService.create(data, file)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch(':id')
|
|
|
|
|
@UseInterceptors(FileInterceptor('image', multerImageOptions))
|
|
|
|
|
@ApiConsumes('multipart/form-data')
|
|
|
|
|
@ApiBody({
|
|
|
|
|
schema: {
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
|
|
|
|
image: { type: 'string', format: 'binary' },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
update(
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Body() data: UpdateGuildGoodDto,
|
|
|
|
|
@UploadedFile() file: Express.Multer.File,
|
|
|
|
|
) {
|
|
|
|
|
return this.goodsService.update(id, data, file)
|
2026-03-07 11:25:11 +03:30
|
|
|
}
|
|
|
|
|
}
|