UPDATE TANK changes

master
Bhaskar 1 year ago
parent 1506c839a2
commit 6b0dc667f4

@ -133,13 +133,14 @@ exports.addTanks = async (req, reply) => {
exports.updateTanksInfo = async (req, reply) => {
try {
const InstallerId = req.params.InstallerId;
const customerId = req.body.customerId;
const customerId = req.params.customerId;
const tankName = req.query.tankName;
const tank = req.body;
const { ...updateData } = tank;
const update = await Tank.findOneAndUpdate({ InstallerId:InstallerId,tankName: tankName,customerId:customerId }, updateData, { new: true });
console.log(update.username)
console.log(tank)
const update = await Tank.findOneAndUpdate({customerId:customerId,tankName: tankName,tankLocation:req.body.tankLocation }, updateData, { new: true });
//console.log(update.username)
//return update;
reply.send({ status_code: 200, data: update });
@ -155,11 +156,11 @@ exports.updateTanksInfo = async (req, reply) => {
//delete selected tank
exports.deleteTanksInfo = async (req, reply) => {
try {
const InstallerId = req.params.InstallerId;
const customerId = req.body.customerId;
const customerId = req.params.customerId;
const tankName = req.query.tankName;
const tankLocation = req.body.tankLocation.toLowerCase();
const tank = await Tank.findOneAndDelete({ InstallerId:InstallerId,tankName: tankName,customerId:customerId,tankLocation:tankLocation });
const tank = await Tank.findOneAndDelete({ tankName: tankName,customerId:customerId,tankLocation:tankLocation });
reply.send({ status_code: 200, data: tank});
// return tank;

@ -53,17 +53,17 @@ module.exports = function (fastify, opts, next) {
fastify.route({
method: "PUT",
url: "/api/updateTanks/:InstallerId",
url: "/api/updateTanks/:customerId",
schema: {
tags: ["Install"],
summary: "This is for update tank",
params: {
required: ["InstallerId"],
required: ["customerId"],
type: "object",
properties: {
InstallerId: {
customerId: {
type: "string",
description: "InstallerId",
description: "customerId",
},
},
},
@ -75,8 +75,8 @@ module.exports = function (fastify, opts, next) {
type: "object",
// required: ['phone'],
properties: {
customerId: { type: "string", default: null },
tankName: { type: "string", default: null },
blockName: { type: "string", default: null },
capacity: { type: "string" },
typeOfWater: { type: "string", default: null },
@ -94,36 +94,34 @@ module.exports = function (fastify, opts, next) {
// fastify.auth([fastify.operatorAuthenticate]),
// validationHandler.validatePhoneFormat,
// ],
preHandler: fastify.auth([fastify.authenticate]),
// preHandler: fastify.auth([fastify.authenticate]),
handler: tanksController.updateTanksInfo,
});
fastify.route({
method: "PUT",
url: "/api/deleteTank/:InstallerId",
url: "/api/deleteTank/:customerId",
schema: {
tags: ["Install"],
summary: "This is for delete tank",
params: {
required: ["InstallerId"],
required: ["customerId"],
type: "object",
properties: {
InstallerId: {
customerId: {
type: "string",
description: "InstallerId",
},
description: "customerId",
},
},
querystring: {
tankName: {type: 'string'}
},
body: {
type: "object",
// required: ['phone'],
properties: {
customerId: { type: "string", default: null },
tankLocation: { type: "string", default: null },
},
},

Loading…
Cancel
Save