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:
@@ -36,7 +36,6 @@ export class ConsumerBusinessActivityGoodsController {
|
||||
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)
|
||||
|
||||
@@ -111,10 +111,15 @@ export class ConsumerBusinessActivityGoodsService {
|
||||
},
|
||||
},
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
|
||||
business_activity_id,
|
||||
)
|
||||
|
||||
if (good.category) {
|
||||
await this.posCacheInvalidationService.invalidatePosGoodsList(
|
||||
good.category.guild_id!,
|
||||
business_activity_id,
|
||||
)
|
||||
}
|
||||
return ResponseMapper.create(good)
|
||||
}
|
||||
|
||||
@@ -127,7 +132,7 @@ export class ConsumerBusinessActivityGoodsService {
|
||||
) {
|
||||
const good = await this.prisma.$transaction(async tx => {
|
||||
const { category_id, sku_id, measure_unit_id, ...rest } = data
|
||||
let image_url = ''
|
||||
let image_url = undefined as string | undefined
|
||||
if (file) {
|
||||
const uploadedUrl = await this.uploaderService.uploadFile(
|
||||
file,
|
||||
@@ -177,11 +182,16 @@ export class ConsumerBusinessActivityGoodsService {
|
||||
},
|
||||
...rest,
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
})
|
||||
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
|
||||
business_activity_id,
|
||||
)
|
||||
|
||||
if (good.category) {
|
||||
await this.posCacheInvalidationService.invalidatePosGoodsList(
|
||||
good.category.guild_id!,
|
||||
business_activity_id,
|
||||
)
|
||||
}
|
||||
return ResponseMapper.update(good)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user