2026-03-29 18:06:41 +03:30
|
|
|
import { PrismaService } from '@/prisma/prisma.service'
|
|
|
|
|
import { Injectable } from '@nestjs/common'
|
|
|
|
|
import { ResponseMapper } from 'common/response/response-mapper'
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class PosService {
|
|
|
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
|
|
|
|
|
|
async getInfo(pos_id: string) {
|
|
|
|
|
const pos = await this.prisma.pos.findUniqueOrThrow({
|
|
|
|
|
where: {
|
|
|
|
|
id: pos_id,
|
|
|
|
|
},
|
|
|
|
|
select: {
|
|
|
|
|
name: true,
|
|
|
|
|
complex: {
|
|
|
|
|
select: {
|
|
|
|
|
id: true,
|
|
|
|
|
name: true,
|
|
|
|
|
tax_id: true,
|
|
|
|
|
business_activity: {
|
|
|
|
|
select: {
|
|
|
|
|
id: true,
|
|
|
|
|
name: true,
|
|
|
|
|
guild: {
|
|
|
|
|
select: {
|
|
|
|
|
id: true,
|
|
|
|
|
name: true,
|
|
|
|
|
code: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
const { name, complex } = pos
|
|
|
|
|
const { name: complexName, id: complexId, tax_id, business_activity } = complex
|
|
|
|
|
const { name: businessName, id: businessId, guild } = business_activity
|
|
|
|
|
|
|
|
|
|
return ResponseMapper.single({
|
|
|
|
|
name,
|
|
|
|
|
complex: {
|
|
|
|
|
id: complexId,
|
|
|
|
|
name: complexName,
|
|
|
|
|
tax_id,
|
|
|
|
|
},
|
|
|
|
|
businessActivity: {
|
|
|
|
|
id: businessId,
|
|
|
|
|
name: businessName,
|
|
|
|
|
},
|
|
|
|
|
guild,
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-04-11 14:47:05 +03:30
|
|
|
|
|
|
|
|
async getAccessible(account_id: string) {
|
|
|
|
|
const poses = await this.prisma.pos.findMany({
|
|
|
|
|
where: {
|
|
|
|
|
complex: {
|
|
|
|
|
business_activity: {
|
|
|
|
|
consumer: {
|
|
|
|
|
consumer_accounts: {
|
|
|
|
|
some: {
|
|
|
|
|
id: account_id,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-13 13:21:50 +03:30
|
|
|
permission_pos: {
|
|
|
|
|
some: {
|
|
|
|
|
permission: {
|
|
|
|
|
consumer_account_id: account_id,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
select: {
|
|
|
|
|
id: true,
|
|
|
|
|
name: true,
|
|
|
|
|
complex: {
|
|
|
|
|
select: {
|
|
|
|
|
id: true,
|
|
|
|
|
name: true,
|
|
|
|
|
business_activity: {
|
|
|
|
|
select: {
|
|
|
|
|
id: true,
|
|
|
|
|
name: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-04-11 14:47:05 +03:30
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return ResponseMapper.list(poses)
|
|
|
|
|
}
|
2026-03-29 18:06:41 +03:30
|
|
|
}
|