From 8a48e1a95ab8d9b09dcdc3880ec97069f4d2d578 Mon Sep 17 00:00:00 2001 From: Kaleeswari Date: Wed, 5 Jan 2022 15:39:07 +0530 Subject: [PATCH] 20220105 old version completeion --- CMA 3.0 Documentation | 110 ++++++++++++++++++++++++ routes/api.js | 188 +++++++++++++++++++++++++++++++++++------- 2 files changed, 269 insertions(+), 29 deletions(-) diff --git a/CMA 3.0 Documentation b/CMA 3.0 Documentation index 898395d..bf71c35 100644 --- a/CMA 3.0 Documentation +++ b/CMA 3.0 Documentation @@ -1,6 +1,26 @@ Documentation of cma ---------------------- + +//api response +otp section +1 - message sent +2 - verified +3 - error in verification +4 - resend +-------------------------- +//status in register (plan detail) + +0 - Plan not activate +1 - Trial Plan used +2 - Plan active(market or trial) +------------------------ +//plantype in register +0 - No plan select +1 - trial plan +2 - market +-------------------- +//=================================API Document=========================== 1. GetOTP(POST) =========== -->Send mobilenumber and countrycode in POST method using getOtp link @@ -240,3 +260,93 @@ Documentation of cma -->sent code 0 for no data & message -->if no -->show code is 2 for error & message is "this mobile number is register with another device please check" + +19.Weekly price graph(marketid,productid(GET) +=================== + -->using userid and deviceid ,we have to check there is any data in register table with deviceid and userid(this is for check which device is having this app with this mobile number) + -->if yes + -->select all details from product_price by using marketid,productid with status=1 with(weekly intervals) + -->check there is any match from select query + -->if match + -->sent code 1 for success & message + -->if no + -->sent code 0 for no data & message + -->if no + -->show code is 2 for error & message is "this mobile number is register with another device please check" + +20.monthly price graph(marketid,productid(GET) +=================== + -->using userid and deviceid ,we have to check there is any data in register table with deviceid and userid(this is for check which device is having this app with this mobile number) + -->if yes + -->select all details from product_price by using marketid,productid with status=1 with(monthly intervals) + -->check there is any match from select query + -->if match + -->sent code 1 for success & message + -->if no + -->sent code 0 for no data & message + -->if no + -->show code is 2 for error & message is "this mobile number is register with another device please check" + +20.statewise price graph(stateid,productid(GET) +=================== + -->using userid and deviceid ,we have to check there is any data in register table with deviceid and userid(this is for check which device is having this app with this mobile number) + -->if yes + -->select all details from product_price by using stateid,productid with status=1 + -->check there is any match from select query + -->if match + -->sent code 1 for success & message + -->if no + -->sent code 0 for no data & message + -->if no + -->show code is 2 for error & message is "this mobile number is register with another device please check" + +22.View user profile (GET) +=================== + -->using userid and deviceid ,we have to check there is any data in register table with deviceid and userid(this is for check which device is having this app with this mobile number) + -->if yes + -->select all details from register by using userId with join of pincodes,plans also + -->check there is any match from select query + -->if match + -->sent code 1 for success & message + -->if no + -->sent code 0 for no data & message + -->if no + -->show code is 2 for error & message is "this mobile number is register with another device please check" + +23.Edit user profile((GET) +================== + -->using userid and deviceid ,we have to check there is any data in register table with deviceid and userid(this is for check which device is having this app with this mobile number) + -->if yes + -->get details from get method and post location,email,name into register table + -->check there is any match from select query + -->if updated + -->sent code 1 for success & message + + -->if no + -->show code is 2 for error & message is "this mobile number is register with another device please check" + +24.Get location by using pincode(GET) +================== + -->using userid and deviceid ,we have to check there is any data in register table with deviceid and userid(this is for check which device is having this app with this mobile number) + -->if yes + -->hit select query by using pincode + -->check there is any match from select query (like query) + -->if yes + -->sent code 1 for success & message + -->if no + -->sent code 2 for no data & message + -->if no + -->show code is 2 for error & message is "this mobile number is register with another device please check" + +25.24.Get location by using region(GET) +================== + -->using userid and deviceid ,we have to check there is any data in register table with deviceid and userid(this is for check which device is having this app with this mobile number) + -->if yes + -->hit select query by using region name (like query) + -->check there is any match from select query + -->if yes + -->sent code 1 for success & message + -->if no + -->sent code 2 for no data & message + -->if no + -->show code is 2 for error & message is "this mobile number is register with another device please check" diff --git a/routes/api.js b/routes/api.js index 72d119d..cb8020c 100644 --- a/routes/api.js +++ b/routes/api.js @@ -4,7 +4,9 @@ var path = require('path'); const async = require('async'); - +var msg91_templateID="61d28c1778947f078d22b313"; +var msg91_authkey="154257AQ8i7Tb161d288f4P1"; +var devicee_access_check="This mobile number is register on another device please check"; const http = require("https"); var app = express(); @@ -41,7 +43,7 @@ app.post('/getOtp',function(requ,res){ "method": "GET", "hostname": "api.msg91.com", "port": null, - "path": "/api/v5/otp?template_id=619c52d5e986f307e67dec97&mobile="+mobwithccode+"&authkey=319029A6b14aygCL5e4cd2a2P1&otp_length=6", + "path": "/api/v5/otp?template_id="+msg91_templateID+"&mobile="+mobwithccode+"&authkey="+msg91_authkey+"&otp_length=6", "headers": { "Content-Type": "application/json" } @@ -85,7 +87,7 @@ app.post('/getOtp',function(requ,res){ "method": "GET", "hostname": "api.msg91.com", "port": null, - "path": "/api/v5/otp?template_id=619c52d5e986f307e67dec97&mobile="+mobwithccode+"&authkey=319029A6b14aygCL5e4cd2a2P1&otp_length=6", + "path": "/api/v5/otp?template_id="+msg91_templateID+"&mobile="+mobwithccode+"&authkey="+msg91_authkey+"&otp_length=6", "headers": { "Content-Type": "application/json" } @@ -150,7 +152,7 @@ let otp = bufferObjotp.toString("utf8"); "method": "GET", "hostname": "api.msg91.com", "port": null, - "path": "/api/v5/otp/verify?authkey=319029A6b14aygCL5e4cd2a2P1&mobile="+mobwithccode+"&otp="+otp+"", + "path": "/api/v5/otp/verify?authkey="+msg91_authkey+"&mobile="+mobwithccode+"&otp="+otp+"", "headers": {} }; @@ -221,7 +223,7 @@ app.post('/resendOtp',function(requ,rese){ "method": "GET", "hostname": "api.msg91.com", "port": null, - "path": "/api/v5/otp/retry?authkey=319029A6b14aygCL5e4cd2a2P1&retrytype=text&mobile="+mobwithccode+"", + "path": "/api/v5/otp/retry?authkey="+msg91_authkey+"&retrytype=text&mobile="+mobwithccode+"", "headers": {} }; @@ -286,7 +288,7 @@ app.get('/listPlans',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } @@ -361,7 +363,7 @@ let date = ("0" + date_ob.getDate()).slice(-2); else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } @@ -397,7 +399,7 @@ app.get('/listNews',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -447,7 +449,7 @@ app.get('/listCategories',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -478,7 +480,7 @@ app.get('/listMarkets',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -532,7 +534,7 @@ app.get('/categoryDetail/:categoryId',(req, res) => { else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -564,7 +566,7 @@ app.get('/totalItemFromMarket',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -596,7 +598,7 @@ app.get('/recentNewsCount',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -642,7 +644,7 @@ app.get('/statewiseProduct/:productId',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -675,7 +677,7 @@ app.get('/listNewsCategory',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -709,7 +711,7 @@ app.get('/thisweekNews',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -744,7 +746,7 @@ app.get('/nextweekNews',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } @@ -779,7 +781,7 @@ app.get('/lastmonthNews',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -813,7 +815,7 @@ app.get('/customrangeNews/:startDate/:endDate',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -846,7 +848,7 @@ app.get('/listNewsCategory/:newsCatId',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -879,7 +881,7 @@ app.get('/listNews/:newsId',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -913,7 +915,7 @@ app.get('/weeklyPriceGraph/:marketId/:productId',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -948,7 +950,7 @@ app.get('/monthlyPriceGraph/:marketId/:productId',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); @@ -961,7 +963,7 @@ app.get('/statewisePriceGraph/:stateId/:productId',function(req,res){ if(err) throw err if(results.length > 0 ){ let sql = "SELECT pp.*,m.name as marketName FROM product_price as pp left join market as m on m.id=pp.market_id where pp.product_id="+req.params.productId+" AND m.state="+req.params.stateId+" and pp.status=1"; - console.log(sql); + let query = db.query(sql,(err, results) => { if(results.length > 0 ){ @@ -982,11 +984,143 @@ app.get('/statewisePriceGraph/:stateId/:productId',function(req,res){ else { var response_code="2"; - var response_msg="This mobile number is register on another device please check"; + var response_msg=devicee_access_check; res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); } }); }); +//============================== +//22.show user profile +app.get('/viewUserProfile',function(req,res){ + let sql = "SELECT * FROM register WHERE id="+req.body.userId+" and device_unique_id='"+req.body.deviceId+"'"; + let query = db.query(sql,(err, results) => { + if(err) throw err + if(results.length > 0 ){ + let sql = "SELECT pc.id as locationId,pc.pincode,pc.region,pc.taluk,pc.district,pc.state,r.*,p.name as planName FROM register as r inner join plan as p on p.id=r.plan_type left join pincodes as pc on pc.id=r.location where r.id="+req.body.userId+""; + + let query = db.query(sql,(err, resultss) => { + + if(resultss.length > 0 ){ + var response_code="1"; + var response_msg="Success"; + + } + else + { + var response_code="0"; + var response_msg="No Data"; + } + + res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss})); + + }); +} +else +{ + var response_code="2"; + var response_msg=devicee_access_check; + res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); +} +}); +}); +//================= +//23.edit user profile +app.get('/editUserProfile',function(req,res){ + let sql = "SELECT * FROM register WHERE id="+req.body.userId+" and device_unique_id='"+req.body.deviceId+"'"; + let query = db.query(sql,(err, results) => { + if(err) throw err + if(results.length > 0 ){ + var data={ + name:req.body.fullName, + location:req.body.location, + email:req.body.email + } + let sql = "UPDATE register SET ? WHERE id=" +req.body.userId; + let query = db.query(sql,data,(err, resultss) => { + if(err) throw err + var response_code="1"; + var response_msg="Updated Successfully"; + res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss})); + }); + } +else +{ + var response_code="2"; + var response_msg=devicee_access_check; + res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); +} +}); +}); +//================ +//24.get location by using pincode +app.get('/getLocByPincode',function(req,res){ + let sql = "SELECT * FROM register WHERE id="+req.body.userId+" and device_unique_id='"+req.body.deviceId+"'"; + let query = db.query(sql,(err, results) => { + if(err) throw err + if(results.length > 0 ){ + let sql = "SELECT * FROM pincodes WHERE pincode like '"+req.body.pincode+"%'"; + let query = db.query(sql,(err, resultss) => { + + if(resultss.length > 0 ){ + var response_code="1"; + var response_msg="Success"; + + } + else + { + var response_code="0"; + var response_msg="No Data"; + } + + res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss})); + + }); + } +else +{ + var response_code="2"; + var response_msg=devicee_access_check; + res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); +} +}); +}); +//================ + +//25.get location by using region +app.get('/getLocByRegion',function(req,res){ + let sql = "SELECT * FROM register WHERE id="+req.body.userId+" and device_unique_id='"+req.body.deviceId+"'"; + let query = db.query(sql,(err, results) => { + if(err) throw err + if(results.length > 0 ){ + let sql = "SELECT * FROM pincodes WHERE region like '"+req.body.region+"%'"; + console.log(sql); + let query = db.query(sql,(err, resultss) => { + + if(resultss.length > 0 ){ + var response_code="1"; + var response_msg="Success"; + + } + else + { + var response_code="0"; + var response_msg="No Data"; + } + + res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss})); + + }); + } +else +{ + var response_code="2"; + var response_msg=devicee_access_check; + res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""})); +} +}); +}); +//================ + //=========================================================== //************API END***************************************** */ //============================================================= @@ -1071,10 +1205,6 @@ const filestorageEngine=multer.diskStorage({ { cb(null,"ca-"+Date.now()+ path.extname(file.originalname)); - - - - } }); const uploads=multer({