refactor(goods): streamline goods service and controller, remove favorites module
- 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.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import { PosInfo } from '@/common/decorators/posInfo.decorator'
|
||||
import type { IPosPayload } from '@/common/models'
|
||||
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 { CreateOwnedGoodsDto } from './dto/create-owned-goods.dto'
|
||||
import { UpdateOwnedGoodsDto } from './dto/update-owned-goods.dto'
|
||||
import { OwnedGoodsService } from './owned-goods.service'
|
||||
|
||||
@Controller('pos/owned-goods')
|
||||
export class OwnedGoodsController {
|
||||
constructor(private readonly service: OwnedGoodsService) {}
|
||||
|
||||
@Get()
|
||||
findAll(@PosInfo('business_id') business_id: string) {
|
||||
return this.service.findAll(business_id)
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@PosInfo('business_id') business_id: string, @Param('id') id: string) {
|
||||
return this.service.findOne(business_id, id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
@UseInterceptors(FileInterceptor('image', multerImageOptions))
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@ApiBody({
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
image: { type: 'string', format: 'binary' },
|
||||
},
|
||||
},
|
||||
})
|
||||
create(
|
||||
@PosInfo() { business_id, guild_id }: IPosPayload,
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body() dto: CreateOwnedGoodsDto,
|
||||
) {
|
||||
return this.service.create(guild_id, business_id, dto, file)
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@UseInterceptors(FileInterceptor('image', multerImageOptions))
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@ApiBody({
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
image: { type: 'string', format: 'binary' },
|
||||
},
|
||||
},
|
||||
})
|
||||
update(
|
||||
@PosInfo() { business_id, guild_id }: IPosPayload,
|
||||
@Param('id') id: string,
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body() dto: UpdateOwnedGoodsDto,
|
||||
) {
|
||||
return this.service.update(guild_id, business_id, id, dto, file)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user