feat: add consumer accounts and business activities management

- Implemented AccountsService for managing consumer accounts including create, update, delete, and find operations.
- Created DTOs for account creation and updates.
- Developed BusinessActivitiesController and BusinessActivitiesService for handling business activities related to consumers.
- Added complexes management with ComplexesController and ComplexesService.
- Introduced POS management with ComplexPosesController and ComplexPosesService.
- Created necessary DTOs for business activities and POS.
- Established Licenses management with LicensesController and LicensesService.
- Integrated consumer management with PartnerConsumersController and PartnerConsumersService.
- Added Prisma module imports and service connections across modules.
This commit is contained in:
2026-04-23 20:59:39 +03:30
parent f9e1ad69dc
commit a350ec7990
104 changed files with 13233 additions and 4105 deletions
+11 -17
View File
@@ -39,11 +39,6 @@ export class ConsumerGuard {
role: true,
},
},
activated_licenses: {
select: {
expires_at: true,
},
},
},
})
@@ -53,18 +48,17 @@ export class ConsumerGuard {
const req = context.switchToHttp().getRequest<ExpressRequest>()
if (req.method !== 'GET') {
if (!consumer.activated_licenses) {
throw new ForbiddenException('برای کاربر شما لایسنس ایجاد نشده است.')
}
if (
consumer.activated_licenses.every(
license => new Date().getTime() > new Date(license?.expires_at).getTime(),
)
) {
throw new ForbiddenException('لایسنس شما منقضی شده است.')
}
}
// if (req.method !== 'GET') {
// if (!consumer.activation) {
// throw new ForbiddenException('برای کاربر شما لایسنس ایجاد نشده است.')
// }
// if (
// consumer.activation &&
// new Date().getTime() > new Date(consumer.activation.expires_at).getTime()
// ) {
// throw new ForbiddenException('لایسنس شما منقضی شده است.')
// }
// }
return true
}
}
+9 -10
View File
@@ -50,15 +50,14 @@ export class PosGuard {
business_activity: {
select: {
id: true,
consumer: {
license_activation: {
select: {
activated_licenses: {
select: {
expires_at: true,
},
},
expires_at: true,
},
},
consumer: {
select: {},
},
},
},
},
@@ -71,13 +70,13 @@ export class PosGuard {
}
if (req.method !== 'GET') {
if (!pos.complex.business_activity.consumer.activated_licenses.length) {
if (!pos.complex.business_activity.license_activation) {
throw new ForbiddenException('برای کاربر شما لایسنس ایجاد نشده است.')
}
if (
pos.complex.business_activity.consumer.activated_licenses.every(
license => new Date().getTime() > new Date(license?.expires_at).getTime(),
)
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('لایسنس شما منقضی شده است.')
}
+4
View File
@@ -70,6 +70,10 @@ export class JwtAuthGuard implements CanActivate {
// await this.consumerGuard.canActivate(tokenPayload, context)
// await this.consumerGuard.canActivate(tokenPayload, context)
await this.posGuard.canActivate(tokenPayload, context)
} else if (req.url.startsWith('/api/v1/partner')) {
// await this.consumerGuard.canActivate(tokenPayload, context)
// await this.consumerGuard.canActivate(tokenPayload, context)
await this.partnerGuard.canActivate(tokenPayload, context)
} else if (tokenPayload.type != 'ADMIN') {
throw new ForbiddenException('شما دسترسی لازم را ندارید')
}