배포 완료. 이제: - **FID 탭**: FID 직접 입력 → WOS API 호출 → DB 저장 → 쿠폰 자동 지급 - **닉네임 탭**: 닉네임 입력 시 DB에서 실시간 검색 → 선택하면 자동으로 FID 조회 및 쿠폰 지급
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import { Controller, Post, Get, Delete, Patch, Body, Param, Query, HttpCode } from '@nestjs/common';
|
|
import { WosService } from './wos.service';
|
|
|
|
@Controller('api')
|
|
export class WosController {
|
|
constructor(private readonly wosService: WosService) {}
|
|
|
|
@Post('player')
|
|
@HttpCode(200)
|
|
async getPlayer(@Body() body: { fid: string }) {
|
|
return this.wosService.getPlayer(body.fid);
|
|
}
|
|
|
|
@Post('redeem-all')
|
|
@HttpCode(200)
|
|
async redeemAll(@Body() body: { fid: string }) {
|
|
return this.wosService.redeemAll(body.fid);
|
|
}
|
|
|
|
@Post('redeem')
|
|
@HttpCode(200)
|
|
async redeem(@Body() body: { fid: string }) {
|
|
return this.wosService.redeemAll(body.fid);
|
|
}
|
|
|
|
@Get('users')
|
|
async listUsers() {
|
|
return this.wosService.listUsers();
|
|
}
|
|
|
|
@Get('users/search')
|
|
async searchUsers(@Query('q') q: string) {
|
|
if (!q || q.trim().length === 0) return [];
|
|
return this.wosService.searchUsersByNickname(q.trim());
|
|
}
|
|
|
|
@Get('history/:fid')
|
|
async getHistory(@Param('fid') fid: string) {
|
|
return this.wosService.getHistory(fid);
|
|
}
|
|
|
|
@Get('coupons')
|
|
async listCoupons() {
|
|
return this.wosService.listCoupons();
|
|
}
|
|
|
|
@Post('coupons')
|
|
@HttpCode(200)
|
|
async addCoupon(@Body() body: { name: string; code: string }) {
|
|
return this.wosService.addCoupon(body.name, body.code);
|
|
}
|
|
|
|
@Patch('coupons/:id')
|
|
async toggleCoupon(@Param('id') id: string, @Body() body: { is_active: boolean }) {
|
|
return this.wosService.toggleCoupon(Number(id), body.is_active);
|
|
}
|
|
|
|
@Delete('coupons/:id')
|
|
async deleteCoupon(@Param('id') id: string) {
|
|
return this.wosService.deleteCoupon(Number(id));
|
|
}
|
|
}
|