Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 758bb03a26 | |||
| 23ae3556de |
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
FROM node:22-slim AS base
|
FROM node:22-slim AS base
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ARG NPM_REGISTRY=https://registry.npmjs.org/
|
ARG NPM_REGISTRY=https://hub.megan.ir/npm/
|
||||||
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
||||||
ENV npm_config_registry=${NPM_REGISTRY}
|
ENV npm_config_registry=${NPM_REGISTRY}
|
||||||
ENV PNPM_HOME="/pnpm"
|
ENV PNPM_HOME="/pnpm"
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ export class BusinessActivitiesQueryService {
|
|||||||
select: QUERY_CONSTANTS.BUSINESS_ACTIVITIES.select,
|
select: QUERY_CONSTANTS.BUSINESS_ACTIVITIES.select,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('businessActivity', businessActivity)
|
|
||||||
|
|
||||||
return QUERY_CONSTANTS.BUSINESS_ACTIVITIES.mappedData(businessActivity)
|
return QUERY_CONSTANTS.BUSINESS_ACTIVITIES.mappedData(businessActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import {
|
|||||||
import { SharedCreateSalesInvoiceDto } from './sale-invoice-create.dto'
|
import { SharedCreateSalesInvoiceDto } from './sale-invoice-create.dto'
|
||||||
|
|
||||||
interface TerminalPaymentInfo {
|
interface TerminalPaymentInfo {
|
||||||
terminalId: string
|
terminal_id: string
|
||||||
stan: string
|
stan: string
|
||||||
rrn: string
|
rrn: string
|
||||||
transactionDateTime: string | Date
|
transaction_date_time: string | Date
|
||||||
customerCardNO?: string
|
customer_card_no: string
|
||||||
description?: string
|
description?: string
|
||||||
amount?: number
|
amount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NormalizedPayment {
|
interface NormalizedPayment {
|
||||||
@@ -150,6 +150,12 @@ export class SharedSaleInvoiceCreateService {
|
|||||||
const rawPayments = (paymentsData || {}) as Record<string, unknown>
|
const rawPayments = (paymentsData || {}) as Record<string, unknown>
|
||||||
const terminalInfo = rawPayments.terminals as TerminalPaymentInfo | undefined
|
const terminalInfo = rawPayments.terminals as TerminalPaymentInfo | undefined
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
'terminalInfo0',
|
||||||
|
rawPayments.terminals?.[0]?.customer_card_no,
|
||||||
|
terminalInfo,
|
||||||
|
)
|
||||||
|
|
||||||
const payments: NormalizedPayment[] = Object.entries(rawPayments)
|
const payments: NormalizedPayment[] = Object.entries(rawPayments)
|
||||||
.filter(([key, value]) => key !== 'terminals' && value && Number(value) > 0)
|
.filter(([key, value]) => key !== 'terminals' && value && Number(value) > 0)
|
||||||
.map(([key, value]) => ({
|
.map(([key, value]) => ({
|
||||||
@@ -508,11 +514,11 @@ export class SharedSaleInvoiceCreateService {
|
|||||||
await tx.salesInvoicePaymentTerminalInfo.create({
|
await tx.salesInvoicePaymentTerminalInfo.create({
|
||||||
data: {
|
data: {
|
||||||
payment_id: createdPayment.id,
|
payment_id: createdPayment.id,
|
||||||
terminal_id: terminalInfo.terminalId,
|
terminal_id: terminalInfo.terminal_id,
|
||||||
stan: terminalInfo.stan,
|
stan: terminalInfo.stan,
|
||||||
rrn: terminalInfo.rrn,
|
rrn: terminalInfo.rrn,
|
||||||
transaction_date_time: new Date(terminalInfo.transactionDateTime || ''),
|
transaction_date_time: new Date(terminalInfo.transaction_date_time || ''),
|
||||||
customer_card_no: terminalInfo.customerCardNO || null,
|
customer_card_no: terminalInfo.customer_card_no || null,
|
||||||
description: terminalInfo.description || null,
|
description: terminalInfo.description || null,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ export class HttpClientUtil {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
response = await interceptor.onResponse(context, response)
|
response = await interceptor.onResponse(context, response)
|
||||||
console.log('response')
|
|
||||||
console.log(response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default (consumer: any) => {
|
|||||||
delete legal?.partner
|
delete legal?.partner
|
||||||
delete individual?.partner
|
delete individual?.partner
|
||||||
|
|
||||||
return {
|
const returnData = {
|
||||||
...rest,
|
...rest,
|
||||||
partner,
|
partner,
|
||||||
type: translateEnumValue('ConsumerType', type),
|
type: translateEnumValue('ConsumerType', type),
|
||||||
@@ -18,9 +18,13 @@ export default (consumer: any) => {
|
|||||||
? { ...individual, fullname: `${individual?.first_name} ${individual?.last_name}` }
|
? { ...individual, fullname: `${individual?.first_name} ${individual?.last_name}` }
|
||||||
: null,
|
: null,
|
||||||
name: legal ? legal.name : `${individual?.first_name} ${individual?.last_name}`,
|
name: legal ? legal.name : `${individual?.first_name} ${individual?.last_name}`,
|
||||||
business_counts,
|
|
||||||
// license_info: prepareLicenseInfo(activation),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (business_counts !== undefined) {
|
||||||
|
returnData['business_counts'] = business_counts
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnData
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareLicenseInfo(latestLicense: any) {
|
function prepareLicenseInfo(latestLicense: any) {
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ export class AuthService {
|
|||||||
include: accountInclude,
|
include: accountInclude,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('account', account)
|
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
|
throw new NotFoundException('اطلاعات ورودی شما اشتباه است')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import { ConsumerInfo } from '@/common/decorators/consumerInfo.decorator'
|
import { ConsumerInfo } from '@/common/decorators/consumerInfo.decorator'
|
||||||
import { Controller, Get } from '@nestjs/common'
|
import { Body, Controller, Get, Patch, Put } from '@nestjs/common'
|
||||||
import { ApiTags } from '@nestjs/swagger'
|
import { ApiTags } from '@nestjs/swagger'
|
||||||
import { ConsumerService } from './consumer.service'
|
import { ConsumerService } from './consumer.service'
|
||||||
import type { ConsumerServiceGetInfoResponseDto } from './dto/consumer-response.dto'
|
import type {
|
||||||
|
ConsumerServiceGetInfoResponseDto,
|
||||||
|
ConsumerServiceUpdateInfoResponseDto,
|
||||||
|
} from './dto/consumer-response.dto'
|
||||||
|
import { UpdateConsumerInfoDto } from './dto/update-info-request.dto'
|
||||||
|
import { UpdateConsumerPasswordDto } from './dto/update-password-request.dto'
|
||||||
|
|
||||||
@ApiTags('Consumer')
|
@ApiTags('Consumer')
|
||||||
@Controller('consumer')
|
@Controller('consumer')
|
||||||
@@ -10,7 +15,26 @@ export class ConsumerController {
|
|||||||
constructor(private service: ConsumerService) {}
|
constructor(private service: ConsumerService) {}
|
||||||
|
|
||||||
@Get('')
|
@Get('')
|
||||||
async findOne(@ConsumerInfo('id') consumerId: string): Promise<ConsumerServiceGetInfoResponseDto> {
|
async findOne(
|
||||||
|
@ConsumerInfo('id') consumerId: string,
|
||||||
|
): Promise<ConsumerServiceGetInfoResponseDto> {
|
||||||
return this.service.getInfo(consumerId)
|
return this.service.getInfo(consumerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Patch('')
|
||||||
|
async updateInfo(
|
||||||
|
@ConsumerInfo('id') consumerId: string,
|
||||||
|
@Body() data: UpdateConsumerInfoDto,
|
||||||
|
): Promise<ConsumerServiceUpdateInfoResponseDto> {
|
||||||
|
return this.service.updateInfo(consumerId, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put('update-password')
|
||||||
|
async updatePassword(
|
||||||
|
@ConsumerInfo('id') consumerId: string,
|
||||||
|
@ConsumerInfo('account_id') accountId: string,
|
||||||
|
@Body() data: UpdateConsumerPasswordDto,
|
||||||
|
) {
|
||||||
|
return this.service.updatePassword(consumerId, accountId, data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import { QUERY_CONSTANTS } from '@/common/queryConstants'
|
import { QUERY_CONSTANTS } from '@/common/queryConstants'
|
||||||
import { ResponseMapper } from '@/common/response/response-mapper'
|
import { ResponseMapper } from '@/common/response/response-mapper'
|
||||||
|
import { PasswordUtil } from '@/common/utils'
|
||||||
|
import { ConsumerUpdateInput } from '@/generated/prisma/models'
|
||||||
import { PrismaService } from '@/prisma/prisma.service'
|
import { PrismaService } from '@/prisma/prisma.service'
|
||||||
import { Injectable } from '@nestjs/common'
|
import { Injectable } from '@nestjs/common'
|
||||||
import consumer_mappersUtil from '../../common/utils/mappers/consumer_mappers.util'
|
import consumer_mappersUtil from '../../common/utils/mappers/consumer_mappers.util'
|
||||||
|
import { UpdateConsumerInfoDto } from './dto/update-info-request.dto'
|
||||||
|
import { UpdateConsumerPasswordDto } from './dto/update-password-request.dto'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConsumerService {
|
export class ConsumerService {
|
||||||
@@ -22,4 +26,71 @@ export class ConsumerService {
|
|||||||
|
|
||||||
return ResponseMapper.single(consumer_mappersUtil(consumer))
|
return ResponseMapper.single(consumer_mappersUtil(consumer))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateInfo(consumer_id: string, data: UpdateConsumerInfoDto) {
|
||||||
|
const consumerExists = await this.prisma.consumer.findUnique({
|
||||||
|
where: {
|
||||||
|
id: consumer_id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
type: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
let dataForUpdate: ConsumerUpdateInput = {}
|
||||||
|
|
||||||
|
if (consumerExists?.type === 'LEGAL') {
|
||||||
|
dataForUpdate = {
|
||||||
|
legal: {
|
||||||
|
update: {
|
||||||
|
name: data.company_name,
|
||||||
|
registration_code: data.registration_code,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else if (consumerExists?.type === 'INDIVIDUAL') {
|
||||||
|
dataForUpdate = {
|
||||||
|
individual: {
|
||||||
|
update: {
|
||||||
|
first_name: data.first_name,
|
||||||
|
last_name: data.last_name,
|
||||||
|
mobile_number: data.mobile_number,
|
||||||
|
national_code: data.national_code,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const consumer = await this.prisma.consumer.update({
|
||||||
|
where: {
|
||||||
|
id: consumer_id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
...dataForUpdate,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return ResponseMapper.update(consumer)
|
||||||
|
}
|
||||||
|
|
||||||
|
async updatePassword(
|
||||||
|
consumer_id: string,
|
||||||
|
accountId: string,
|
||||||
|
data: UpdateConsumerPasswordDto,
|
||||||
|
) {
|
||||||
|
const consumer = await this.prisma.consumerAccount.update({
|
||||||
|
where: {
|
||||||
|
id: accountId,
|
||||||
|
consumer_id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
account: {
|
||||||
|
update: {
|
||||||
|
password: await PasswordUtil.hash(data.password),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return ResponseMapper.update(consumer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
import type { ConsumerService } from '../consumer.service'
|
import type { ConsumerService } from '../consumer.service'
|
||||||
|
|
||||||
export type ConsumerServiceGetInfoResponseDto = Awaited<ReturnType<ConsumerService['getInfo']>>
|
export type ConsumerServiceGetInfoResponseDto = Awaited<
|
||||||
|
ReturnType<ConsumerService['getInfo']>
|
||||||
|
>
|
||||||
|
export type ConsumerServiceUpdateInfoResponseDto = Awaited<
|
||||||
|
ReturnType<ConsumerService['updateInfo']>
|
||||||
|
>
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger'
|
||||||
|
import { IsString } from 'class-validator'
|
||||||
|
|
||||||
|
export class UpdateConsumerInfoDto {
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty()
|
||||||
|
first_name: string
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty()
|
||||||
|
last_name: string
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty()
|
||||||
|
mobile_number: string
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty()
|
||||||
|
national_code: string
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty()
|
||||||
|
company_name: string
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty()
|
||||||
|
registration_code: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger'
|
||||||
|
import { IsString } from 'class-validator'
|
||||||
|
|
||||||
|
export class UpdateConsumerPasswordDto {
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
password: string
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
||||||
import { Controller, Get } from '@nestjs/common'
|
import { Controller, Get } from '@nestjs/common'
|
||||||
import { ApiTags } from '@nestjs/swagger'
|
import { ApiTags } from '@nestjs/swagger'
|
||||||
import { StatisticsService } from './statistics.service'
|
|
||||||
import type { StatisticsServiceGetInvoicesResponseDto } from './dto/statistics-response.dto'
|
import type { StatisticsServiceGetInvoicesResponseDto } from './dto/statistics-response.dto'
|
||||||
|
import { StatisticsService } from './statistics.service'
|
||||||
|
|
||||||
@ApiTags('ConsumerStatistics')
|
@ApiTags('ConsumerStatistics')
|
||||||
@Controller('consumer/statistics')
|
@Controller('consumer/statistics')
|
||||||
@@ -10,7 +10,9 @@ export class StatisticsController {
|
|||||||
constructor(private readonly service: StatisticsService) {}
|
constructor(private readonly service: StatisticsService) {}
|
||||||
|
|
||||||
@Get('invoices')
|
@Get('invoices')
|
||||||
async getInvoices(@TokenAccount('userId') consumerId: string): Promise<StatisticsServiceGetInvoicesResponseDto> {
|
async getInvoices(
|
||||||
|
@TokenAccount('userId') consumerId: string,
|
||||||
|
): Promise<StatisticsServiceGetInvoicesResponseDto> {
|
||||||
return this.service.getInvoices(consumerId)
|
return this.service.getInvoices(consumerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger'
|
||||||
|
import { IsString } from 'class-validator'
|
||||||
|
|
||||||
|
export class UpdatePartnerPasswordDto {
|
||||||
|
@IsString()
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
password: string
|
||||||
|
}
|
||||||
@@ -1,16 +1,24 @@
|
|||||||
import { PartnerInfo } from '@/common/decorators/partnerInfo.decorator'
|
import { PartnerInfo } from '@/common/decorators/partnerInfo.decorator'
|
||||||
|
import type { IPartnerPayload } from '@/common/models/partnerPayload.model'
|
||||||
import { multerImageOptions } from '@/multer.config'
|
import { multerImageOptions } from '@/multer.config'
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
Patch,
|
Patch,
|
||||||
|
Put,
|
||||||
UploadedFile,
|
UploadedFile,
|
||||||
UseInterceptors,
|
UseInterceptors,
|
||||||
} from '@nestjs/common'
|
} from '@nestjs/common'
|
||||||
import { FileInterceptor } from '@nestjs/platform-express'
|
import { FileInterceptor } from '@nestjs/platform-express'
|
||||||
import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger'
|
import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger'
|
||||||
import { UpdatePartnerProfileDto } from './dto/partner.dto'
|
import { UpdatePartnerProfileDto } from './dto/partner.dto'
|
||||||
|
import {
|
||||||
|
PartnerServiceGetInfoResponseDto,
|
||||||
|
PartnerServiceMeResponseDto,
|
||||||
|
PartnerServiceUpdateInfoResponseDto,
|
||||||
|
} from './dto/partners-response.dto'
|
||||||
|
import { UpdatePartnerPasswordDto } from './dto/update-password-request.dto'
|
||||||
import { PartnerService } from './partners.service'
|
import { PartnerService } from './partners.service'
|
||||||
|
|
||||||
@ApiTags('Partner')
|
@ApiTags('Partner')
|
||||||
@@ -19,16 +27,20 @@ export class PartnerController {
|
|||||||
constructor(private service: PartnerService) {}
|
constructor(private service: PartnerService) {}
|
||||||
|
|
||||||
@Get('')
|
@Get('')
|
||||||
async me(@PartnerInfo() { id, account_id }: IPartnerPayload): Promise<PartnerServiceMeResponseDto> {
|
async me(
|
||||||
|
@PartnerInfo() { id, account_id }: IPartnerPayload,
|
||||||
|
): Promise<PartnerServiceMeResponseDto> {
|
||||||
return this.service.me(id, account_id)
|
return this.service.me(id, account_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('info')
|
@Get('info')
|
||||||
async getInfo(@PartnerInfo('id') partnerId: string): Promise<PartnerServiceGetInfoResponseDto> {
|
async getInfo(
|
||||||
|
@PartnerInfo('id') partnerId: string,
|
||||||
|
): Promise<PartnerServiceGetInfoResponseDto> {
|
||||||
return this.service.getInfo(partnerId)
|
return this.service.getInfo(partnerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch('profile')
|
@Patch('')
|
||||||
@UseInterceptors(FileInterceptor('logo', multerImageOptions))
|
@UseInterceptors(FileInterceptor('logo', multerImageOptions))
|
||||||
@ApiConsumes('multipart/form-data')
|
@ApiConsumes('multipart/form-data')
|
||||||
@ApiBody({
|
@ApiBody({
|
||||||
@@ -46,7 +58,13 @@ export class PartnerController {
|
|||||||
): Promise<PartnerServiceUpdateInfoResponseDto> {
|
): Promise<PartnerServiceUpdateInfoResponseDto> {
|
||||||
return this.service.updateInfo(partnerId, data, logo)
|
return this.service.updateInfo(partnerId, data, logo)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
import type { IPartnerPayload } from '@/common/models/partnerPayload.model'
|
@Put('update-password')
|
||||||
import type { PartnerServiceGetInfoResponseDto, PartnerServiceMeResponseDto, PartnerServiceUpdateInfoResponseDto } from './dto/partners-response.dto'
|
async updatePassword(
|
||||||
|
@PartnerInfo('id') partnerId: string,
|
||||||
|
@PartnerInfo('account_id') accountId: string,
|
||||||
|
@Body() data: UpdatePartnerPasswordDto,
|
||||||
|
) {
|
||||||
|
return this.service.updatePassword(partnerId, accountId, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { UploadedFileTypes } from '@/common/enums/enums'
|
import { UploadedFileTypes } from '@/common/enums/enums'
|
||||||
import { ResponseMapper } from '@/common/response/response-mapper'
|
import { ResponseMapper } from '@/common/response/response-mapper'
|
||||||
import { PartnerAccountSelect } from '@/generated/prisma/models'
|
import { PasswordUtil } from '@/common/utils'
|
||||||
import { UploaderService } from '@/modules/uploader/uploader.service'
|
import { UploaderService } from '@/modules/uploader/uploader.service'
|
||||||
import { PrismaService } from '@/prisma/prisma.service'
|
import { PrismaService } from '@/prisma/prisma.service'
|
||||||
import { Injectable } from '@nestjs/common'
|
import { Injectable } from '@nestjs/common'
|
||||||
import { UpdatePartnerProfileDto } from './dto/partner.dto'
|
import { UpdatePartnerProfileDto } from './dto/partner.dto'
|
||||||
|
import { UpdatePartnerPasswordDto } from './dto/update-password-request.dto'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PartnerService {
|
export class PartnerService {
|
||||||
@@ -13,10 +14,8 @@ export class PartnerService {
|
|||||||
private readonly uploaderService: UploaderService,
|
private readonly uploaderService: UploaderService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private readonly defaultSelect: PartnerAccountSelect = {}
|
|
||||||
|
|
||||||
async me(partner_id: string, account_id: string) {
|
async me(partner_id: string, account_id: string) {
|
||||||
const partner = await this.prisma.partnerAccount.findUniqueOrThrow({
|
const partnerAccount = await this.prisma.partnerAccount.findUniqueOrThrow({
|
||||||
where: {
|
where: {
|
||||||
id: account_id,
|
id: account_id,
|
||||||
partner_id,
|
partner_id,
|
||||||
@@ -33,12 +32,21 @@ export class PartnerService {
|
|||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
|
code: true,
|
||||||
|
logo_url: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return ResponseMapper.single(partner)
|
return ResponseMapper.single({
|
||||||
|
...partnerAccount.partner,
|
||||||
|
account: {
|
||||||
|
role: partnerAccount.role,
|
||||||
|
id: partnerAccount.id,
|
||||||
|
username: partnerAccount.account.username,
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async getInfo(partner_id: string) {
|
async getInfo(partner_id: string) {
|
||||||
@@ -234,10 +242,31 @@ export class PartnerService {
|
|||||||
...rest,
|
...rest,
|
||||||
...(logo_url ? { logo_url } : {}),
|
...(logo_url ? { logo_url } : {}),
|
||||||
},
|
},
|
||||||
select: this.defaultSelect,
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return ResponseMapper.single(updatedPartner)
|
return ResponseMapper.single(updatedPartner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updatePassword(
|
||||||
|
partner_id: string,
|
||||||
|
accountId: string,
|
||||||
|
data: UpdatePartnerPasswordDto,
|
||||||
|
) {
|
||||||
|
const partnerAccount = await this.prisma.partnerAccount.update({
|
||||||
|
where: {
|
||||||
|
id: accountId,
|
||||||
|
partner_id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
account: {
|
||||||
|
update: {
|
||||||
|
password: await PasswordUtil.hash(data.password),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return ResponseMapper.update(partnerAccount)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user