1ST PHASE GIVING MACID AND MASTERID TO WATERLEVEL SENSOR

master
varun 1 year ago
parent 24da5964b3
commit cec367205d

@ -10,7 +10,9 @@ const fastify = require("fastify")({
return uuidv4(); return uuidv4();
}, },
}); });
const { Install, ProfilePictureInstall, generateinstallationId,Store} = require("../models/store"); const { Install, ProfilePictureInstall, generateinstallationId,Store,WaterLeverSensor} = require("../models/store");
const { User,Counter, generateBookingId,resetCounter,generateCustomerId,ProfilePicture} = require('../models/User')
@ -403,99 +405,35 @@ exports.installSignUp = async (request, reply) => {
} }
}; };
const generatewaterlevelsensorId = async () => {
const result = await Counter.findOneAndUpdate(
{ _id: 'waterlevelsensor_id' },
{ $inc: { seq: 1 } },
{ upsert: true, new: true }
);
return result.seq;
};
// exports.loginStore = async (request, reply) => { const moment = require('moment');
// try { exports.createwaterlevelSensor = async (req, reply) => {
// let store = await Store.findOne({ phone: request.body.phone }); try {
// if (!store) { const { hardwareId,hardwareId_company, type, indate } = req.body;
// return reply.code(400).send({ var mater_seq_id = await generatewaterlevelsensorId();
// simplydata: { const date = moment().format('MM-DD');
// error: true, const prefix = 'AS-' + date + '--MALOV1-';
// code: 400, var masterId = `${prefix}${mater_seq_id}`;
// message: "Invalid Phone or Password", const newSensor = new WaterLeverSensor({
// }, hardwareId,
// }); masterId,
// } type,
indate
// const isMatch = await bcrypt.compare(request.body.password, store.services.password.bcrypt); });
// if (!isMatch) { const savedSensor = await newSensor.save();
// return reply.code(400).send({ reply.code(201).send(savedSensor);
// simplydata: { } catch (err) {
// error: true, reply.code(500).send(err);
// code: 400, }
// message: "Invalid Phone or Password", };
// },
// });
// }
// const token = request.jwt.sign(
// {
// storename: store.storename,
// storeId: store._id,
// roles: store.profile.role,
// },
// { expiresIn: "30d" }
// );
// var profilePicture = await profilePictureStore.findOne({ storeId: store.storeId });
// if (!profilePicture) {
// reply.send({
// simplydata: {
// error: false,
// apiversion: fastify.config.APIVERSION,
// access_token: token,
// email: store.emails,
// phone: store.phone,
// storeId: store.storeId,
// storename: store.storename,
// office_address: store.profile.office_address,
// phoneVerified: store.phoneVerified,
// oneTimePasswordSetFlag: store.oneTimePasswordSetFlag,
// latitude: store.latitude,
// longitude: store.longitude,
// description: store.description,
// type: store.profile.role,
// typeasobj: JSON.stringify(Object.assign({}, store.profile.role)),
// },
// });
// } else {
// reply.send({
// simplydata: {
// error: false,
// apiversion: fastify.config.APIVERSION,
// access_token: token,
// picture: profilePicture.picture,
// email: store.emails,
// phone: store.phone,
// storeId: store.storeId,
// storename: store.storename,
// office_address: store.profile.office_address,
// phoneVerified: store.phoneVerified,
// oneTimePasswordSetFlag: store.oneTimePasswordSetFlag,
// latitude: store.latitude,
// longitude: store.longitude,
// description: store.description,
// type: store.profile.role,
// typeasobj: JSON.stringify(Object.assign({}, store.profile.role)),
// },
// });
// }
// } catch (err) {
// reply.send({
// simplydata: {
// error: true,
// code: 500,
// message: err.message,
// },
// });
// }
// };

@ -153,13 +153,60 @@ const installationschema = new mongoose.Schema({
const waterLeverSensorInSchema = new mongoose.Schema({
hardwareId: { type: String },
masterId: { type: String, default: null },
type: { type: String },
indate: { type: String },
hardwareId_company: { type: String },
qccheck: { type: String, default: null },
qccheckdate: { type: String, default: null },
qcby: { type: String, default: null },
comment: { type: String, default: "0" },
outforrepairdate: { type: String, default: "0" },
sendto: { type: String, default: null },
repairfeedback:{ type: String, default: "0" },
dateofinstallation: { type: String, default: null },
installedby: { type: String, default: "0" },
customerId:{ type: String,default:"0" },
comments:{ type: String,default:"0" },
slaves: {
source: { type: String },
tankhardware: [
{
tankhardwareId: { type: String },
slaveId: { type: String, default: null },
type: { type: String },
indate: { type: String },
hardwareId_company: { type: String },
qccheck: { type: String, default: null },
qccheckdate: { type: String, default: null },
qcby: { type: String, default: null },
comment: { type: String, default: "0" },
outforrepairdate: { type: String, default: "0" },
sendto: { type: String, default: null },
repairfeedback:{ type: String, default: "0" },
dateofinstallation: { type: String, default: null },
installedby: { type: String, default: "0" },
customerId:{ type: String,default:"0" },
comments:{ type: String,default:"0" },
}
]
}
});
const Store = mongoose.model("Store", storeSchema); const Store = mongoose.model("Store", storeSchema);
const WaterLeverSensor = mongoose.model('WaterLeverSensor', waterLeverSensorInSchema);
const ProfilePictureStore = mongoose.model('ProfilePictureStore', profilePictureStoreSchema); const ProfilePictureStore = mongoose.model('ProfilePictureStore', profilePictureStoreSchema);
const ProfilePictureInstall = mongoose.model('ProfilePictureInstall', profilePictureInstallSchema); const ProfilePictureInstall = mongoose.model('ProfilePictureInstall', profilePictureInstallSchema);
const Install = mongoose.model("Install", installationschema); const Install = mongoose.model("Install", installationschema);
module.exports = { Install, ProfilePictureInstall, generateinstallationId,Store,ProfilePictureStore}; module.exports = { Install, ProfilePictureInstall, generateinstallationId,Store,ProfilePictureStore,WaterLeverSensor};

@ -134,7 +134,24 @@ fastify.post('/api/stores', {
handler: storeController.addStore, handler: storeController.addStore,
}); });
fastify.post("/api/createwaterlevelSensor", {
schema: {
description: "This is for creating waterlevel Sensor",
tags: ["Store-Data"],
summary: "This is for creating waterlevel Sensor",
body: {
type: "object",
properties: {
hardwareId: { type: "string" },
type: { type: "string" },
indate: { type: "string" },
hardwareId_company: { type: "string" }
},
},
},
handler: storeController.createwaterlevelSensor,
})
next(); next();
}; };

Loading…
Cancel
Save