From 9372eeb3e0ee0dd05de787164e5a32fc40ccd5be Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Fri, 3 Jan 2025 15:17:16 +0530 Subject: [PATCH 1/2] admin city creation --- src/controllers/departmentController.js | 10 +++- src/models/Department.js | 8 ++-- src/routes/departmentRoute.js | 62 +++++++++++++------------ 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/controllers/departmentController.js b/src/controllers/departmentController.js index d753fdf3..c360464a 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, diff --git a/src/models/Department.js b/src/models/Department.js index 96b7ee4b..bbc11383 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 () { diff --git a/src/routes/departmentRoute.js b/src/routes/departmentRoute.js index c4a7fb36..fbca1e0e 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: { From 318dffff18a6d0d1d8f5dd30418b24dcba6754b7 Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Fri, 3 Jan 2025 15:53:20 +0530 Subject: [PATCH 2/2] designation creation --- src/controllers/departmentController.js | 2 ++ src/models/Department.js | 1 + src/routes/departmentRoute.js | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/departmentController.js b/src/controllers/departmentController.js index c360464a..d36e60bd 100644 --- a/src/controllers/departmentController.js +++ b/src/controllers/departmentController.js @@ -236,6 +236,7 @@ exports.getAllDepartmentsParticularFields = async (req, reply) => { address2, pincode, desginationName, + location, createdBy, updatedBy, } = request.body; @@ -271,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 bbc11383..8adfabb2 100644 --- a/src/models/Department.js +++ b/src/models/Department.js @@ -44,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 fbca1e0e..4864c73f 100644 --- a/src/routes/departmentRoute.js +++ b/src/routes/departmentRoute.js @@ -25,7 +25,7 @@ module.exports = function (fastify, opts, next) { address2: { type: "string" }, zone: { type: "string" }, pincode: { type: "string" }, - departmentName: { type: "string" }, + //departmentName: { type: "string" }, }, }, security: [ @@ -178,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: [