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:
@@ -1,9 +1,5 @@
|
||||
import { Body, Controller, Get, Param, Post, Put } from '@nestjs/common'
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { BusinessActivitiesService } from './business-activities.service'
|
||||
import {
|
||||
CreateBusinessActivitiesDto,
|
||||
UpdateBusinessActivityDto,
|
||||
} from './dto/create-business-activities.dto'
|
||||
|
||||
@Controller('admin/consumers/:consumerId/business_activities')
|
||||
export class BusinessActivitiesController {
|
||||
@@ -19,22 +15,22 @@ export class BusinessActivitiesController {
|
||||
return this.businessActivitiesService.findOne(consumerId, id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Body() data: CreateBusinessActivitiesDto,
|
||||
) {
|
||||
return this.businessActivitiesService.create(consumerId, data)
|
||||
}
|
||||
// @Post()
|
||||
// async create(
|
||||
// @Param('consumerId') consumerId: string,
|
||||
// @Body() data: CreateBusinessActivitiesDto,
|
||||
// ) {
|
||||
// return this.businessActivitiesService.create(consumerId, data)
|
||||
// }
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdateBusinessActivityDto,
|
||||
) {
|
||||
return this.businessActivitiesService.update(consumerId, id, data)
|
||||
}
|
||||
// @Put(':id')
|
||||
// async update(
|
||||
// @Param('consumerId') consumerId: string,
|
||||
// @Param('id') id: string,
|
||||
// @Body() data: UpdateBusinessActivityDto,
|
||||
// ) {
|
||||
// return this.businessActivitiesService.update(consumerId, id, data)
|
||||
// }
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param('id') id: string) {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { BusinessActivitySelect } from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreateBusinessActivitiesDto } from './dto/create-business-activities.dto'
|
||||
|
||||
@Injectable()
|
||||
export class BusinessActivitiesService {
|
||||
@@ -39,37 +38,37 @@ export class BusinessActivitiesService {
|
||||
return ResponseMapper.single(businessActivity)
|
||||
}
|
||||
|
||||
async create(consumer_id: string, data: CreateBusinessActivitiesDto) {
|
||||
const businessActivity = await this.prisma.businessActivity.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
guild: {
|
||||
connect: {
|
||||
id: data.guild_id,
|
||||
},
|
||||
},
|
||||
consumer: {
|
||||
connect: {
|
||||
id: consumer_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
return ResponseMapper.create(businessActivity)
|
||||
}
|
||||
// async create(consumer_id: string, data: CreateBusinessActivitiesDto) {
|
||||
// const businessActivity = await this.prisma.businessActivity.create({
|
||||
// data: {
|
||||
// name: data.name,
|
||||
// guild: {
|
||||
// connect: {
|
||||
// id: data.guild_id,
|
||||
// },
|
||||
// },
|
||||
// consumer: {
|
||||
// connect: {
|
||||
// id: consumer_id,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// select: this.defaultSelect,
|
||||
// })
|
||||
// return ResponseMapper.create(businessActivity)
|
||||
// }
|
||||
|
||||
async update(consumer_id: string, id: string, data: any) {
|
||||
const businessActivity = await this.prisma.businessActivity.update({
|
||||
where: { id, consumer_id },
|
||||
data,
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
return ResponseMapper.update(businessActivity)
|
||||
}
|
||||
// async update(consumer_id: string, id: string, data: any) {
|
||||
// const businessActivity = await this.prisma.businessActivity.update({
|
||||
// where: { id, consumer_id },
|
||||
// data,
|
||||
// select: this.defaultSelect,
|
||||
// })
|
||||
// return ResponseMapper.update(businessActivity)
|
||||
// }
|
||||
|
||||
async delete(id: string) {
|
||||
await this.prisma.businessActivity.delete({ where: { id } })
|
||||
return ResponseMapper.delete()
|
||||
}
|
||||
// async delete(id: string) {
|
||||
// await this.prisma.businessActivity.delete({ where: { id } })
|
||||
// return ResponseMapper.delete()
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { BusinessActivityComplexesService } from './complexes.service'
|
||||
import { CreateComplexDto, UpdateComplexDto } from './dto/complex.dto'
|
||||
|
||||
@ApiTags('AdminBusinessActivityComplexes')
|
||||
@Controller(
|
||||
@@ -27,23 +26,23 @@ export class BusinessActivityComplexesController {
|
||||
return this.service.findOne(consumerId, businessActivityId, id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Body() data: CreateComplexDto,
|
||||
) {
|
||||
return this.service.create(businessActivityId, data)
|
||||
}
|
||||
// @Post()
|
||||
// async create(
|
||||
// @Param('businessActivityId') businessActivityId: string,
|
||||
// @Body() data: CreateComplexDto,
|
||||
// ) {
|
||||
// return this.service.create(businessActivityId, data)
|
||||
// }
|
||||
|
||||
@Patch(':id')
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Body() data: UpdateComplexDto,
|
||||
) {
|
||||
return this.service.update(consumerId, businessActivityId, id, data)
|
||||
}
|
||||
// @Patch(':id')
|
||||
// async update(
|
||||
// @Param('id') id: string,
|
||||
// @Param('consumerId') consumerId: string,
|
||||
// @Param('businessActivityId') businessActivityId: string,
|
||||
// @Body() data: UpdateComplexDto,
|
||||
// ) {
|
||||
// return this.service.update(consumerId, businessActivityId, id, data)
|
||||
// }
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param('id') id: string) {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { ComplexSelect } from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreateComplexDto, UpdateComplexDto } from './dto/complex.dto'
|
||||
|
||||
@Injectable()
|
||||
export class BusinessActivityComplexesService {
|
||||
@@ -47,40 +46,40 @@ export class BusinessActivityComplexesService {
|
||||
return ResponseMapper.single(account)
|
||||
}
|
||||
|
||||
async create(business_id: string, data: CreateComplexDto) {
|
||||
const account = await this.prisma.complex.create({
|
||||
data: {
|
||||
...data,
|
||||
business_activity: {
|
||||
connect: {
|
||||
id: business_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
return ResponseMapper.create(account)
|
||||
}
|
||||
// async create(business_id: string, data: CreateComplexDto) {
|
||||
// const account = await this.prisma.complex.create({
|
||||
// data: {
|
||||
// ...data,
|
||||
// business_activity: {
|
||||
// connect: {
|
||||
// id: business_id,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// return ResponseMapper.create(account)
|
||||
// }
|
||||
|
||||
async update(
|
||||
consumer_id: string,
|
||||
business_activity_id: string,
|
||||
id: string,
|
||||
data: UpdateComplexDto,
|
||||
) {
|
||||
const account = await this.prisma.complex.update({
|
||||
where: {
|
||||
business_activity: {
|
||||
id: business_activity_id,
|
||||
consumer: {
|
||||
id: consumer_id,
|
||||
},
|
||||
},
|
||||
id,
|
||||
},
|
||||
data,
|
||||
})
|
||||
return ResponseMapper.update(account)
|
||||
}
|
||||
// async update(
|
||||
// consumer_id: string,
|
||||
// business_activity_id: string,
|
||||
// id: string,
|
||||
// data: UpdateComplexDto,
|
||||
// ) {
|
||||
// const account = await this.prisma.complex.update({
|
||||
// where: {
|
||||
// business_activity: {
|
||||
// id: business_activity_id,
|
||||
// consumer: {
|
||||
// id: consumer_id,
|
||||
// },
|
||||
// },
|
||||
// id,
|
||||
// },
|
||||
// data,
|
||||
// })
|
||||
// return ResponseMapper.update(account)
|
||||
// }
|
||||
|
||||
// async delete(id: string) {
|
||||
// await this.prisma.complex.delete({ where: { id } })
|
||||
|
||||
+14
-15
@@ -1,6 +1,5 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { CreatePosDto, UpdatePosDto } from './dto/pos.dto'
|
||||
import { ComplexPosesService } from './poses.service'
|
||||
|
||||
@ApiTags('AdminComplexPoses')
|
||||
@@ -25,20 +24,20 @@ export class ComplexPosesController {
|
||||
return this.service.findOne(businessActivityId, complexId, id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Param('complexId') complexId: string, @Body() data: CreatePosDto) {
|
||||
return this.service.create(complexId, data)
|
||||
}
|
||||
// @Post()
|
||||
// async create(@Param('complexId') complexId: string, @Body() data: CreatePosDto) {
|
||||
// return this.service.create(complexId, data)
|
||||
// }
|
||||
|
||||
@Patch(':id')
|
||||
async update(
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('complexId') complexId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdatePosDto,
|
||||
) {
|
||||
return this.service.update(businessActivityId, complexId, id, data)
|
||||
}
|
||||
// @Patch(':id')
|
||||
// async update(
|
||||
// @Param('businessActivityId') businessActivityId: string,
|
||||
// @Param('complexId') complexId: string,
|
||||
// @Param('id') id: string,
|
||||
// @Body() data: UpdatePosDto,
|
||||
// ) {
|
||||
// return this.service.update(businessActivityId, complexId, id, data)
|
||||
// }
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param('id') id: string) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { POSStatus } from '@/generated/prisma/enums'
|
||||
import { PosCreateInput, PosSelect } from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreatePosDto, UpdatePosDto } from './dto/pos.dto'
|
||||
import { CreatePosDto } from './dto/pos.dto'
|
||||
|
||||
@Injectable()
|
||||
export class ComplexPosesService {
|
||||
@@ -108,58 +107,58 @@ export class ComplexPosesService {
|
||||
return ResponseMapper.single(account)
|
||||
}
|
||||
|
||||
async create(complex_id: string, data: CreatePosDto) {
|
||||
const account = await this.prisma.pos.create({
|
||||
data: {
|
||||
...this.defaultInsert(data, complex_id),
|
||||
status: POSStatus.ACTIVE,
|
||||
},
|
||||
})
|
||||
return ResponseMapper.create(account)
|
||||
}
|
||||
// async create(complex_id: string, data: CreatePosDto) {
|
||||
// const account = await this.prisma.pos.create({
|
||||
// data: {
|
||||
// ...this.defaultInsert(data, complex_id),
|
||||
// status: POSStatus.ACTIVE,
|
||||
// },
|
||||
// })
|
||||
// return ResponseMapper.create(account)
|
||||
// }
|
||||
|
||||
async update(
|
||||
business_activity_id: string,
|
||||
complex_id: string,
|
||||
id: string,
|
||||
data: UpdatePosDto,
|
||||
) {
|
||||
const { device_id, provider_id, ...rest } = data
|
||||
const account = await this.prisma.pos.update({
|
||||
where: {
|
||||
complex: {
|
||||
id: complex_id,
|
||||
business_activity: {
|
||||
id: business_activity_id,
|
||||
},
|
||||
},
|
||||
id,
|
||||
},
|
||||
data: {
|
||||
complex: {
|
||||
connect: {
|
||||
id: complex_id,
|
||||
},
|
||||
},
|
||||
provider: provider_id
|
||||
? {
|
||||
connect: {
|
||||
id: provider_id,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
device: device_id
|
||||
? {
|
||||
connect: {
|
||||
id: device_id,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
...rest,
|
||||
},
|
||||
})
|
||||
return ResponseMapper.update(account)
|
||||
}
|
||||
// async update(
|
||||
// business_activity_id: string,
|
||||
// complex_id: string,
|
||||
// id: string,
|
||||
// data: UpdatePosDto,
|
||||
// ) {
|
||||
// const { device_id, provider_id, ...rest } = data
|
||||
// const account = await this.prisma.pos.update({
|
||||
// where: {
|
||||
// complex: {
|
||||
// id: complex_id,
|
||||
// business_activity: {
|
||||
// id: business_activity_id,
|
||||
// },
|
||||
// },
|
||||
// id,
|
||||
// },
|
||||
// data: {
|
||||
// complex: {
|
||||
// connect: {
|
||||
// id: complex_id,
|
||||
// },
|
||||
// },
|
||||
// provider: provider_id
|
||||
// ? {
|
||||
// connect: {
|
||||
// id: provider_id,
|
||||
// },
|
||||
// }
|
||||
// : undefined,
|
||||
// device: device_id
|
||||
// ? {
|
||||
// connect: {
|
||||
// id: device_id,
|
||||
// },
|
||||
// }
|
||||
// : undefined,
|
||||
// ...rest,
|
||||
// },
|
||||
// })
|
||||
// return ResponseMapper.update(account)
|
||||
// }
|
||||
|
||||
// async delete(id: string) {
|
||||
// await this.prisma.complex.delete({ where: { id } })
|
||||
|
||||
Reference in New Issue
Block a user