2026-03-29 18:06:41 +03:30
|
|
|
import { PosInfo } from '@/common/decorators/posInfo.decorator'
|
2026-04-11 14:47:05 +03:30
|
|
|
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
2026-05-24 10:44:47 +03:30
|
|
|
import { Body, Controller, Get, Put, Res } from '@nestjs/common'
|
2026-03-29 18:06:41 +03:30
|
|
|
import { ApiTags } from '@nestjs/swagger'
|
2026-04-27 10:45:39 +03:30
|
|
|
import type {
|
|
|
|
|
PosServiceGetAccessibleResponseDto,
|
|
|
|
|
PosServiceGetInfoResponseDto,
|
|
|
|
|
PosServiceGetMeResponseDto,
|
|
|
|
|
} from './dto/pos-response.dto'
|
2026-05-24 10:44:47 +03:30
|
|
|
import { UpdatePosAccountPasswordDto } from './dto/update-password-request.dto'
|
2026-03-29 18:06:41 +03:30
|
|
|
import { PosService } from './pos.service'
|
|
|
|
|
|
|
|
|
|
@ApiTags('Pos')
|
|
|
|
|
@Controller('pos')
|
|
|
|
|
export class PosController {
|
|
|
|
|
constructor(private service: PosService) {}
|
|
|
|
|
|
|
|
|
|
@Get()
|
2026-04-27 10:45:39 +03:30
|
|
|
async getInfo(
|
|
|
|
|
@PosInfo('pos_id') pos_id: string,
|
|
|
|
|
@Res({ passthrough: true }) res,
|
|
|
|
|
): Promise<PosServiceGetInfoResponseDto> {
|
2026-04-11 14:47:05 +03:30
|
|
|
const result = await this.service.getInfo(pos_id)
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
res.cookie('posId', pos_id, {
|
2026-04-13 13:21:50 +03:30
|
|
|
httpOnly: false,
|
2026-04-11 14:47:05 +03:30
|
|
|
secure: process.env.NODE_ENV === 'production',
|
|
|
|
|
sameSite: 'lax',
|
|
|
|
|
maxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('/accessible')
|
2026-04-27 10:45:39 +03:30
|
|
|
async getAccessiblePos(
|
|
|
|
|
@TokenAccount('account_id') account_id,
|
|
|
|
|
): Promise<PosServiceGetAccessibleResponseDto> {
|
2026-04-11 14:47:05 +03:30
|
|
|
return await this.service.getAccessible(account_id)
|
2026-03-29 18:06:41 +03:30
|
|
|
}
|
2026-04-22 21:55:40 +03:30
|
|
|
|
|
|
|
|
@Get('/me')
|
2026-04-27 10:45:39 +03:30
|
|
|
async getMe(
|
|
|
|
|
@TokenAccount('account_id') account_id,
|
|
|
|
|
@PosInfo('pos_id') pos_id: string,
|
|
|
|
|
): Promise<PosServiceGetMeResponseDto> {
|
2026-04-22 21:55:40 +03:30
|
|
|
return await this.service.getMe(account_id, pos_id)
|
|
|
|
|
}
|
2026-05-24 10:44:47 +03:30
|
|
|
|
|
|
|
|
@Put('update-password')
|
|
|
|
|
async updatePassword(
|
|
|
|
|
@TokenAccount('userId') consumerId: string,
|
|
|
|
|
@TokenAccount('account_id') accountId: string,
|
|
|
|
|
@Body() data: UpdatePosAccountPasswordDto,
|
|
|
|
|
) {
|
|
|
|
|
return this.service.updatePassword(consumerId, accountId, data)
|
|
|
|
|
}
|
2026-03-29 18:06:41 +03:30
|
|
|
}
|