Some checks failed
Sync dev → Gitea / Mirror dev to Gitea (push) Has been cancelled
- Added a comment line to main.ts for deployment verification purposes
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { Body, Controller, Get, Param, Patch, Post, UseGuards } from "@nestjs/common";
|
|
import { Public } from "../common/decorators/public.decorator";
|
|
import { Roles } from "../common/decorators/roles.decorator";
|
|
import { RolesGuard } from "../common/guards/roles.guard";
|
|
import { PlansService } from "./plans.service";
|
|
|
|
@Controller("plans")
|
|
export class PlansController {
|
|
constructor(private plansService: PlansService) {}
|
|
|
|
@Get()
|
|
@Public()
|
|
async findAll() {
|
|
return this.plansService.findAll();
|
|
}
|
|
|
|
@Post()
|
|
@UseGuards(RolesGuard)
|
|
@Roles("admin")
|
|
async create(
|
|
@Body() body: { name: string; brandCount: number; priceMonthly: number; priceYearly: number },
|
|
) {
|
|
return this.plansService.create(body);
|
|
}
|
|
|
|
@Patch(":id")
|
|
@UseGuards(RolesGuard)
|
|
@Roles("admin")
|
|
async update(
|
|
@Param("id") id: string,
|
|
@Body() body: {
|
|
name?: string;
|
|
brandCount?: number;
|
|
priceMonthly?: number;
|
|
priceYearly?: number;
|
|
isActive?: boolean;
|
|
},
|
|
) {
|
|
return this.plansService.update(id, body);
|
|
}
|
|
}
|