|
|
@ -8,7 +8,7 @@ const fastify = require("fastify")({
|
|
|
|
exports.addTanks = async (req, reply) => {
|
|
|
|
exports.addTanks = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
const username = req.params.username
|
|
|
|
var customerId = req.params.customerId
|
|
|
|
//const username = req.params.username;
|
|
|
|
//const username = req.params.username;
|
|
|
|
|
|
|
|
|
|
|
|
console.log(req.params);
|
|
|
|
console.log(req.params);
|
|
|
@ -21,7 +21,7 @@ console.log(req.params);
|
|
|
|
|
|
|
|
|
|
|
|
// console.log("This is the reply in the handler after the validations", reply);
|
|
|
|
// console.log("This is the reply in the handler after the validations", reply);
|
|
|
|
tankData = {
|
|
|
|
tankData = {
|
|
|
|
userName: username,
|
|
|
|
customerId: customerId,
|
|
|
|
tankName: req.body.tankName,
|
|
|
|
tankName: req.body.tankName,
|
|
|
|
blockName: req.body.blockName,
|
|
|
|
blockName: req.body.blockName,
|
|
|
|
capacity: req.body.capacity,
|
|
|
|
capacity: req.body.capacity,
|
|
|
@ -31,7 +31,7 @@ console.log(req.params);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var tank_name = req.body.tankName
|
|
|
|
var tank_name = req.body.tankName
|
|
|
|
var i_tank = await Tank.findOne({ tankName: tank_name,userName:username})
|
|
|
|
var i_tank = await Tank.findOne({ tankName: tank_name,customerId:customerId})
|
|
|
|
if(i_tank){
|
|
|
|
if(i_tank){
|
|
|
|
throw new Error('tankname already exists');
|
|
|
|
throw new Error('tankname already exists');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -43,6 +43,7 @@ console.log(req.params);
|
|
|
|
if (checkFormEncoding.isUserFormUrlEncoded) {
|
|
|
|
if (checkFormEncoding.isUserFormUrlEncoded) {
|
|
|
|
usertobeInserted = checkFormEncoding.tank;
|
|
|
|
usertobeInserted = checkFormEncoding.tank;
|
|
|
|
console.log("thsi true url string");
|
|
|
|
console.log("thsi true url string");
|
|
|
|
|
|
|
|
tank.customerId = usertobeInserted.customerId
|
|
|
|
tank.tankName = usertobeInserted.tankName;
|
|
|
|
tank.tankName = usertobeInserted.tankName;
|
|
|
|
tank.blockName = usertobeInserted.blockName;
|
|
|
|
tank.blockName = usertobeInserted.blockName;
|
|
|
|
tank.capacity = usertobeInserted.capacity;
|
|
|
|
tank.capacity = usertobeInserted.capacity;
|
|
|
@ -66,11 +67,11 @@ console.log(req.params);
|
|
|
|
exports.updateTanksInfo = async (req, reply) => {
|
|
|
|
exports.updateTanksInfo = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const username = loginObject.user.username;
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
const tankName = req.params.tankName;
|
|
|
|
const tankName = req.params.tankName;
|
|
|
|
const tank = req.body;
|
|
|
|
const tank = req.body;
|
|
|
|
const { ...updateData } = tank;
|
|
|
|
const { ...updateData } = tank;
|
|
|
|
const update = await Tank.findOneAndUpdate({ tankName: tankName,userName:username, }, updateData, { new: true });
|
|
|
|
const update = await Tank.findOneAndUpdate({ tankName: tankName,customerId:customerId, }, updateData, { new: true });
|
|
|
|
console.log(update.username)
|
|
|
|
console.log(update.username)
|
|
|
|
//return update;
|
|
|
|
//return update;
|
|
|
|
|
|
|
|
|
|
|
|