You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
4.0 KiB

const departmentController = require('../controllers/departmentController')
module.exports = function (fastify, opts, next) {
fastify.route({
method: "POST",
url: "/api/departmentSignup",
schema: {
tags: ["Department"],
description: "This is for creating a new Department Account",
summary: "This is for creating a new Department Account",
body: {
type: "object",
//required: ["phone", "username", "password", "role"], // Add role to required fields
properties: {
phone: { type: "string" },
password: { type: "string" },
city: { type: "string" },
state: { type: "string" },
country: { type: "string" },
address1: { type: "string" },
address2: { type: "string" },
zone: { type: "string" },
pincode: { type: "string" },
departmentName: { type: "string" },
},
},
security: [
{
basicAuth: [],
},
],
},
handler: departmentController.addDepartment,
});
fastify.get("/api/getSingledepartmentData/:departmentId", {
schema: {
tags: ["Department"],
description: "This is for Get Single departmentId Data",
summary: "This is to Get Single departmentId Data",
params: {
type: "object",
properties: {
departmentId: {
type: "string",
description: "departmentId",
},
},
},
security: [
{
basicAuth: [],
},
],
},
handler: departmentController.getSinledepartmentData,
});
fastify.get("/api/getalldepartments", {
schema: {
tags: ["Department"],
description: "This is for Get all Department Data",
summary: "This is for to Get all Department Data",
security: [
{
basicAuth: [],
},
],
},
//preHandler: fastify.auth([fastify.authenticate]),
handler: departmentController.getalldepartmants,
});
fastify.delete("/api/deletedepartment/:departmentId", {
schema: {
description: "Delete a Department by departmentId",
tags: ["Department"],
summary: "Delete a user by departmentId",
params: {
type: "object",
properties: {
departmentId: { type: "string" }, // Customer ID
},
required: ["departmentId"],
},
response: {
200: {
type: "object",
properties: {
success: { type: "boolean" },
message: { type: "string" },
}
}
}
},
handler: departmentController.deletedepartmentInfo,
});
fastify.put('/api/editdepartment/:departmentId', {
schema: {
description: "Edit Department details by departmentId",
tags: ["Department"],
summary: "Edit Department details.",
params: {
type: "object",
properties: {
departmentId: { type: "string" },
},
required: ["departmentId"],
},
body: {
type: "object",
properties: {
phone: { type: "string" },
city: { type: "string" },
state: { type: "string" },
country: { type: "string" },
address1: { type: "string" },
address2: { type: "string" },
zone: { type: "string" },
pincode: { type: "string" },
departmentName: { type: "string" },
},
}
},
handler: departmentController.editdepartment,
});
next();
};