Refactor Partner and POS models to replace 'serial' with 'serial_number' and update related services and DTOs
- Updated PartnerAccountQuotaAllocation model to change license relation. - Refactored Pos model to replace 'serial' with 'serial_number' across all references. - Modified BusinessActivitiesService to include license activation details in responses. - Adjusted ComplexPosesService to reflect changes in the Pos model. - Updated PartnerService to include a new method for updating partner profiles. - Created UpdatePartnerProfileDto for partner profile updates. - Added migration to drop 'serial' column and add unique 'serial_number' column in poses table.
This commit is contained in:
@@ -1,36 +1,52 @@
|
||||
import { ResponseMapper } from '@/common/response/response-mapper'
|
||||
import { PartnerSelect } from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { UpdatePartnerProfileDto } from './dto/partner.dto'
|
||||
|
||||
@Injectable()
|
||||
export class PartnerService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
private readonly defaultSelect: PartnerSelect = {
|
||||
id: true,
|
||||
name: true,
|
||||
status: true,
|
||||
account_quota_charge_transactions: {
|
||||
select: {
|
||||
_count: {
|
||||
select: {
|
||||
allocations: {
|
||||
where: {
|
||||
license_id: undefined,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
async getInfo(partner_id: string) {
|
||||
const partner = await this.prisma.partner.findUniqueOrThrow({
|
||||
where: {
|
||||
id: partner_id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
status: true,
|
||||
account_quota_charge_transactions: {
|
||||
select: {
|
||||
_count: {
|
||||
select: {
|
||||
allocations: {
|
||||
where: {
|
||||
license_id: undefined,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
|
||||
return ResponseMapper.single(partner)
|
||||
}
|
||||
|
||||
async updateInfo(partner_id: string, data: UpdatePartnerProfileDto) {
|
||||
const updatedPartner = await this.prisma.partner.update({
|
||||
where: {
|
||||
id: partner_id,
|
||||
},
|
||||
data,
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
|
||||
return ResponseMapper.single(updatedPartner)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user