feat: implement partner licenses module with pagination and filtering capabilities
This commit is contained in:
@@ -23,12 +23,22 @@ export class PosGuard {
|
||||
const { posId } = cookie
|
||||
|
||||
if (!posId) {
|
||||
throw new ForbiddenException('شما دسترسی لازم را ندارید.')
|
||||
return false
|
||||
// throw new ForbiddenException('شما دسترسی لازم را ندارید.')
|
||||
}
|
||||
|
||||
const checkLicenseActivation = await this.prisma.licenseAccountAllocation.findFirst({
|
||||
where: {
|
||||
account_id: tokenPayload.account_id,
|
||||
OR: [
|
||||
{
|
||||
account_id: tokenPayload.account_id,
|
||||
},
|
||||
{
|
||||
account: {
|
||||
consumer_id: tokenPayload.user?.id,
|
||||
},
|
||||
},
|
||||
],
|
||||
license_activation: {
|
||||
OR: [
|
||||
{
|
||||
|
||||
@@ -84,6 +84,9 @@ export class ResponseMappingInterceptor implements NestInterceptor {
|
||||
// }
|
||||
break
|
||||
case 'paginate': {
|
||||
const { items: a, ...rest } = wrapped
|
||||
console.log(rest)
|
||||
|
||||
const items = Array.isArray(wrapped.items) ? wrapped.items : []
|
||||
const total =
|
||||
typeof wrapped.total === 'number' ? wrapped.total : items.length
|
||||
|
||||
@@ -12,9 +12,9 @@ export type MapperWrapper<T> =
|
||||
| { __mapped: 'delete' }
|
||||
|
||||
interface IPaginateMeta {
|
||||
count: number
|
||||
total: number
|
||||
page?: number
|
||||
pageSize?: number
|
||||
perPage?: number
|
||||
}
|
||||
|
||||
export const ResponseMapper = {
|
||||
@@ -38,12 +38,12 @@ export const ResponseMapper = {
|
||||
return { __mapped: 'list', items }
|
||||
},
|
||||
|
||||
paginate<T>(items: T[], { count, page = 1, pageSize: perPage }: IPaginateMeta) {
|
||||
return { __mapped: 'paginate', items, count, page, perPage }
|
||||
paginate<T>(items: T[], { total, page = 1, perPage }: IPaginateMeta) {
|
||||
return { __mapped: 'paginate', items, total, page, perPage }
|
||||
},
|
||||
|
||||
sequelizePaginate<T>(rows: T[], count: number, page = 1, pageSize = rows.length) {
|
||||
return { __mapped: 'sequelize', rows, count, page, pageSize }
|
||||
sequelizePaginate<T>(rows: T[], total: number, page = 1, pageSize = rows.length) {
|
||||
return { __mapped: 'sequelize', rows, total, page, pageSize }
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user