feat: implement sysadmin subscription management and plan usage cycle recalculation tools
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { Request, Response } from "express";
|
||||
import { PlansService } from "../services/plans.service";
|
||||
import { SysAdminUpdatePlanParams } from "../models/Plans.Model";
|
||||
|
||||
const plansService = new PlansService();
|
||||
|
||||
export class PlansController {
|
||||
public listPlans = async (_req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const plans = await plansService.listPlans();
|
||||
res.json(plans);
|
||||
} catch (error: any) {
|
||||
console.error("Error listing plans:", error?.response?.data || error);
|
||||
res.status(500).json(error?.response?.data || { success: false, message: "Internal Server Error" });
|
||||
}
|
||||
};
|
||||
|
||||
public updatePlan = async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const data: SysAdminUpdatePlanParams = req.body;
|
||||
const result = await plansService.updatePlan(data);
|
||||
res.json(result);
|
||||
} catch (error: any) {
|
||||
console.error("Error updating plan:", error?.response?.data || error);
|
||||
res.status(500).json(error?.response?.data || { success: false, message: "Internal Server Error" });
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user