update
This commit is contained in:
@@ -30,3 +30,12 @@ export class UpdatePartnerDto extends PartialType(CreatePartnerDto) {
|
||||
@ApiProperty({ enum: PartnerStatus })
|
||||
status: PartnerStatus
|
||||
}
|
||||
|
||||
export class LicenseChargeDto {
|
||||
@IsNumber()
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
minimum: 0,
|
||||
})
|
||||
count: number
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { CreatePartnerDto, UpdatePartnerDto } from './dto/partner.dto'
|
||||
import { CreatePartnerDto, LicenseChargeDto, UpdatePartnerDto } from './dto/partner.dto'
|
||||
import { PartnersService } from './partners.service'
|
||||
|
||||
@Controller('admin/partners')
|
||||
@@ -26,6 +26,11 @@ export class PartnersController {
|
||||
return this.partnersService.update(id, data)
|
||||
}
|
||||
|
||||
@Post(':id/charge-license')
|
||||
async licenseCharge(@Param('id') id: string, @Body() data: LicenseChargeDto) {
|
||||
return this.partnersService.licenseCharge(id, data)
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') id: string) {
|
||||
return this.partnersService.delete(id)
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreatePartnerDto, UpdatePartnerDto } from './dto/partner.dto'
|
||||
import { CreatePartnerDto, LicenseChargeDto, UpdatePartnerDto } from './dto/partner.dto'
|
||||
|
||||
@Injectable()
|
||||
export class PartnersService {
|
||||
@@ -69,6 +69,18 @@ export class PartnersService {
|
||||
return ResponseMapper.update(partner)
|
||||
}
|
||||
|
||||
async licenseCharge(id: string, data: LicenseChargeDto) {
|
||||
const partner = await this.prisma.partner.update({
|
||||
where: { id },
|
||||
data: {
|
||||
license_quota: {
|
||||
increment: data.count,
|
||||
},
|
||||
},
|
||||
})
|
||||
return ResponseMapper.update(partner)
|
||||
}
|
||||
|
||||
async delete(id: string) {
|
||||
await this.prisma.partner.delete({ where: { id } })
|
||||
return ResponseMapper.delete()
|
||||
|
||||
Reference in New Issue
Block a user