|
|
|
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",
|
|
|
|
properties: {
|
|
|
|
phone: { type: "string" },
|
|
|
|
city: { type: "string" },
|
|
|
|
officeName: { type: "string" },
|
|
|
|
location: {
|
|
|
|
type: "array",
|
|
|
|
items: { type: "string" },
|
|
|
|
},
|
|
|
|
state: { type: "string" },
|
|
|
|
country: { type: "string" },
|
|
|
|
office_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.get("/api/getalldepartmentsParticularFileds", {
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "This is for Get all Department particular fileds Data",
|
|
|
|
summary: "This is for to Get all Department particular fields Data",
|
|
|
|
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
//preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
handler: departmentController.getAllDepartmentsParticularFields,
|
|
|
|
});
|
|
|
|
|
|
|
|
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,
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
method: "POST",
|
|
|
|
url: "/api/desginationSignup",
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "This is for creating a new Desgination Account",
|
|
|
|
summary: "This is for creating a new Desgination 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" },
|
|
|
|
desginationName: { type: "string" },
|
|
|
|
departmentName: { type: "string" },
|
|
|
|
firstName: { type: "string" },
|
|
|
|
lastName: { type: "string" },
|
|
|
|
reportingManager: { type: "string" },
|
|
|
|
email: { type: "string" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
handler: departmentController.addDesgination,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.get("/api/getSingledesginationData/:desginationId", {
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "This is for Get Single desginationId Data",
|
|
|
|
summary: "This is to Get Single desginationId Data",
|
|
|
|
params: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
desginationId: {
|
|
|
|
type: "string",
|
|
|
|
description: "desginationId",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
handler: departmentController.getSinledesginationData,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.get("/api/getalldesginations", {
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "This is for Get all designation Data",
|
|
|
|
summary: "This is for to Get all designation Data",
|
|
|
|
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
//preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
handler: departmentController.getalldesgination,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.delete("/api/deletedesignation/:desginationId", {
|
|
|
|
schema: {
|
|
|
|
description: "Delete a desgination by desginationId",
|
|
|
|
tags: ["Department"],
|
|
|
|
summary: "Delete a user by desginationId",
|
|
|
|
params: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
desginationId: { type: "string" },
|
|
|
|
},
|
|
|
|
required: ["desginationId"],
|
|
|
|
},
|
|
|
|
response: {
|
|
|
|
200: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
success: { type: "boolean" },
|
|
|
|
message: { type: "string" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handler: departmentController.deletedesginationInfo,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.put('/api/editdesgination/:desginationId', {
|
|
|
|
schema: {
|
|
|
|
description: "Edit Desgination details by desginationId",
|
|
|
|
tags: ["Department"],
|
|
|
|
summary: "Edit Desgination details.",
|
|
|
|
params: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
desginationId: { type: "string" },
|
|
|
|
},
|
|
|
|
required: ["desginationId"],
|
|
|
|
},
|
|
|
|
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" },
|
|
|
|
desginationName: { type: "string" },
|
|
|
|
email: { type: "string" },
|
|
|
|
reportingManager: { type: "string" },
|
|
|
|
departmentName: { type: "string" },
|
|
|
|
firstName: { type: "string" },
|
|
|
|
lastName: { type: "string" },
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handler: departmentController.editdesgination,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.get("/api/getalldesignationsParticularFileds", {
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "This is for Get all Designation particular fileds",
|
|
|
|
summary: "This is for to Get all Designation particular fields",
|
|
|
|
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
//preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
handler: departmentController.getAllDesignationsParticularFields,
|
|
|
|
});
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|