37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { Body, Controller, Get, Param, Post, Put, Query, UseGuards } from '@nestjs/common';
|
|
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
|
import { AdminPromoCodesService } from './admin-promo-codes.service';
|
|
import { AdminPromoCodesQueryDto } from './dto/admin-query.dto';
|
|
import { CreatePromoCodeDto, UpdatePromoCodeStatusDto } from './dto/admin-mutate.dto';
|
|
|
|
@Controller('admin/promo-codes')
|
|
@UseGuards(HqAuthGuard)
|
|
export class AdminPromoCodesController {
|
|
constructor(private readonly service: AdminPromoCodesService) {}
|
|
|
|
@Get()
|
|
list(@Query() query: AdminPromoCodesQueryDto) {
|
|
return this.service.list(query);
|
|
}
|
|
|
|
@Get(':id/stats')
|
|
stats(@Param('id') id: string) {
|
|
return this.service.stats(BigInt(id));
|
|
}
|
|
|
|
@Get(':id')
|
|
detail(@Param('id') id: string) {
|
|
return this.service.detail(BigInt(id));
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() dto: CreatePromoCodeDto) {
|
|
return this.service.create(dto);
|
|
}
|
|
|
|
@Put(':id/status')
|
|
updateStatus(@Param('id') id: string, @Body() dto: UpdatePromoCodeStatusDto) {
|
|
return this.service.updateStatus(BigInt(id), dto.status);
|
|
}
|
|
}
|