coupon/back/src/wos/wos.controller.ts
2026-05-11 16:35:26 +09:00

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));
}
}