This commit is contained in:
2026-04-22 21:55:40 +03:30
parent 1a3a450960
commit f9e1ad69dc
85 changed files with 15644 additions and 4057 deletions
@@ -1,18 +0,0 @@
import { Body, Controller, Get, Param, Post } from '@nestjs/common'
import { ConfigService } from './config.service'
import { CreateConfigDto } from './dto/create-config.dto'
@Controller('pos/config')
export class ConfigController {
constructor(private readonly configService: ConfigService) {}
@Get(':id')
findOne(@Param('id') uuid: string) {
return this.configService.findOne(uuid)
}
@Post()
create(@Body() data: CreateConfigDto) {
return this.configService.create(data)
}
}
-9
View File
@@ -1,9 +0,0 @@
import { Module } from '@nestjs/common'
import { ConfigController } from './config.controller'
import { ConfigService } from './config.service'
@Module({
controllers: [ConfigController],
providers: [ConfigService],
})
export class PosConfigModule {}
-38
View File
@@ -1,38 +0,0 @@
import { PrismaService } from '@/prisma/prisma.service'
import { Injectable } from '@nestjs/common'
import { Public } from 'common/decorators/public.decorator'
import { ResponseMapper } from 'common/response/response-mapper'
import { CreateConfigDto } from './dto/create-config.dto'
@Injectable()
export class ConfigService {
constructor(private prisma: PrismaService) {}
@Public()
async findOne(uuid: string) {
const config = await this.prisma.userDevices.findUnique({
where: {
uuid,
},
})
return ResponseMapper.single(config)
}
@Public()
async create(data: CreateConfigDto) {
const config = await this.prisma.userDevices.upsert({
where: {
uuid: data.uuid,
},
update: {
...data,
},
create: {
...data,
},
})
return ResponseMapper.create(config)
}
}
@@ -1,56 +0,0 @@
import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsOptional, IsString } from 'class-validator'
export class CreateConfigDto {
@ApiProperty()
@IsString()
app_version: string
@ApiProperty()
@IsString()
build_number: string
@ApiProperty()
@IsString()
uuid: string
@ApiProperty({ required: false })
@IsString()
@IsOptional()
fcm_token?: string
@ApiProperty()
@IsString()
platform: string
@ApiProperty()
@IsString()
brand: string
@ApiProperty()
@IsString()
model: string
@ApiProperty()
@IsString()
device: string
@ApiProperty()
@IsString()
os_version: string
@ApiProperty()
@IsString()
sdk_version: string
@ApiProperty()
@IsString()
release_number: string
@ApiProperty({ required: false })
@IsString()
@IsOptional()
browser_name: string
}
export class UpdateConfigDto extends PartialType(CreateConfigDto) {}
+6
View File
@@ -11,6 +11,7 @@ export class PosController {
@Get()
async getInfo(@PosInfo('pos_id') pos_id: string, @Res({ passthrough: true }) res) {
console.log('getInfo', pos_id)
const result = await this.service.getInfo(pos_id)
if (result) {
@@ -30,4 +31,9 @@ export class PosController {
async getAccessiblePos(@TokenAccount('account_id') account_id) {
return await this.service.getAccessible(account_id)
}
@Get('/me')
async getMe(@TokenAccount('account_id') account_id, @PosInfo('pos_id') pos_id: string) {
return await this.service.getMe(account_id, pos_id)
}
}
-2
View File
@@ -1,6 +1,5 @@
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common'
import { JwtService } from '@nestjs/jwt'
import { PosConfigModule } from './config/config.module'
import { PosCustomersModule } from './customers/customers.module'
import { PosGoodCategoriesModule } from './good-categories/good-categories.module'
import { PosGoodsModule } from './goods/goods.module'
@@ -13,7 +12,6 @@ import { PosSalesInvoicesModule } from './sales-invoices/sales-invoices.module'
controllers: [PosController],
providers: [PosService, JwtService],
imports: [
PosConfigModule,
PosCustomersModule,
PosGoodCategoriesModule,
PosGoodsModule,
+42
View File
@@ -1,3 +1,4 @@
import { ConsumerStatus } from '@/generated/prisma/enums'
import { PrismaService } from '@/prisma/prisma.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
@@ -96,4 +97,45 @@ export class PosService {
return ResponseMapper.list(poses)
}
async getMe(account_id: string, pos_id: string) {
const account = await this.prisma.consumerAccount.findUniqueOrThrow({
where: {
id: account_id,
consumer: {
status: ConsumerStatus.ACTIVE,
business_activities: {
some: {
complexes: {
some: {
pos_list: {
some: {
id: pos_id,
},
},
},
},
},
},
},
},
select: {
id: true,
role: true,
consumer: {
select: {
first_name: true,
last_name: true,
},
},
account: {
select: {
username: true,
},
},
},
})
return ResponseMapper.single(account)
}
}