34 lines
955 B
TypeScript
34 lines
955 B
TypeScript
import { PosInfo } from '@/common/decorators/posInfo.decorator'
|
|
import { TokenAccount } from '@/common/decorators/tokenInfo.decorator'
|
|
import { Controller, Get, Res } from '@nestjs/common'
|
|
import { ApiTags } from '@nestjs/swagger'
|
|
import { PosService } from './pos.service'
|
|
|
|
@ApiTags('Pos')
|
|
@Controller('pos')
|
|
export class PosController {
|
|
constructor(private service: PosService) {}
|
|
|
|
@Get()
|
|
async getInfo(@PosInfo('pos_id') pos_id: string, @Res({ passthrough: true }) res) {
|
|
const result = await this.service.getInfo(pos_id)
|
|
|
|
if (result) {
|
|
// @ts-ignore
|
|
res.cookie('posId', pos_id, {
|
|
httpOnly: true,
|
|
secure: process.env.NODE_ENV === 'production',
|
|
sameSite: 'lax',
|
|
maxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
|
|
})
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
@Get('/accessible')
|
|
async getAccessiblePos(@TokenAccount('account_id') account_id) {
|
|
return await this.service.getAccessible(account_id)
|
|
}
|
|
}
|