代下单功能
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
import { Body, Controller, Get, Param, Post, Put, Query, UseGuards } from '@nestjs/common';
|
||||
import { HqAuthGuard } from '../../common/guards/hq-auth.guard';
|
||||
import { HqOperation } from '../../common/hq-operation/hq-operation.decorator';
|
||||
import { HqOperationAction } from '../../common/hq-operation/hq-operation.constants';
|
||||
import { PromoCodeService } from './promo-code.service';
|
||||
import {
|
||||
CreatePromoCodeDto,
|
||||
PromoCodeListQueryDto,
|
||||
UpdatePromoCodeDto,
|
||||
UpdatePromoCodeStatusDto,
|
||||
} from './dto/promo-code.dto';
|
||||
|
||||
@Controller('admin/promo-codes')
|
||||
@UseGuards(HqAuthGuard)
|
||||
export class AdminPromoCodeController {
|
||||
constructor(private readonly service: PromoCodeService) {}
|
||||
|
||||
@Get('scenes')
|
||||
listScenes() {
|
||||
return this.service.listScenes();
|
||||
}
|
||||
|
||||
@Get()
|
||||
list(@Query() query: PromoCodeListQueryDto) {
|
||||
return this.service.list(query);
|
||||
}
|
||||
|
||||
@Get(':id/users')
|
||||
listUsers(@Param('id') id: string, @Query('page') page?: string, @Query('pageSize') pageSize?: string) {
|
||||
return this.service.listUsers(
|
||||
BigInt(id),
|
||||
page ? Number(page) : 1,
|
||||
pageSize ? Number(pageSize) : 20,
|
||||
);
|
||||
}
|
||||
|
||||
@Get(':id/stats')
|
||||
stats(@Param('id') id: string) {
|
||||
return this.service.stats(BigInt(id));
|
||||
}
|
||||
|
||||
@Get(':id/qrcode')
|
||||
qrcode(@Param('id') id: string) {
|
||||
return this.service.getQrcodeUrl(BigInt(id));
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
detail(@Param('id') id: string) {
|
||||
return this.service.detail(BigInt(id));
|
||||
}
|
||||
|
||||
@Post()
|
||||
@HqOperation({
|
||||
action: HqOperationAction.PROMO_CODE_CREATE,
|
||||
refType: 'PROMO_CODE',
|
||||
batch: true,
|
||||
includeBody: true,
|
||||
})
|
||||
create(@Body() dto: CreatePromoCodeDto) {
|
||||
return this.service.create(dto);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.PROMO_CODE_UPDATE,
|
||||
refType: 'PROMO_CODE',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
update(@Param('id') id: string, @Body() dto: UpdatePromoCodeDto) {
|
||||
return this.service.update(BigInt(id), dto);
|
||||
}
|
||||
|
||||
@Put(':id/status')
|
||||
@HqOperation({
|
||||
action: HqOperationAction.PROMO_CODE_UPDATE_STATUS,
|
||||
refType: 'PROMO_CODE',
|
||||
refIdParam: 'id',
|
||||
includeBody: true,
|
||||
})
|
||||
updateStatus(@Param('id') id: string, @Body() dto: UpdatePromoCodeStatusDto) {
|
||||
return this.service.updateStatus(BigInt(id), dto.status);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user