|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
const { Tanker, Tankerbooking,Bore } = require('../models/tankers')
|
|
|
|
|
const { Tanker, Tankerbooking,Bore,GovtPipeLine } = require('../models/tankers')
|
|
|
|
|
|
|
|
|
|
const User = require("../models/User");
|
|
|
|
|
const boom = require("boom");
|
|
|
|
@ -196,7 +196,7 @@ exports.addBores = async (req, reply) => {
|
|
|
|
|
if (checkFormEncoding.isUserFormUrlEncoded) {
|
|
|
|
|
usertobeInserted = checkFormEncoding.bores;
|
|
|
|
|
console.log("thsi true url string");
|
|
|
|
|
tank.customerId = usertobeInserted.customerId
|
|
|
|
|
bores.customerId = usertobeInserted.customerId
|
|
|
|
|
bores.boreName = usertobeInserted.boreName;
|
|
|
|
|
bores.typeofwater = usertobeInserted.typeofwater;
|
|
|
|
|
bores.description = usertobeInserted.description;
|
|
|
|
@ -264,3 +264,106 @@ exports.updateBoresInfo = async (req, reply) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.addGovtPIpeline = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var customerId = req.params.customerId;
|
|
|
|
|
//console.log(customerId);
|
|
|
|
|
//const username = loginObject.user.username;
|
|
|
|
|
|
|
|
|
|
pipelineData = {
|
|
|
|
|
customerId:customerId,
|
|
|
|
|
Name: req.body.Name,
|
|
|
|
|
typeofwater: req.body.typeofwater,
|
|
|
|
|
description: req.body.description,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pipeline_Name = req.body.Name
|
|
|
|
|
var i_pipe = await GovtPipeLine.findOne({ Name: pipeline_Name,customerId:customerId})
|
|
|
|
|
if(i_pipe){
|
|
|
|
|
throw new Error('Pipeline already exists');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
var pipe_line = new GovtPipeLine(pipelineData);
|
|
|
|
|
|
|
|
|
|
checkFormEncoding = isUserFormUrlEncoded(req);
|
|
|
|
|
if (checkFormEncoding.isUserFormUrlEncoded) {
|
|
|
|
|
usertobeInserted = checkFormEncoding.pipe_line;
|
|
|
|
|
console.log("thsi true url string");
|
|
|
|
|
pipe_line.customerId = usertobeInserted.customerId
|
|
|
|
|
pipe_line.Name = usertobeInserted.Name;
|
|
|
|
|
pipe_line.typeofwater = usertobeInserted.typeofwater;
|
|
|
|
|
pipe_line.description = usertobeInserted.description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const insertedpipeline = await pipe_line.save();
|
|
|
|
|
|
|
|
|
|
return insertedpipeline;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getPipeline = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
await GovtPipeLine.find({customerId: req.query.customerId})
|
|
|
|
|
.exec()
|
|
|
|
|
.then((docs) => {
|
|
|
|
|
reply.send({ status_code: 200, data: docs, count: docs.length });
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.log(err);
|
|
|
|
|
reply.send({ error: err });
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.deletePipelineInfo = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await GovtPipeLine.findOneAndDelete({customerId: req.params.customerId,Name: req.query.Name});
|
|
|
|
|
//console.log(Bore)
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200});
|
|
|
|
|
// return Bore;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.updatePipelineInfo = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var customerId = req.params.customerId;
|
|
|
|
|
var Name = req.query.Name;
|
|
|
|
|
const pipeline = req.body;
|
|
|
|
|
const { ...updateData } = pipeline;
|
|
|
|
|
const update = await GovtPipeLine.findOneAndUpdate({ customerId:customerId,Name: Name, }, updateData, { new: true });
|
|
|
|
|
//console.log(update.username)
|
|
|
|
|
//return update;
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200, data: update });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (err) {
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|