Change the api and add some new feature
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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" },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user