update
This commit is contained in:
@@ -34,6 +34,7 @@ export class PartnerLicensesService {
|
||||
},
|
||||
},
|
||||
},
|
||||
created_at: true,
|
||||
}
|
||||
|
||||
async findAll(page = 1, pageSize = 10) {
|
||||
|
||||
+32
-6
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
generateTrackingCode,
|
||||
isTrackingCodeUniqueViolation,
|
||||
} from '@/common/utils/tracking-code-generator.util'
|
||||
import {
|
||||
ChargedLicenseTransactionsWhereInput,
|
||||
LicenseCreateInput,
|
||||
@@ -11,11 +15,16 @@ import { ChargeLicenseDto } from './dto/chargedLicenseTransactions.dto'
|
||||
export class PartnerChargedLicenseTransactionsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
private readonly TRACKING_CODE_LENGTH = 8
|
||||
private readonly TRACKING_CODE_MAX_ATTEMPTS = 5
|
||||
|
||||
private readonly mappedTransaction = (transaction: any) => {
|
||||
const { licenses, ...rest } = transaction
|
||||
return {
|
||||
...rest,
|
||||
charged_license_count: licenses.length,
|
||||
activated_license_count: licenses.filter(license => license?.activated_license)
|
||||
.length,
|
||||
remained_license_count: licenses.filter(license => !license?.activated_license)
|
||||
.length,
|
||||
}
|
||||
@@ -35,6 +44,7 @@ export class PartnerChargedLicenseTransactionsService {
|
||||
id: true,
|
||||
created_at: true,
|
||||
activation_expires_at: true,
|
||||
tracking_code: true,
|
||||
licenses: {
|
||||
select: {
|
||||
activated_license: {
|
||||
@@ -88,12 +98,28 @@ export class PartnerChargedLicenseTransactionsService {
|
||||
async create(partner_id: string, data: ChargeLicenseDto) {
|
||||
try {
|
||||
return await this.prisma.$transaction(async tx => {
|
||||
const transaction = await tx.chargedLicenseTransactions.create({
|
||||
data: {
|
||||
activation_expires_at: data.activated_expires_at,
|
||||
partner: { connect: { id: partner_id } },
|
||||
},
|
||||
})
|
||||
let transaction: { id: string } | null = null
|
||||
|
||||
for (let attempt = 0; attempt < this.TRACKING_CODE_MAX_ATTEMPTS; attempt++) {
|
||||
try {
|
||||
transaction = await tx.chargedLicenseTransactions.create({
|
||||
data: {
|
||||
activation_expires_at: data.activated_expires_at,
|
||||
tracking_code: generateTrackingCode('LIC', this.TRACKING_CODE_LENGTH),
|
||||
partner: { connect: { id: partner_id } },
|
||||
},
|
||||
})
|
||||
break
|
||||
} catch (error) {
|
||||
if (
|
||||
isTrackingCodeUniqueViolation(error) &&
|
||||
attempt < this.TRACKING_CODE_MAX_ATTEMPTS - 1
|
||||
) {
|
||||
continue
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
if (!transaction) {
|
||||
throw new BadRequestException('متاسفانه مشکلی پیش آمده است.')
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Public } from '@/common/decorators/public.decorator'
|
||||
import { Controller, Get } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { AppService } from './application.service'
|
||||
|
||||
@ApiTags('App')
|
||||
@Controller('app')
|
||||
export class AppController {
|
||||
constructor(private service: AppService) {}
|
||||
|
||||
@Get('/check-version')
|
||||
@Public()
|
||||
checkVersion() {
|
||||
return this.service.checkVersion()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
import { checkAndDecodeJwtToken } from '@/common/utils/jwt-user.util'
|
||||
import { ConsumerRole } from '@/generated/prisma/enums'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import {
|
||||
ForbiddenException,
|
||||
Injectable,
|
||||
NestMiddleware,
|
||||
PreconditionFailedException,
|
||||
} from '@nestjs/common'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
|
||||
@Injectable()
|
||||
export class PosMiddleware implements NestMiddleware {
|
||||
constructor(
|
||||
private prisma: PrismaService,
|
||||
private jwtService: JwtService,
|
||||
) {}
|
||||
|
||||
async use(req: Request, _res: Response, next: NextFunction) {
|
||||
const doForbidden = () => {
|
||||
throw new ForbiddenException('شما دسترسی لازم را ندارید')
|
||||
}
|
||||
try {
|
||||
const tokenAccount = checkAndDecodeJwtToken(req, this.jwtService)
|
||||
|
||||
const { type, role, account_id } = tokenAccount!
|
||||
|
||||
let posId = req.cookies['posId']
|
||||
|
||||
if (type !== 'CONSUMER') {
|
||||
return doForbidden()
|
||||
}
|
||||
|
||||
if (req.url.startsWith('/api/v1/pos/accessible')) {
|
||||
req.decodedToken = tokenAccount!
|
||||
return next()
|
||||
}
|
||||
|
||||
if (!posId || typeof posId !== 'string') {
|
||||
const pos = await this.prisma.pos.findMany({
|
||||
where: {
|
||||
complex: {
|
||||
business_activity: {
|
||||
consumer: {
|
||||
consumer_accounts: {
|
||||
some: {
|
||||
id: account_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
permission_pos: {
|
||||
some: {
|
||||
permission: {
|
||||
consumer_account_id: account_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if (!pos?.length) {
|
||||
throw new ForbiddenException('پایانهی فروشی برای شما یافت نشد')
|
||||
}
|
||||
if (pos.length === 1) {
|
||||
posId = pos[0].id
|
||||
} else
|
||||
throw new PreconditionFailedException('پایانهی مورد نظر خود را انتخاب کنید.')
|
||||
}
|
||||
|
||||
const pos = await this.prisma.pos.findUnique({
|
||||
where: {
|
||||
id: posId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
complex: {
|
||||
select: {
|
||||
id: true,
|
||||
business_activity: {
|
||||
select: {
|
||||
id: true,
|
||||
guild_id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if (!pos) {
|
||||
return doForbidden()
|
||||
}
|
||||
|
||||
if (role !== ConsumerRole.OWNER) {
|
||||
const accountPermissions = await this.prisma.permissionConsumer.findUnique({
|
||||
where: {
|
||||
consumer_account_id: account_id,
|
||||
},
|
||||
select: {
|
||||
pos_permissions: {
|
||||
select: {
|
||||
pos_id: true,
|
||||
},
|
||||
},
|
||||
business_permissions: {
|
||||
select: {
|
||||
business_id: true,
|
||||
},
|
||||
},
|
||||
complex_permissions: {
|
||||
select: {
|
||||
complex_id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if (
|
||||
!// accountPermissions?.business_permissions.some(
|
||||
// permission => permission.id,
|
||||
// ) ||
|
||||
// accountPermissions?.complex_permissions.some(
|
||||
// permission => permission.complex_id,
|
||||
// ) ||
|
||||
accountPermissions?.pos_permissions.some(permission => permission.pos_id)
|
||||
) {
|
||||
return doForbidden()
|
||||
}
|
||||
}
|
||||
req.posData = {
|
||||
pos_id: posId,
|
||||
complex_id: pos.complex.id,
|
||||
business_id: pos.complex.id,
|
||||
guild_id: pos.complex.business_activity.guild_id,
|
||||
consumer_account_id: account_id,
|
||||
}
|
||||
req.decodedToken = tokenAccount!
|
||||
|
||||
return next()
|
||||
} catch (error) {
|
||||
if (error && typeof error === 'object') {
|
||||
throw error
|
||||
}
|
||||
|
||||
return doForbidden()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { AppController } from './application.controller'
|
||||
import { AppService } from './application.service'
|
||||
import { ApplicationAuthModule } from './auth/auth.module'
|
||||
import { ApplicationConfigModule } from './config/config.module'
|
||||
|
||||
@Module({
|
||||
controllers: [AppController],
|
||||
providers: [AppService, JwtService],
|
||||
imports: [ApplicationConfigModule, ApplicationAuthModule],
|
||||
})
|
||||
export class ApplicationModule {}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async checkVersion() {
|
||||
return await this.prisma.applicationReleasedInfo.findFirst({
|
||||
where: {
|
||||
is_minimum_supported: true,
|
||||
},
|
||||
orderBy: {
|
||||
build_number: 'desc',
|
||||
},
|
||||
select: {
|
||||
build_number: true,
|
||||
version: true,
|
||||
platform: true,
|
||||
is_minimum_supported: true,
|
||||
release_type: true,
|
||||
notes: true,
|
||||
release_date: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Public } from '@/common/decorators/public.decorator'
|
||||
import { Body, Controller, Post } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { ApplicationAuthService } from './auth.service'
|
||||
import { applicationLoginDto } from './dto/auth.dto'
|
||||
|
||||
@ApiTags('Application Auth')
|
||||
@Controller('app/auth')
|
||||
export class ApplicationAuthController {
|
||||
constructor(private service: ApplicationAuthService) {}
|
||||
|
||||
@Post('/login')
|
||||
@Public()
|
||||
login(@Body() data: applicationLoginDto) {
|
||||
return this.service.login(data)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { AuthModule } from '@/modules/auth/auth.module'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { ApplicationAuthController } from './auth.controller'
|
||||
import { ApplicationAuthService } from './auth.service'
|
||||
|
||||
@Module({
|
||||
controllers: [ApplicationAuthController],
|
||||
providers: [ApplicationAuthService],
|
||||
imports: [AuthModule],
|
||||
})
|
||||
export class ApplicationAuthModule {}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { AuthService } from '@/modules/auth/auth.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { applicationLoginDto } from './dto/auth.dto'
|
||||
|
||||
@Injectable()
|
||||
export class ApplicationAuthService {
|
||||
constructor(private readonly authService: AuthService) {}
|
||||
|
||||
async login(data: applicationLoginDto) {
|
||||
const loginResponse = await this.authService.login(data, true)
|
||||
|
||||
return loginResponse
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { LoginDto } from '@/modules/auth/dto/login.dto'
|
||||
|
||||
export class applicationLoginDto extends LoginDto {}
|
||||
+4
-3
@@ -1,8 +1,9 @@
|
||||
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common'
|
||||
import { ConfigService } from './config.service'
|
||||
import { CreateConfigDto } from './dto/create-config.dto'
|
||||
|
||||
@Controller('pos/config')
|
||||
@Controller('app/config')
|
||||
export class ConfigController {
|
||||
constructor(private readonly configService: ConfigService) {}
|
||||
|
||||
@@ -12,7 +13,7 @@ export class ConfigController {
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() data: CreateConfigDto) {
|
||||
return this.configService.create(data)
|
||||
create(@TokenAccount('userId') consumerId: string, @Body() data: CreateConfigDto) {
|
||||
return this.configService.create(consumerId, data)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,4 +6,4 @@ import { ConfigService } from './config.service'
|
||||
controllers: [ConfigController],
|
||||
providers: [ConfigService],
|
||||
})
|
||||
export class PosConfigModule {}
|
||||
export class ApplicationConfigModule {}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { ConsumerDevicesSelect } from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { BadRequestException, Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreateConfigDto } from './dto/create-config.dto'
|
||||
|
||||
@Injectable()
|
||||
export class ConfigService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
private readonly defaultSelect: ConsumerDevicesSelect = {
|
||||
uuid: true,
|
||||
app_version: true,
|
||||
brand: true,
|
||||
browser_name: true,
|
||||
build_number: true,
|
||||
device: true,
|
||||
os_version: true,
|
||||
fcm_token: true,
|
||||
model: true,
|
||||
platform: true,
|
||||
release_number: true,
|
||||
sdk_version: true,
|
||||
consumer: {
|
||||
select: {
|
||||
id: true,
|
||||
first_name: true,
|
||||
last_name: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
async findOne(uuid: string) {
|
||||
const config = await this.prisma.consumerDevices.findUnique({
|
||||
where: {
|
||||
uuid,
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
|
||||
return ResponseMapper.single(config)
|
||||
}
|
||||
|
||||
async create(consumer_id: string, data: CreateConfigDto) {
|
||||
const prevConfig = await this.prisma.consumerDevices.findUnique({
|
||||
where: {
|
||||
uuid: data.uuid,
|
||||
},
|
||||
select: {
|
||||
consumer_id: true,
|
||||
},
|
||||
})
|
||||
|
||||
if (prevConfig && consumer_id !== prevConfig.consumer_id) {
|
||||
throw new BadRequestException('این دستگاه با کاربری دیگری ثبت شده است.')
|
||||
}
|
||||
|
||||
const config = await this.prisma.consumerDevices.upsert({
|
||||
where: {
|
||||
uuid: data.uuid,
|
||||
},
|
||||
update: {
|
||||
...data,
|
||||
consumer: {
|
||||
connect: {
|
||||
id: consumer_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
create: {
|
||||
...data,
|
||||
consumer: {
|
||||
connect: {
|
||||
id: consumer_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
|
||||
return ResponseMapper.create(config)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import { ApplicationPlatform, ApplicationPublisher } from '@/generated/prisma/enums'
|
||||
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator'
|
||||
|
||||
export class CreateConfigDto {
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsEnum(ApplicationPublisher)
|
||||
publisher: ApplicationPublisher
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
app_version: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
build_number: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsEnum(ApplicationPlatform)
|
||||
platform: ApplicationPlatform
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
brand: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
model: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
device: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
os_version: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
sdk_version: string
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
release_number: string
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
browser_name: string
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
user_agent: string
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
fcm_token?: string
|
||||
}
|
||||
|
||||
export class UpdateConfigDto extends PartialType(CreateConfigDto) {}
|
||||
@@ -12,7 +12,7 @@ export class AuthService {
|
||||
private authUtils: AuthUtils,
|
||||
) {}
|
||||
|
||||
async login(dto: LoginDto) {
|
||||
async login(dto: LoginDto, isPos = false) {
|
||||
const { username, password } = dto
|
||||
|
||||
const account = await this.prisma.account.findUnique({
|
||||
@@ -25,6 +25,17 @@ export class AuthService {
|
||||
throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
|
||||
}
|
||||
|
||||
if (isPos) {
|
||||
const posAccount = await this.prisma.consumerAccount.findUnique({
|
||||
where: {
|
||||
account_id: account.id,
|
||||
},
|
||||
})
|
||||
if (!posAccount) {
|
||||
throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
|
||||
}
|
||||
}
|
||||
|
||||
await this.authUtils.checkAuthPassword(password, account.password)
|
||||
|
||||
const preparedData = await this.authUtils.generateLoginResponse(account)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { Public } from 'common/decorators/public.decorator'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreateConfigDto } from './dto/create-config.dto'
|
||||
|
||||
@Injectable()
|
||||
export class ConfigService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
@Public()
|
||||
async findOne(uuid: string) {
|
||||
const config = await this.prisma.userDevices.findUnique({
|
||||
where: {
|
||||
uuid,
|
||||
},
|
||||
})
|
||||
|
||||
return ResponseMapper.single(config)
|
||||
}
|
||||
|
||||
@Public()
|
||||
async create(data: CreateConfigDto) {
|
||||
const config = await this.prisma.userDevices.upsert({
|
||||
where: {
|
||||
uuid: data.uuid,
|
||||
},
|
||||
update: {
|
||||
...data,
|
||||
},
|
||||
create: {
|
||||
...data,
|
||||
},
|
||||
})
|
||||
|
||||
return ResponseMapper.create(config)
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsOptional, IsString } from 'class-validator'
|
||||
|
||||
export class CreateConfigDto {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
app_version: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
build_number: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
fcm_token?: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
platform: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
brand: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
model: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
device: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
os_version: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
sdk_version: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
release_number: string
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
browser_name: string
|
||||
}
|
||||
|
||||
export class UpdateConfigDto extends PartialType(CreateConfigDto) {}
|
||||
@@ -11,6 +11,7 @@ export class PosController {
|
||||
|
||||
@Get()
|
||||
async getInfo(@PosInfo('pos_id') pos_id: string, @Res({ passthrough: true }) res) {
|
||||
console.log('getInfo', pos_id)
|
||||
const result = await this.service.getInfo(pos_id)
|
||||
|
||||
if (result) {
|
||||
@@ -30,4 +31,9 @@ export class PosController {
|
||||
async getAccessiblePos(@TokenAccount('account_id') account_id) {
|
||||
return await this.service.getAccessible(account_id)
|
||||
}
|
||||
|
||||
@Get('/me')
|
||||
async getMe(@TokenAccount('account_id') account_id, @PosInfo('pos_id') pos_id: string) {
|
||||
return await this.service.getMe(account_id, pos_id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common'
|
||||
import { JwtService } from '@nestjs/jwt'
|
||||
import { PosConfigModule } from './config/config.module'
|
||||
import { PosCustomersModule } from './customers/customers.module'
|
||||
import { PosGoodCategoriesModule } from './good-categories/good-categories.module'
|
||||
import { PosGoodsModule } from './goods/goods.module'
|
||||
@@ -13,7 +12,6 @@ import { PosSalesInvoicesModule } from './sales-invoices/sales-invoices.module'
|
||||
controllers: [PosController],
|
||||
providers: [PosService, JwtService],
|
||||
imports: [
|
||||
PosConfigModule,
|
||||
PosCustomersModule,
|
||||
PosGoodCategoriesModule,
|
||||
PosGoodsModule,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ConsumerStatus } from '@/generated/prisma/enums'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
@@ -96,4 +97,45 @@ export class PosService {
|
||||
|
||||
return ResponseMapper.list(poses)
|
||||
}
|
||||
|
||||
async getMe(account_id: string, pos_id: string) {
|
||||
const account = await this.prisma.consumerAccount.findUniqueOrThrow({
|
||||
where: {
|
||||
id: account_id,
|
||||
consumer: {
|
||||
status: ConsumerStatus.ACTIVE,
|
||||
business_activities: {
|
||||
some: {
|
||||
complexes: {
|
||||
some: {
|
||||
pos_list: {
|
||||
some: {
|
||||
id: pos_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
role: true,
|
||||
consumer: {
|
||||
select: {
|
||||
first_name: true,
|
||||
last_name: true,
|
||||
},
|
||||
},
|
||||
account: {
|
||||
select: {
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
return ResponseMapper.single(account)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user