diff --git a/src/controllers/departmentController.js b/src/controllers/departmentController.js index d753fdf3..d36e60bd 100644 --- a/src/controllers/departmentController.js +++ b/src/controllers/departmentController.js @@ -33,11 +33,14 @@ const generateDepartmentId = async (prefix) => { try { const { departmentName, + phone, + officeName, + location, city, state, country, zone, - address1, + office_address1, address2, pincode, createdBy, @@ -57,8 +60,11 @@ const generateDepartmentId = async (prefix) => { // Create new department const department = new Department({ departmentId, + phone, + officeName, + location, city, - address1, + office_address1, address2, state, zone, @@ -230,6 +236,7 @@ exports.getAllDepartmentsParticularFields = async (req, reply) => { address2, pincode, desginationName, + location, createdBy, updatedBy, } = request.body; @@ -265,6 +272,7 @@ exports.getAllDepartmentsParticularFields = async (req, reply) => { country, pincode, desginationName, + location, createdBy, updatedBy, }); diff --git a/src/models/Department.js b/src/models/Department.js index 96b7ee4b..8adfabb2 100644 --- a/src/models/Department.js +++ b/src/models/Department.js @@ -8,15 +8,17 @@ const departmentSchema = new mongoose.Schema( { departmentId:{type:String}, departmentName: { type: String }, - //phone: { type: String, unique: true, trim: true }, - address1: String, + phone: { type: String, unique: true, trim: true }, + office_address1: String, + officeName: { type: String }, address2: String, pincode: { type: String }, zone: { type: String }, city: { type: String }, + location: [{ type : String}], state: String, country: String, - //services: { password: { bcrypt: String } }, + services: { password: { bcrypt: String } }, createdAt: { type: Date, default: function () { @@ -42,6 +44,7 @@ const departmentSchema = new mongoose.Schema( desginationName: { type: String }, phone: { type: String, unique: true, trim: true }, reportingManager : { type: String }, + location: [{ type : String}], firstName : { type: String }, lastName: { type: String }, email: { type: String }, diff --git a/src/routes/departmentRoute.js b/src/routes/departmentRoute.js index c4a7fb36..4864c73f 100644 --- a/src/routes/departmentRoute.js +++ b/src/routes/departmentRoute.js @@ -2,39 +2,41 @@ 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" }, - + 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: [], + }, + ], }, - security: [ - { - basicAuth: [], - }, - ], - }, - handler: departmentController.addDepartment, - }); + handler: departmentController.addDepartment, + }); + fastify.get("/api/getSingledepartmentData/:departmentId", { schema: { @@ -176,6 +178,10 @@ module.exports = function (fastify, opts, next) { lastName: { type: "string" }, reportingManager: { type: "string" }, email: { type: "string" }, + location: { + type: "array", + items: { type: "string" }, + }, }, }, security: [