1d47fb1a1d
- Removed the PosGoodFavorite module, controller, and service to simplify the codebase. - Updated goods service to handle cache invalidation directly. - Refactored goods controller to remove commented-out code and improve clarity. - Introduced OwnedGoods module for better organization of owned goods functionality. - Updated DTOs to extend from existing structures for consistency. - Enhanced cache invalidation logic in goods service and owned goods service.
70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
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')
|
|
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()
|
|
@UseInterceptors(FileInterceptor('image', multerImageOptions))
|
|
@ApiConsumes('multipart/form-data')
|
|
@ApiBody({
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
image: { type: 'string', format: 'binary' },
|
|
},
|
|
},
|
|
})
|
|
create(
|
|
@Param('guildId') guildId: string,
|
|
@Body() data: CreateGuildGoodDto,
|
|
@UploadedFile() file: Express.Multer.File,
|
|
) {
|
|
return this.goodsService.create(guildId, data, file)
|
|
}
|
|
|
|
@Patch(':id')
|
|
@UseInterceptors(FileInterceptor('image', multerImageOptions))
|
|
@ApiConsumes('multipart/form-data')
|
|
@ApiBody({
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
image: { type: 'string', format: 'binary' },
|
|
},
|
|
},
|
|
})
|
|
update(
|
|
@Param('guildId') guildId: string,
|
|
@Param('id') id: string,
|
|
@Body() data: UpdateGuildGoodDto,
|
|
@UploadedFile() file: Express.Multer.File,
|
|
) {
|
|
return this.goodsService.update(guildId, id, data, file)
|
|
}
|
|
}
|