|
|
|
const departmentController = require('../controllers/departmentController')
|
|
|
|
|
|
|
|
module.exports = function (fastify, opts, next) {
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
method: "POST",
|
|
|
|
url: "/api/citySignup",
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "This is for creating a new City account",
|
|
|
|
summary: "This is for creating a new City 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.addCity,
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 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/getallcities", {
|
|
|
|
// schema: {
|
|
|
|
// tags: ["Department"],
|
|
|
|
// description: "This is for Get all cities Data",
|
|
|
|
// summary: "This is for to Get all cities Data",
|
|
|
|
|
|
|
|
// security: [
|
|
|
|
// {
|
|
|
|
// basicAuth: [],
|
|
|
|
// },
|
|
|
|
// ],
|
|
|
|
// },
|
|
|
|
// //preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
// handler: departmentController.getallcities,
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// 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/deletecity/:cityId", {
|
|
|
|
schema: {
|
|
|
|
description: "Delete a city by cityId",
|
|
|
|
tags: ["Department"],
|
|
|
|
summary: "Delete a user by city",
|
|
|
|
params: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
cityId: { type: "string" },
|
|
|
|
},
|
|
|
|
required: ["cityId"],
|
|
|
|
},
|
|
|
|
response: {
|
|
|
|
200: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
success: { type: "boolean" },
|
|
|
|
message: { type: "string" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handler: departmentController.deletecityInfo,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.put('/api/editcity/:cityId', {
|
|
|
|
schema: {
|
|
|
|
description: "Edit City details by cityId",
|
|
|
|
tags: ["Department"],
|
|
|
|
summary: "Edit City details.",
|
|
|
|
params: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
cityId: { type: "string" },
|
|
|
|
},
|
|
|
|
required: ["cityId"],
|
|
|
|
},
|
|
|
|
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.editcity,
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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" },
|
|
|
|
alternativeContactNumber: { type: "string" },
|
|
|
|
personalEmail: { type: "string" },
|
|
|
|
gender: { 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" },
|
|
|
|
location: {
|
|
|
|
type: "array",
|
|
|
|
items: { 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 departments Data",
|
|
|
|
summary: "This is for to Get all departments Data",
|
|
|
|
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
//preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
handler: departmentController.getalldepartments,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.get("/api/getallcitiesdata", {
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "This is for Get all Cities Data",
|
|
|
|
summary: "This is for to Get all Cities Data",
|
|
|
|
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
//preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
handler: departmentController.getallCitiesData,
|
|
|
|
});
|
|
|
|
fastify.get("/api/getallzonesdata", {
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "This is for Get all Zones Data",
|
|
|
|
summary: "This is for to Get all Zones Data",
|
|
|
|
|
|
|
|
security: [
|
|
|
|
{
|
|
|
|
basicAuth: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
//preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
handler: departmentController.getallZonesData,
|
|
|
|
});
|
|
|
|
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" },
|
|
|
|
},
|
|
|
|
required: ["departmentId"],
|
|
|
|
},
|
|
|
|
response: {
|
|
|
|
200: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
success: { type: "boolean" },
|
|
|
|
message: { type: "string" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handler: departmentController.deletedepartmentInfo,
|
|
|
|
});
|
|
|
|
|
|
|
|
fastify.put('/api/editdesgination/: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" },
|
|
|
|
alternativeContactNumber: { type: "string" },
|
|
|
|
personalEmail: { type: "string" },
|
|
|
|
gender: { 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.editdepartment,
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
// });
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
method: "GET",
|
|
|
|
url: "/api/locations",
|
|
|
|
schema: {
|
|
|
|
tags: ["Department"],
|
|
|
|
description: "Fetch locations by city and zone",
|
|
|
|
summary: "Fetch locations by city and zone",
|
|
|
|
querystring: {
|
|
|
|
type: "object",
|
|
|
|
required: ["city", "zone"],
|
|
|
|
properties: {
|
|
|
|
city: { type: "string" },
|
|
|
|
zone: { type: "string" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handler:departmentController.getZonebasedLocations
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|