update models and create consumer domain accounts permissions

This commit is contained in:
2026-04-11 14:47:05 +03:30
parent 89726c8904
commit 9cef733370
87 changed files with 2967 additions and 3352 deletions
@@ -35,14 +35,14 @@ export class consumerCustomersService {
},
}
private defaultWhere(user_id: string): CustomerWhereInput {
private defaultWhere(consumer_id: string): CustomerWhereInput {
return {
OR: [
{
customer_individual: {
complex: {
business_activity: {
user_id,
consumer_id,
},
},
},
@@ -51,7 +51,7 @@ export class consumerCustomersService {
customer_legal: {
complex: {
business_activity: {
user_id,
consumer_id,
},
},
},
@@ -60,43 +60,45 @@ export class consumerCustomersService {
}
}
async findAll(user_id: string, page = 1, pageSize = 10) {
async findAll(consumer_id: string, page = 1, pageSize = 10) {
const [customers, count] = await this.prisma.$transaction(async tx => [
await tx.customer.findMany({
where: this.defaultWhere(user_id),
where: this.defaultWhere(consumer_id),
select: this.defaultSelect,
skip: (page - 1) * pageSize,
take: 10,
}),
await tx.customer.count({
where: this.defaultWhere(user_id),
where: this.defaultWhere(consumer_id),
}),
])
return ResponseMapper.paginate(customers, { count, page, pageSize })
}
async findOne(user_id: string, customer_id: string) {
async findOne(consumer_id: string, customer_id: string) {
const customer = await this.prisma.customer.findUniqueOrThrow({
where: {
...this.defaultWhere(user_id),
...this.defaultWhere(consumer_id),
id: customer_id,
},
select: this.defaultSelect,
})
console.log(customer)
return ResponseMapper.single(customer)
}
async updateLegal(user_id: string, customer_id: string, data: UpdateCustomerLegalDto) {
async updateLegal(
consumer_id: string,
customer_id: string,
data: UpdateCustomerLegalDto,
) {
const customer = await this.prisma.customer.update({
where: {
id: customer_id,
customer_legal: {
complex: {
business_activity: {
user_id,
consumer_id,
},
},
},
@@ -115,7 +117,7 @@ export class consumerCustomersService {
}
async updateIndividual(
user_id: string,
consumer_id: string,
customer_id: string,
data: UpdateCustomerIndividualDto,
) {
@@ -125,7 +127,7 @@ export class consumerCustomersService {
customer_individual: {
complex: {
business_activity: {
user_id,
consumer_id,
},
},
},