debugging and add image uploader to guild good
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common'
|
||||
import { CreateGuildGoodDto } from './dto/create-good.dto'
|
||||
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'
|
||||
import { GoodsService } from './goods.service'
|
||||
|
||||
@Controller('admin/guilds/:guildId/goods')
|
||||
@@ -17,7 +29,36 @@ export class GoodsController {
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() data: CreateGuildGoodDto) {
|
||||
return this.goodsService.create(data)
|
||||
@UseInterceptors(FileInterceptor('file', multerImageOptions))
|
||||
@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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user