29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
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" });
|
|
}
|
|
};
|
|
}
|