From d2b320f3b1dbdcfb4a69de87a1ed47afb40df420 Mon Sep 17 00:00:00 2001 From: Md Sharafat Hassain Binoy Date: Thu, 30 Apr 2026 21:26:18 +0600 Subject: [PATCH] Change the api and add some new feature --- src/app/modules/order/order.service.ts | 8 + src/app/modules/plan/plan.service.ts | 11 +- .../modules/statictics/statictics.swagger.ts | 138 ++++++++++++++++++ 3 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 src/app/modules/statictics/statictics.swagger.ts diff --git a/src/app/modules/order/order.service.ts b/src/app/modules/order/order.service.ts index 1285906..e554f37 100644 --- a/src/app/modules/order/order.service.ts +++ b/src/app/modules/order/order.service.ts @@ -93,6 +93,14 @@ const get_all_order_from_db = async (req: Request) => { where: { AND: andCondition, }, + select: { + id: true, + customerName: true, + productQuantity: true, + productPrice: true, + status: true, + createdAt: true, + }, orderBy: { [sortBy as string]: sortOrder, }, diff --git a/src/app/modules/plan/plan.service.ts b/src/app/modules/plan/plan.service.ts index 4d351c0..d550a8b 100644 --- a/src/app/modules/plan/plan.service.ts +++ b/src/app/modules/plan/plan.service.ts @@ -5,7 +5,16 @@ import { AppError } from "../../utils/app_error.js"; const get_all_plan_from_db = async (req: Request) => { // define your own login here - const result = await prisma.plan.findMany(); + const result = await prisma.plan.findMany({ + select:{ + planName: true, + price: true, + planType: true, + planDesc: true, + planFeatures: true, + + } + }); return result; }; diff --git a/src/app/modules/statictics/statictics.swagger.ts b/src/app/modules/statictics/statictics.swagger.ts new file mode 100644 index 0000000..16a7ef0 --- /dev/null +++ b/src/app/modules/statictics/statictics.swagger.ts @@ -0,0 +1,138 @@ + +export const staticticsSwaggerDocs = { + "/api/statictics": { + post: { + tags: ["statictics"], + summary: "Create new statictics", + description: "", + requestBody: { + + required: true, + content: { + "application/json": { + example: JSON.stringify({}), // put your request body + }, + }, + }, + responses: { + 201: { description: "statictics created successfully" }, + 500: { description: "Validation error or internal server error" }, + }, + }, + get: { + tags: ["statictics"], + summary: "Get all statictics", + description: "", + parameters: [ + { + name: "page", + in: "query", + required: false, + schema: { type: "number" }, + }, + { + name: "limit", + in: "query", + required: false, + schema: { type: "number" }, + }, + ], + responses: { + 200: { description: "statictics fetched successfully" }, + 401: { description: "unauthorized" }, + }, + }, + }, + "/api/statictics/seller": { + get: { + tags: ["statistics"], + summary: "Get seller statistics", + description: "Fetch seller dashboard stats (7d, 30d, all)", + + parameters: [ + { + name: "range", + in: "query", + required: false, + schema: { + type: "string", + enum: ["7d", "30d", "all"], + default: "7d", + }, + description: "Time range for statistics", + }, + ], + + responses: { + 200: { + description: "Statistics fetched successfully", + }, + 401: { + description: "Unauthorized", + }, + }, + }, + }, + + "/api/statictics/{id}": { + get: { + tags: ["statictics"], + summary: "Get single statictics", + description: "", + parameters: [ + { + name: "id", + in: "path", + required: true, + schema: { type: "string" }, + }, + ], + responses: { + 200: { description: "statictics fetched successfully" }, + 401: { description: "unauthorized" }, + }, + }, + patch: { + tags: ["statictics"], + summary: "Update statictics", + description: "", + parameters: [ + { + name: "id", + in: "path", + required: true, + schema: { type: "string" }, + }, + ], + requestBody: { + required: true, + content: { + "application/json": { + example: JSON.stringify({}), // put your request body + }, + }, + }, + responses: { + 200: { description: "statictics updated successfully" }, + 500: { description: "Validation error or internal server error" }, + }, + }, + delete: { + tags: ["statictics"], + summary: "Delete statictics", + description: "", + parameters: [ + { + name: "id", + in: "path", + required: true, + schema: { type: "string" }, + }, + ], + responses: { + 200: { description: "statictics delete successfully" }, + 401: { description: "unauthorized" }, + }, + }, + }, +};