refactor(accounts): rename account DTOs for clarity and consistency
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { AccountsService } from './accounts.service'
|
||||
import { CreateConsumerAccountDto, UpdateAccountDto } from './dto/account.dto'
|
||||
import type { AccountsServiceCreateResponseDto, AccountsServiceFindAllResponseDto, AccountsServiceFindOneResponseDto, AccountsServiceUpdateResponseDto } from './dto/accounts-response.dto'
|
||||
import {
|
||||
CreateAdminConsumerAccountDto,
|
||||
UpdateAdminConsumerAccountDto,
|
||||
} from './dto/account.dto'
|
||||
import type {
|
||||
AccountsServiceCreateResponseDto,
|
||||
AccountsServiceFindAllResponseDto,
|
||||
AccountsServiceFindOneResponseDto,
|
||||
AccountsServiceUpdateResponseDto,
|
||||
} from './dto/accounts-response.dto'
|
||||
|
||||
@ApiTags('AdminConsumerAccounts')
|
||||
@Controller('admin/consumers/:consumerId/accounts')
|
||||
@@ -10,7 +18,9 @@ export class AccountsController {
|
||||
constructor(private readonly accountsService: AccountsService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@Param('consumerId') consumerId: string): Promise<AccountsServiceFindAllResponseDto> {
|
||||
async findAll(
|
||||
@Param('consumerId') consumerId: string,
|
||||
): Promise<AccountsServiceFindAllResponseDto> {
|
||||
return this.accountsService.findAll(consumerId)
|
||||
}
|
||||
|
||||
@@ -22,13 +32,16 @@ export class AccountsController {
|
||||
@Post()
|
||||
async create(
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Body() data: CreateConsumerAccountDto,
|
||||
@Body() data: CreateAdminConsumerAccountDto,
|
||||
): Promise<AccountsServiceCreateResponseDto> {
|
||||
return this.accountsService.create(consumerId, data)
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
async update(@Param('id') id: string, @Body() data: UpdateAccountDto): Promise<AccountsServiceUpdateResponseDto> {
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdateAdminConsumerAccountDto,
|
||||
): Promise<AccountsServiceUpdateResponseDto> {
|
||||
return this.accountsService.update(id, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,10 @@ import { AccountStatus, AccountType } from '@/generated/prisma/enums'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreateConsumerAccountDto, UpdateAccountDto } from './dto/account.dto'
|
||||
import {
|
||||
CreateAdminConsumerAccountDto,
|
||||
UpdateAdminConsumerAccountDto,
|
||||
} from './dto/account.dto'
|
||||
|
||||
@Injectable()
|
||||
export class AccountsService {
|
||||
@@ -70,7 +73,7 @@ export class AccountsService {
|
||||
return ResponseMapper.single(account)
|
||||
}
|
||||
|
||||
async create(consumerId: string, data: CreateConsumerAccountDto) {
|
||||
async create(consumerId: string, data: CreateAdminConsumerAccountDto) {
|
||||
const account = await this.prisma.consumerAccount.create({
|
||||
data: {
|
||||
role: data.role,
|
||||
@@ -95,7 +98,7 @@ export class AccountsService {
|
||||
return ResponseMapper.create(account)
|
||||
}
|
||||
|
||||
async update(id: string, data: UpdateAccountDto) {
|
||||
async update(id: string, data: UpdateAdminConsumerAccountDto) {
|
||||
const account = await this.prisma.account.update({ where: { id }, data })
|
||||
return ResponseMapper.update(account)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator'
|
||||
import { AccountStatus, ConsumerRole } from 'generated/prisma/enums'
|
||||
|
||||
export class CreateConsumerAccountDto {
|
||||
export class CreateAdminConsumerAccountDto {
|
||||
@IsString()
|
||||
@UsernameFieldValidator()
|
||||
@ApiProperty({ required: true })
|
||||
@@ -19,7 +19,9 @@ export class CreateConsumerAccountDto {
|
||||
role: ConsumerRole
|
||||
}
|
||||
|
||||
export class UpdateAccountDto extends PartialType(CreateConsumerAccountDto) {
|
||||
export class UpdateAdminConsumerAccountDto extends PartialType(
|
||||
CreateAdminConsumerAccountDto,
|
||||
) {
|
||||
@IsOptional()
|
||||
@IsEnum(AccountStatus)
|
||||
@ApiProperty({ enum: AccountStatus })
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { AccountsService } from './accounts.service'
|
||||
import { CreatePartnerAccountDto, UpdateAccountDto } from './dto/account.dto'
|
||||
import type { AccountsServiceCreateResponseDto, AccountsServiceDeleteResponseDto, AccountsServiceFindAllResponseDto, AccountsServiceFindOneResponseDto, AccountsServiceUpdateResponseDto } from './dto/accounts-response.dto'
|
||||
import {
|
||||
CreateAdminPartnerAccountDto,
|
||||
UpdateAdminPartnerAccountDto,
|
||||
} from './dto/account.dto'
|
||||
import type {
|
||||
AccountsServiceCreateResponseDto,
|
||||
AccountsServiceDeleteResponseDto,
|
||||
AccountsServiceFindAllResponseDto,
|
||||
AccountsServiceFindOneResponseDto,
|
||||
AccountsServiceUpdateResponseDto,
|
||||
} from './dto/accounts-response.dto'
|
||||
|
||||
@Controller('admin/partners/:partnerId/accounts')
|
||||
export class AccountsController {
|
||||
constructor(private readonly accountsService: AccountsService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@Param('partnerId') partnerId: string): Promise<AccountsServiceFindAllResponseDto> {
|
||||
async findAll(
|
||||
@Param('partnerId') partnerId: string,
|
||||
): Promise<AccountsServiceFindAllResponseDto> {
|
||||
return this.accountsService.findAll(partnerId)
|
||||
}
|
||||
|
||||
@@ -20,13 +31,16 @@ export class AccountsController {
|
||||
@Post()
|
||||
async create(
|
||||
@Param('partnerId') partnerId: string,
|
||||
@Body() data: CreatePartnerAccountDto,
|
||||
@Body() data: CreateAdminPartnerAccountDto,
|
||||
): Promise<AccountsServiceCreateResponseDto> {
|
||||
return this.accountsService.create(partnerId, data)
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
async update(@Param('id') id: string, @Body() data: UpdateAccountDto): Promise<AccountsServiceUpdateResponseDto> {
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdateAdminPartnerAccountDto,
|
||||
): Promise<AccountsServiceUpdateResponseDto> {
|
||||
return this.accountsService.update(id, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,10 @@ import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { PasswordUtil } from 'common/utils/password.util'
|
||||
import { AccountStatus, AccountType, PartnerRole } from 'generated/prisma/enums'
|
||||
import { CreatePartnerAccountDto, UpdateAccountDto } from './dto/account.dto'
|
||||
import {
|
||||
CreateAdminPartnerAccountDto,
|
||||
UpdateAdminPartnerAccountDto,
|
||||
} from './dto/account.dto'
|
||||
|
||||
@Injectable()
|
||||
export class AccountsService {
|
||||
@@ -38,7 +41,7 @@ export class AccountsService {
|
||||
return ResponseMapper.single(account)
|
||||
}
|
||||
|
||||
async create(partnerId: string, data: CreatePartnerAccountDto) {
|
||||
async create(partnerId: string, data: CreateAdminPartnerAccountDto) {
|
||||
const { username, password } = data
|
||||
|
||||
const result = await this.prisma.$transaction(async tx => {
|
||||
@@ -69,7 +72,7 @@ export class AccountsService {
|
||||
return ResponseMapper.create(result)
|
||||
}
|
||||
|
||||
async update(id: string, data: UpdateAccountDto) {
|
||||
async update(id: string, data: UpdateAdminPartnerAccountDto) {
|
||||
const account = await this.prisma.account.update({ where: { id }, data })
|
||||
return ResponseMapper.update(account)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator'
|
||||
import { PartnerRole } from 'generated/prisma/enums'
|
||||
|
||||
export class CreatePartnerAccountDto {
|
||||
export class CreateAdminPartnerAccountDto {
|
||||
@IsString()
|
||||
@ApiProperty({})
|
||||
@UsernameFieldValidator()
|
||||
@@ -15,7 +15,9 @@ export class CreatePartnerAccountDto {
|
||||
password: string
|
||||
}
|
||||
|
||||
export class UpdateAccountDto extends PartialType(CreatePartnerAccountDto) {
|
||||
export class UpdateAdminPartnerAccountDto extends PartialType(
|
||||
CreateAdminPartnerAccountDto,
|
||||
) {
|
||||
@IsOptional()
|
||||
@IsEnum(PartnerRole)
|
||||
@ApiProperty({ enum: PartnerRole })
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { AccountsService } from './accounts.service'
|
||||
import { CreateAccountDto, UpdateAccountDto } from './dto/account.dto'
|
||||
import type { AccountsServiceCreateResponseDto, AccountsServiceFindAllResponseDto, AccountsServiceFindOneResponseDto, AccountsServiceUpdateResponseDto } from './dto/accounts-response.dto'
|
||||
import { CreateAdminAccountDto, UpdateAdminAccountDto } from './dto/account.dto'
|
||||
import type {
|
||||
AccountsServiceCreateResponseDto,
|
||||
AccountsServiceFindAllResponseDto,
|
||||
AccountsServiceFindOneResponseDto,
|
||||
AccountsServiceUpdateResponseDto,
|
||||
} from './dto/accounts-response.dto'
|
||||
|
||||
@ApiTags('accounts')
|
||||
@Controller('admin/users/:userId/accounts')
|
||||
@@ -10,7 +15,9 @@ export class AccountsController {
|
||||
constructor(private readonly accountsService: AccountsService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@Param('userId') userId: string): Promise<AccountsServiceFindAllResponseDto> {
|
||||
async findAll(
|
||||
@Param('userId') userId: string,
|
||||
): Promise<AccountsServiceFindAllResponseDto> {
|
||||
return this.accountsService.findAll(userId)
|
||||
}
|
||||
|
||||
@@ -20,12 +27,18 @@ export class AccountsController {
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Param('userId') userId: string, @Body() data: CreateAccountDto): Promise<AccountsServiceCreateResponseDto> {
|
||||
async create(
|
||||
@Param('userId') userId: string,
|
||||
@Body() data: CreateAdminAccountDto,
|
||||
): Promise<AccountsServiceCreateResponseDto> {
|
||||
return this.accountsService.create(userId, data)
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
async update(@Param('id') id: string, @Body() data: UpdateAccountDto): Promise<AccountsServiceUpdateResponseDto> {
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdateAdminAccountDto,
|
||||
): Promise<AccountsServiceUpdateResponseDto> {
|
||||
return this.accountsService.update(id, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreateAccountDto, UpdateAccountDto } from './dto/account.dto'
|
||||
import { CreateAdminAccountDto, UpdateAdminAccountDto } from './dto/account.dto'
|
||||
|
||||
@Injectable()
|
||||
export class AccountsService {
|
||||
@@ -23,7 +23,7 @@ export class AccountsService {
|
||||
return ResponseMapper.single({})
|
||||
}
|
||||
|
||||
async create(userId: string, data: CreateAccountDto) {
|
||||
async create(userId: string, data: CreateAdminAccountDto) {
|
||||
// const account = await this.prisma.account.create({
|
||||
// data: {
|
||||
// ...data,
|
||||
@@ -39,7 +39,7 @@ export class AccountsService {
|
||||
return ResponseMapper.create({})
|
||||
}
|
||||
|
||||
async update(id: string, data: UpdateAccountDto) {
|
||||
async update(id: string, data: UpdateAdminAccountDto) {
|
||||
const account = await this.prisma.account.update({ where: { id }, data })
|
||||
return ResponseMapper.update(account)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator'
|
||||
import { AccountStatus, AccountType } from 'generated/prisma/enums'
|
||||
|
||||
export class CreateAccountDto {
|
||||
export class CreateAdminAccountDto {
|
||||
@IsString()
|
||||
@UsernameFieldValidator()
|
||||
@ApiProperty()
|
||||
@@ -19,7 +19,7 @@ export class CreateAccountDto {
|
||||
type: AccountType
|
||||
}
|
||||
|
||||
export class UpdateAccountDto extends PartialType(CreateAccountDto) {
|
||||
export class UpdateAdminAccountDto extends PartialType(CreateAdminAccountDto) {
|
||||
@IsOptional()
|
||||
@IsEnum(AccountStatus)
|
||||
@ApiProperty({ enum: AccountStatus })
|
||||
|
||||
@@ -2,8 +2,12 @@ import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
||||
import { Body, Controller, Get, Param, Patch } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { AccountsService } from './accounts.service'
|
||||
import { UpdateAccountDto } from './dto/account.dto'
|
||||
import type { AccountsServiceFindAllResponseDto, AccountsServiceFindOneResponseDto, AccountsServiceUpdateResponseDto } from './dto/accounts-response.dto'
|
||||
import { UpdateConsumerAccountDto } from './dto/account.dto'
|
||||
import type {
|
||||
AccountsServiceFindAllResponseDto,
|
||||
AccountsServiceFindOneResponseDto,
|
||||
AccountsServiceUpdateResponseDto,
|
||||
} from './dto/accounts-response.dto'
|
||||
|
||||
@ApiTags('ConsumerAccounts')
|
||||
@Controller('consumer/accounts')
|
||||
@@ -11,7 +15,9 @@ export class AccountsController {
|
||||
constructor(private readonly accountsService: AccountsService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@TokenAccount('userId') consumerId: string): Promise<AccountsServiceFindAllResponseDto> {
|
||||
async findAll(
|
||||
@TokenAccount('userId') consumerId: string,
|
||||
): Promise<AccountsServiceFindAllResponseDto> {
|
||||
return this.accountsService.findAll(consumerId)
|
||||
}
|
||||
|
||||
@@ -29,7 +35,10 @@ export class AccountsController {
|
||||
// }
|
||||
|
||||
@Patch(':id')
|
||||
async update(@Param('id') id: string, @Body() data: UpdateAccountDto): Promise<AccountsServiceUpdateResponseDto> {
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdateConsumerAccountDto,
|
||||
): Promise<AccountsServiceUpdateResponseDto> {
|
||||
return this.accountsService.update(id, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ConsumerRole } from '@/generated/prisma/enums'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { UpdateAccountDto } from './dto/account.dto'
|
||||
import { UpdateConsumerAccountDto } from './dto/account.dto'
|
||||
|
||||
@Injectable()
|
||||
export class AccountsService {
|
||||
@@ -91,7 +91,7 @@ export class AccountsService {
|
||||
// return ResponseMapper.create(account)
|
||||
// }
|
||||
|
||||
async update(id: string, data: UpdateAccountDto) {
|
||||
async update(id: string, data: UpdateConsumerAccountDto) {
|
||||
const account = await this.prisma.account.update({ where: { id }, data })
|
||||
return ResponseMapper.update(account)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export class CreateConsumerAccountDto {
|
||||
// role: ConsumerRole
|
||||
}
|
||||
|
||||
export class UpdateAccountDto extends PartialType(CreateConsumerAccountDto) {
|
||||
export class UpdateConsumerAccountDto extends PartialType(CreateConsumerAccountDto) {
|
||||
@IsOptional()
|
||||
@IsEnum(AccountStatus)
|
||||
@ApiProperty({ enum: AccountStatus })
|
||||
|
||||
@@ -2,8 +2,12 @@ import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
||||
import { Body, Controller, Get, Param, Patch } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { AccountsService } from './accounts.service'
|
||||
import { UpdateAccountDto } from './dto/account.dto'
|
||||
import type { AccountsServiceFindAllResponseDto, AccountsServiceFindOneResponseDto, AccountsServiceUpdateResponseDto } from './dto/accounts-response.dto'
|
||||
import { UpdatePartnerAccountDto } from './dto/account.dto'
|
||||
import type {
|
||||
AccountsServiceFindAllResponseDto,
|
||||
AccountsServiceFindOneResponseDto,
|
||||
AccountsServiceUpdateResponseDto,
|
||||
} from './dto/accounts-response.dto'
|
||||
|
||||
@ApiTags('PartnerAccounts')
|
||||
@Controller('partner/accounts')
|
||||
@@ -11,7 +15,9 @@ export class AccountsController {
|
||||
constructor(private readonly service: AccountsService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@TokenAccount('userId') consumerId: string): Promise<AccountsServiceFindAllResponseDto> {
|
||||
async findAll(
|
||||
@TokenAccount('userId') consumerId: string,
|
||||
): Promise<AccountsServiceFindAllResponseDto> {
|
||||
return this.service.findAll(consumerId)
|
||||
}
|
||||
|
||||
@@ -29,7 +35,10 @@ export class AccountsController {
|
||||
// }
|
||||
|
||||
@Patch(':id')
|
||||
async update(@Param('id') id: string, @Body() data: UpdateAccountDto): Promise<AccountsServiceUpdateResponseDto> {
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdatePartnerAccountDto,
|
||||
): Promise<AccountsServiceUpdateResponseDto> {
|
||||
return this.service.update(id, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { AccountStatus, AccountType } from '@/generated/prisma/enums'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { CreatePartnerAccountDto, UpdateAccountDto } from './dto/account.dto'
|
||||
import { CreatePartnerAccountDto, UpdatePartnerAccountDto } from './dto/account.dto'
|
||||
|
||||
@Injectable()
|
||||
export class AccountsService {
|
||||
@@ -73,7 +73,7 @@ export class AccountsService {
|
||||
return ResponseMapper.create(account)
|
||||
}
|
||||
|
||||
async update(id: string, data: UpdateAccountDto) {
|
||||
async update(id: string, data: UpdatePartnerAccountDto) {
|
||||
const account = await this.prisma.account.update({ where: { id }, data })
|
||||
return ResponseMapper.update(account)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export class CreatePartnerAccountDto {
|
||||
role: PartnerRole
|
||||
}
|
||||
|
||||
export class UpdateAccountDto extends PartialType(CreatePartnerAccountDto) {
|
||||
export class UpdatePartnerAccountDto extends PartialType(CreatePartnerAccountDto) {
|
||||
@IsOptional()
|
||||
@IsEnum(AccountStatus)
|
||||
@ApiProperty({ enum: AccountStatus })
|
||||
|
||||
@@ -2,8 +2,12 @@ import { PartnerInfo } from '@/common/decorators/partnerInfo.decorator'
|
||||
import { Body, Controller, Get, Param, Patch } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { AccountsService } from './accounts.service'
|
||||
import { UpdateAccountDto } from './dto/account.dto'
|
||||
import type { AccountsServiceFindAllResponseDto, AccountsServiceFindOneResponseDto, AccountsServiceUpdateResponseDto } from './dto/accounts-response.dto'
|
||||
import { UpdatePartnerConsumerAccountDto } from './dto/account.dto'
|
||||
import type {
|
||||
AccountsServiceFindAllResponseDto,
|
||||
AccountsServiceFindOneResponseDto,
|
||||
AccountsServiceUpdateResponseDto,
|
||||
} from './dto/accounts-response.dto'
|
||||
|
||||
@ApiTags('PartnerConsumerAccounts')
|
||||
@Controller('partner/consumers/:consumerId/accounts')
|
||||
@@ -41,7 +45,7 @@ export class AccountsController {
|
||||
@PartnerInfo('id') partnerId: string,
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('id') id: string,
|
||||
@Body() data: UpdateAccountDto,
|
||||
@Body() data: UpdatePartnerConsumerAccountDto,
|
||||
): Promise<AccountsServiceUpdateResponseDto> {
|
||||
return this.accountsService.update(partnerId, consumerId, id, data)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ConsumerAccountSelect } from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { UpdateAccountDto } from './dto/account.dto'
|
||||
import { UpdatePartnerConsumerAccountDto } from './dto/account.dto'
|
||||
|
||||
@Injectable()
|
||||
export class AccountsService {
|
||||
@@ -126,7 +126,7 @@ export class AccountsService {
|
||||
partner_id: string,
|
||||
consumer_id: string,
|
||||
id: string,
|
||||
data: UpdateAccountDto,
|
||||
data: UpdatePartnerConsumerAccountDto,
|
||||
) {
|
||||
const account = await this.prisma.account.update({
|
||||
where: {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator'
|
||||
import { AccountStatus, ConsumerRole } from 'generated/prisma/enums'
|
||||
|
||||
export class CreateConsumerAccountDto {
|
||||
export class CreatePartnerConsumerAccountDto {
|
||||
@IsString()
|
||||
@UsernameFieldValidator()
|
||||
@ApiProperty({ required: true })
|
||||
@@ -19,7 +19,9 @@ export class CreateConsumerAccountDto {
|
||||
role: ConsumerRole
|
||||
}
|
||||
|
||||
export class UpdateAccountDto extends PartialType(CreateConsumerAccountDto) {
|
||||
export class UpdatePartnerConsumerAccountDto extends PartialType(
|
||||
CreatePartnerConsumerAccountDto,
|
||||
) {
|
||||
@IsOptional()
|
||||
@IsEnum(AccountStatus)
|
||||
@ApiProperty({ enum: AccountStatus })
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { POSStatus, POSType } from '@/generated/prisma/enums'
|
||||
import { CreateConsumerAccountDto } from '@/modules/partners/consumers/accounts/dto/account.dto'
|
||||
import { CreatePartnerConsumerAccountDto } from '@/modules/partners/consumers/accounts/dto/account.dto'
|
||||
import { ApiProperty, OmitType, PartialType } from '@nestjs/swagger'
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator'
|
||||
|
||||
export class CreatePosDto extends OmitType(CreateConsumerAccountDto, ['role']) {
|
||||
export class CreatePosDto extends OmitType(CreatePartnerConsumerAccountDto, ['role']) {
|
||||
@IsString()
|
||||
@ApiProperty({})
|
||||
name: string
|
||||
|
||||
@@ -19,6 +19,10 @@ export class CustomersService {
|
||||
id: true,
|
||||
}
|
||||
|
||||
console.log('type', type)
|
||||
console.log('type === CustomerType.LEGAL', type === CustomerType.LEGAL)
|
||||
console.log('type === CustomerType.INDIVIDUAL', type === CustomerType.INDIVIDUAL)
|
||||
|
||||
if (type === CustomerType.LEGAL) {
|
||||
where.legal = {
|
||||
business_activity_id: posInfo.business_id,
|
||||
@@ -118,9 +122,7 @@ export class CustomersService {
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
type: true,
|
||||
created_at: true,
|
||||
updated_at: true,
|
||||
...select,
|
||||
},
|
||||
})
|
||||
return ResponseMapper.list(customers)
|
||||
|
||||
Reference in New Issue
Block a user