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:
@@ -52,85 +52,5 @@ export class PosGuard {
|
||||
}
|
||||
|
||||
return true
|
||||
// const pos = await this.prisma.pos.findUnique({
|
||||
// where: {
|
||||
// id: posId,
|
||||
// account_id: tokenPayload.account_id,
|
||||
// },
|
||||
// select: {
|
||||
// complex: {
|
||||
// select: {
|
||||
// id: true,
|
||||
// business_activity: {
|
||||
// select: {
|
||||
// id: true,
|
||||
// license_activation: {
|
||||
// select: {
|
||||
// expires_at: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
|
||||
// if (!pos) {
|
||||
// throw new ForbiddenException('شما دسترسی لازم را ندارید.')
|
||||
// }
|
||||
|
||||
// if (req.method !== 'GET') {
|
||||
// if (!pos.complex.business_activity.license_activation) {
|
||||
// throw new ForbiddenException('برای کاربر شما لایسنس ایجاد نشده است.')
|
||||
// }
|
||||
// if (
|
||||
// pos.complex.business_activity.license_activation.expires_at &&
|
||||
// new Date().getTime() >
|
||||
// new Date(pos.complex.business_activity.license_activation.expires_at).getTime()
|
||||
// ) {
|
||||
// throw new ForbiddenException('لایسنس شما منقضی شده است.')
|
||||
// }
|
||||
// }
|
||||
|
||||
// const foundedAccount = await this.prisma.consumerAccount.findUnique({
|
||||
// where: {
|
||||
// id: tokenPayload.account_id,
|
||||
// },
|
||||
// select: {
|
||||
// role: true,
|
||||
// },
|
||||
// })
|
||||
|
||||
// if (foundedAccount?.role === 'OWNER') {
|
||||
// return true
|
||||
// }
|
||||
|
||||
// const accountPermissions = await this.prisma.permissionConsumer.findUnique({
|
||||
// where: {
|
||||
// consumer_account_id: tokenPayload.account_id,
|
||||
// },
|
||||
// select: {
|
||||
// pos_permissions: true,
|
||||
// business_permissions: true,
|
||||
// complex_permissions: true,
|
||||
// },
|
||||
// })
|
||||
|
||||
// if (accountPermissions?.pos_permissions.some(p => p.pos_id === posId)) {
|
||||
// return true
|
||||
// }
|
||||
// if (
|
||||
// accountPermissions?.complex_permissions.some(p => p.complex_id === pos.complex.id)
|
||||
// ) {
|
||||
// return true
|
||||
// }
|
||||
// if (
|
||||
// accountPermissions?.business_permissions.some(
|
||||
// p => p.business_id === pos.complex.business_activity.id,
|
||||
// )
|
||||
// ) {
|
||||
// return true
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ export class RedisKeyMaker extends PartnerKeyMaker {
|
||||
static guildStockKeepingUnitsList = GuildKeyMaker.guildStockKeepingUnitsList
|
||||
static guildGoodsList = GuildKeyMaker.guildGoodsList
|
||||
|
||||
static posInfo = PosKeyMaker.posInfo
|
||||
static posMe = PosKeyMaker.posMe
|
||||
static posGoodsList = PosKeyMaker.posGoodsList
|
||||
static posInfo = PosKeyMaker.info
|
||||
static posMe = PosKeyMaker.me
|
||||
static posGoodsList = PosKeyMaker.goodList
|
||||
|
||||
static enumsAll = EnumKeyMaker.enumsAll
|
||||
static enumsValues = EnumKeyMaker.enumsValues
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
export class PosKeyMaker {
|
||||
static posInfo(posId: string): string {
|
||||
static info(posId: string): string {
|
||||
return `pos:${posId}:info`
|
||||
}
|
||||
|
||||
static posMe(accountId: string, posId: string): string {
|
||||
static me(accountId: string, posId: string): string {
|
||||
return `pos:${posId}:me:${accountId}`
|
||||
}
|
||||
|
||||
static posGoodsList(businessActivityId: string, guildId: string): string {
|
||||
return `pos:ba:${businessActivityId}:guild:${guildId}:goods:list`
|
||||
static goodList(guildId: string, businessActivityId: string): string {
|
||||
return `pos:goods:list:guildId:${guildId}:ba:${businessActivityId}`
|
||||
}
|
||||
|
||||
static goodListByGuildPattern(guildId: string): string {
|
||||
return `pos:goods:list:guildId:${guildId}:ba:*`
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user