chnages in desigination

master
Bhaskar 10 months ago
parent 0f978d027f
commit 1141602d70

@ -35,10 +35,10 @@ exports.addDepartment = async (request, reply) => {
const departmentId = `AWDP${d_id}`;
const {
phone,
//phone,
city,
state,
password,
// password,
country,
zone,
address1,
@ -50,12 +50,12 @@ exports.addDepartment = async (request, reply) => {
} = request.body;
const existingStore = await Department.findOne({ phone });
const existingStore = await Department.findOne({ departmentId });
if (existingStore) {
return reply.status(400).send({ message: 'Phone is already registered' });
}
const hashedPassword = await bcrypt.hash(password, 10);
// const hashedPassword = await bcrypt.hash(password, 10);
const department = new Department({
departmentId: departmentId,
@ -63,7 +63,7 @@ exports.addDepartment = async (request, reply) => {
phone,
address1,
address2,
services: { password: { bcrypt: hashedPassword } },
// services: { password: { bcrypt: hashedPassword } },
state,
zone,
country,
@ -143,7 +143,7 @@ exports.addDepartment = async (request, reply) => {
const { departmentId } = request.params;
const {
phone,
// phone,
city,
state,
country,
@ -161,13 +161,13 @@ exports.addDepartment = async (request, reply) => {
return reply.status(404).send({ message: 'Department not found' });
}
const phoneExists = await Department.findOne({ phone, departmentId: { $ne: departmentId } });
if (phoneExists) {
return reply.status(400).send({ message: 'Phone is already registered to another user' });
}
// const phoneExists = await Department.findOne({ phone, departmentId: { $ne: departmentId } });
// if (phoneExists) {
// return reply.status(400).send({ message: 'Phone is already registered to another user' });
// }
existing.phone = phone || existing.phone;
// existing.phone = phone || existing.phone;
existing.city = city || existing.city;
existing.state = state || existing.state;
existing.country = country || existing.country;
@ -197,6 +197,11 @@ exports.addDepartment = async (request, reply) => {
const {
phone,
city,
firstName,
lastName,
departmentName,
reportingManager,
email,
state,
password,
country,
@ -220,6 +225,11 @@ exports.addDepartment = async (request, reply) => {
const department = new Desgination({
desginationId: desginationId,
city,
firstName,
lastName,
email,
reportingManager,
departmentName,
phone,
address1,
address2,
@ -306,6 +316,11 @@ exports.addDepartment = async (request, reply) => {
phone,
city,
firstName,
lastName,
email,
reportingManager,
departmentName,
state,
country,
zone,
@ -339,7 +354,12 @@ exports.addDepartment = async (request, reply) => {
existing.address1 = address1 || existing.address1;
existing.address2 = address2 || existing.address2;
existing.email = email || existing.email;
existing.firstName = firstName || existing.firstName;
existing.lastName = lastName || existing.lastName;
existing.departmentName = departmentName || existing.departmentName;
existing.reportingManager = reportingManager || existing.reportingManager
await existing.save();

@ -8,7 +8,7 @@ const departmentSchema = new mongoose.Schema(
{
departmentId:{type:String},
departmentName: { type: String },
phone: { type: String, unique: true, trim: true },
//phone: { type: String, unique: true, trim: true },
address1: String,
address2: String,
pincode: { type: String },
@ -16,7 +16,7 @@ const departmentSchema = new mongoose.Schema(
city: { type: String },
state: String,
country: String,
services: { password: { bcrypt: String } },
//services: { password: { bcrypt: String } },
createdAt: {
type: Date,
default: function () {
@ -41,6 +41,11 @@ const departmentSchema = new mongoose.Schema(
desginationId:{type:String},
desginationName: { type: String },
phone: { type: String, unique: true, trim: true },
reportingManager : { type: String },
firstName : { type: String },
lastName: { type: String },
email: { type: String },
departmentName: { type: String },
address1: String,
address2: String,
pincode: { type: String },

@ -14,8 +14,8 @@ module.exports = function (fastify, opts, next) {
type: "object",
//required: ["phone", "username", "password", "role"], // Add role to required fields
properties: {
phone: { type: "string" },
password: { type: "string" },
// phone: { type: "string" },
// password: { type: "string" },
city: { type: "string" },
state: { type: "string" },
country: { type: "string" },
@ -116,7 +116,7 @@ module.exports = function (fastify, opts, next) {
body: {
type: "object",
properties: {
phone: { type: "string" },
// phone: { type: "string" },
city: { type: "string" },
state: { type: "string" },
country: { type: "string" },
@ -154,7 +154,11 @@ module.exports = function (fastify, opts, next) {
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: [
@ -255,6 +259,11 @@ module.exports = function (fastify, opts, next) {
zone: { type: "string" },
pincode: { type: "string" },
desginationName: { type: "string" },
email: { type: "string" },
reportingManager: { type: "string" },
departmentName: { type: "string" },
firstName: { type: "string" },
lastName: { type: "string" },
},
}

Loading…
Cancel
Save