|
|
|
@ -12,11 +12,12 @@ const fastify = require("fastify")({
|
|
|
|
|
|
|
|
|
|
exports.createConnections = async (req, body) => {
|
|
|
|
|
try {
|
|
|
|
|
var customerId = req.body.source;
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
var tankname = req.body.tankname;
|
|
|
|
|
|
|
|
|
|
const tankInfo = await Tank.findOne({ customerId: customerId.toString() })
|
|
|
|
|
const tankInfo = await Tank.findOne({ customerId: customerId.toString(),tankName:tankname })
|
|
|
|
|
const usertobeInserted = req.body;
|
|
|
|
|
if (usertobeInserted.source) tankInfo.connections.source = usertobeInserted.source;
|
|
|
|
|
tankInfo.connections.source = tankInfo.tankName;
|
|
|
|
|
if (usertobeInserted.inputConnections) tankInfo.connections.inputConnections = usertobeInserted.inputConnections;
|
|
|
|
|
if (usertobeInserted.outputConnections) tankInfo.connections.outputConnections = usertobeInserted.outputConnections;
|
|
|
|
|
const tank_connections = await tankInfo.save();
|
|
|
|
@ -31,11 +32,12 @@ exports.createConnections = async (req, body) => {
|
|
|
|
|
exports.updateconnectionInfo = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
//const username = loginObject.user.username;
|
|
|
|
|
const customerId = req.params.source;
|
|
|
|
|
const tankInfo = await Tank.findOne({ customerId: customerId.toString() })
|
|
|
|
|
const tankname = req.body.tankname
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
const tankInfo = await Tank.findOne({ customerId: customerId.toString(),tankName:tankname })
|
|
|
|
|
const updateData = req.body;
|
|
|
|
|
|
|
|
|
|
if (updateData.source) tankInfo.connections.source = updateData.source;
|
|
|
|
|
tankInfo.connections.source = tankInfo.tankName;
|
|
|
|
|
if (updateData.inputConnections) tankInfo.connections.inputConnections = updateData.inputConnections;
|
|
|
|
|
if (updateData.outputConnections) tankInfo.connections.outputConnections = updateData.outputConnections;
|
|
|
|
|
const tank_connections = await tankInfo.save();
|
|
|
|
|