|
|
@ -17,7 +17,7 @@ import { |
|
|
|
} from '@nestjs/common'; |
|
|
|
import { REQUEST } from '@nestjs/core'; |
|
|
|
import { AuthGuard } from '@nestjs/passport'; |
|
|
|
import { Account as AccountModel } from '@prisma/client'; |
|
|
|
import { Account as AccountModel, Order } from '@prisma/client'; |
|
|
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes'; |
|
|
|
|
|
|
|
import { AccountService } from './account.service'; |
|
|
@ -47,14 +47,17 @@ export class AccountController { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
const account = await this.accountService.account({ |
|
|
|
id_userId: { |
|
|
|
id, |
|
|
|
userId: this.request.user.id |
|
|
|
} |
|
|
|
}); |
|
|
|
const account = await this.accountService.accountWithOrders( |
|
|
|
{ |
|
|
|
id_userId: { |
|
|
|
id, |
|
|
|
userId: this.request.user.id |
|
|
|
} |
|
|
|
}, |
|
|
|
{ Order: true } |
|
|
|
); |
|
|
|
|
|
|
|
if (account.isDefault) { |
|
|
|
if (account?.isDefault || account?.Order.length > 0) { |
|
|
|
throw new HttpException( |
|
|
|
getReasonPhrase(StatusCodes.FORBIDDEN), |
|
|
|
StatusCodes.FORBIDDEN |
|
|
@ -83,7 +86,7 @@ export class AccountController { |
|
|
|
); |
|
|
|
|
|
|
|
let accounts = await this.accountService.accounts({ |
|
|
|
include: { Platform: true }, |
|
|
|
include: { Order: true, Platform: true }, |
|
|
|
orderBy: { name: 'asc' }, |
|
|
|
where: { userId: impersonationUserId || this.request.user.id } |
|
|
|
}); |
|
|
|