Varun 9 months ago
commit 21b6cd5117

@ -33,11 +33,14 @@ const generateDepartmentId = async (prefix) => {
try { try {
const { const {
departmentName, departmentName,
phone,
officeName,
location,
city, city,
state, state,
country, country,
zone, zone,
address1, office_address1,
address2, address2,
pincode, pincode,
createdBy, createdBy,
@ -57,8 +60,11 @@ const generateDepartmentId = async (prefix) => {
// Create new department // Create new department
const department = new Department({ const department = new Department({
departmentId, departmentId,
phone,
officeName,
location,
city, city,
address1, office_address1,
address2, address2,
state, state,
zone, zone,
@ -230,6 +236,7 @@ exports.getAllDepartmentsParticularFields = async (req, reply) => {
address2, address2,
pincode, pincode,
desginationName, desginationName,
location,
createdBy, createdBy,
updatedBy, updatedBy,
} = request.body; } = request.body;
@ -265,6 +272,7 @@ exports.getAllDepartmentsParticularFields = async (req, reply) => {
country, country,
pincode, pincode,
desginationName, desginationName,
location,
createdBy, createdBy,
updatedBy, updatedBy,
}); });

@ -8,15 +8,17 @@ const departmentSchema = new mongoose.Schema(
{ {
departmentId:{type:String}, departmentId:{type:String},
departmentName: { type: String }, departmentName: { type: String },
//phone: { type: String, unique: true, trim: true }, phone: { type: String, unique: true, trim: true },
address1: String, office_address1: String,
officeName: { type: String },
address2: String, address2: String,
pincode: { type: String }, pincode: { type: String },
zone: { type: String }, zone: { type: String },
city: { type: String }, city: { type: String },
location: [{ type : String}],
state: String, state: String,
country: String, country: String,
//services: { password: { bcrypt: String } }, services: { password: { bcrypt: String } },
createdAt: { createdAt: {
type: Date, type: Date,
default: function () { default: function () {
@ -42,6 +44,7 @@ const departmentSchema = new mongoose.Schema(
desginationName: { type: String }, desginationName: { type: String },
phone: { type: String, unique: true, trim: true }, phone: { type: String, unique: true, trim: true },
reportingManager : { type: String }, reportingManager : { type: String },
location: [{ type : String}],
firstName : { type: String }, firstName : { type: String },
lastName: { type: String }, lastName: { type: String },
email: { type: String }, email: { type: String },

@ -2,39 +2,41 @@ const departmentController = require('../controllers/departmentController')
module.exports = function (fastify, opts, next) { module.exports = function (fastify, opts, next) {
fastify.route({ fastify.route({
method: "POST", method: "POST",
url: "/api/departmentSignup", url: "/api/departmentSignup",
schema: { schema: {
tags: ["Department"], tags: ["Department"],
description: "This is for creating a new Department Account", description: "This is for creating a new department account",
summary: "This is for creating a new Department Account", summary: "This is for creating a new department account",
body: { body: {
type: "object", type: "object",
//required: ["phone", "username", "password", "role"], // Add role to required fields properties: {
properties: { phone: { type: "string" },
// phone: { type: "string" }, city: { type: "string" },
// password: { type: "string" }, officeName: { type: "string" },
city: { type: "string" }, location: {
state: { type: "string" }, type: "array",
country: { type: "string" }, items: { type: "string" },
address1: { type: "string" }, },
address2: { type: "string" }, state: { type: "string" },
zone: { type: "string" }, country: { type: "string" },
pincode: { type: "string" }, office_address1: { type: "string" },
departmentName: { type: "string" }, address2: { type: "string" },
zone: { type: "string" },
pincode: { type: "string" },
//departmentName: { type: "string" },
},
}, },
security: [
{
basicAuth: [],
},
],
}, },
security: [ handler: departmentController.addDepartment,
{ });
basicAuth: [],
},
],
},
handler: departmentController.addDepartment,
});
fastify.get("/api/getSingledepartmentData/:departmentId", { fastify.get("/api/getSingledepartmentData/:departmentId", {
schema: { schema: {
@ -176,6 +178,10 @@ module.exports = function (fastify, opts, next) {
lastName: { type: "string" }, lastName: { type: "string" },
reportingManager: { type: "string" }, reportingManager: { type: "string" },
email: { type: "string" }, email: { type: "string" },
location: {
type: "array",
items: { type: "string" },
},
}, },
}, },
security: [ security: [

Loading…
Cancel
Save