20211231 19.37 #2
@ -1,7 +1,7 @@
|
||||
Documentation of cma
|
||||
----------------------
|
||||
|
||||
1. GetOTP
|
||||
1. GetOTP(POST)
|
||||
===========
|
||||
-->Send mobilenumber and countrycode in POST method using getOtp link
|
||||
-->get mobilenumber and countrycode from application
|
||||
@ -12,7 +12,7 @@ Documentation of cma
|
||||
-->not exist means insert mobilenumber and countrycode in register table
|
||||
-->final result sent as response
|
||||
|
||||
2. VerifyOTP
|
||||
2. VerifyOTP(POST)
|
||||
============
|
||||
-->send mobilenumber and otp as base64encode and devicetype,devicetoken,deviceid as normal value in POST method using verifyOtp link
|
||||
-->get mobilenumber and otp as base64 decodemethod and also get devicetype,devicetoken,deviceidfrom application
|
||||
@ -23,7 +23,7 @@ Documentation of cma
|
||||
-->if success means update those values into register table by using userId
|
||||
-->not success means show error
|
||||
|
||||
3.ResendOTP
|
||||
3.ResendOTP(POST)
|
||||
===========
|
||||
-->Send mobilenumber in POST method using resendOtp link
|
||||
-->get mobilenumber and countrycode from application
|
||||
@ -31,7 +31,7 @@ Documentation of cma
|
||||
-->send to msg91 with mobilenumber and get response from msg91
|
||||
-->final result sent as response
|
||||
|
||||
4.Listplans
|
||||
4.Listplans(GET)
|
||||
==========
|
||||
-->using userid and deviceid we have to check there is any data in register table(this is for check which device is having this app with this mobile number)
|
||||
-->if yes
|
||||
@ -43,7 +43,7 @@ Documentation of cma
|
||||
-->if no
|
||||
-->show code is 2 for error & message is "this mobile number is register with another device please check"
|
||||
|
||||
5.SubscribePlan
|
||||
5.SubscribePlan(POST)
|
||||
==============
|
||||
-->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
|
||||
@ -57,4 +57,186 @@ Documentation of cma
|
||||
-->update details status=2(activeplan),plan_type=2(dynamic),startdate,enddate with 365days(dynamically get days from above select query) perid in register table by using mobilenumber
|
||||
-->sent code is 1 for success & message & planid
|
||||
-->if no
|
||||
-->show code is 2 for error & message is "this mobile number is register with another device please check"
|
||||
-->show code is 2 for error & message is "this mobile number is register with another device please check"
|
||||
|
||||
6.Listnews(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 news from news table with desc order and 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"
|
||||
|
||||
7.Listcategories(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 category from category table with status=1 & using these category id get marketcount from market_product table
|
||||
-->sent all data to async method to get result from single object data
|
||||
-->after get result , 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"
|
||||
|
||||
8.Listmarkets(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 needed details
|
||||
-->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"
|
||||
|
||||
9.Categorydetails(/categoryId(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 table by using categoryId with status=1
|
||||
-->check there is any match from select query
|
||||
-->if match
|
||||
-->sent all data to async method to get result from single object data
|
||||
-->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"
|
||||
|
||||
10.Total items from market count(this week (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 table by using thisweek data(7days intervel) 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"
|
||||
|
||||
11.Recent News count(This week (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 news table by using thisweek data(7days intervel) 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"
|
||||
|
||||
12. Statewise product with price(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 market and state table with status=1
|
||||
-->check there is any match from select query
|
||||
-->if match
|
||||
-->pass that productid into productprice table and select needed data and using async method to join two query objects
|
||||
-->receive query and 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"
|
||||
|
||||
13.News category(This week (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 newscategory table 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"
|
||||
|
||||
14.This Week news filter(This week (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 news table by using thisweek data(7days intervel) 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"
|
||||
|
||||
14.Next week news filter(This week (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 news table by using nextweek data(7days intervel) 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"
|
||||
|
||||
15.Last month news filter(This week (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 news table by using lastmonth data(30days intervel) 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"
|
||||
|
||||
16.Custom range news filter(startdate ,enddate (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 news table by using passing start date and end date 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"
|
||||
|
||||
17.List particular news category(NewscategoryId (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 newscategory table by using NewscategoryId 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"
|
||||
|
||||
18.List particular news (NewsId (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 newstable by using NewsId 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"
|
||||
|
428
routes/api.js
428
routes/api.js
@ -14,7 +14,7 @@ const { monitorEventLoopDelay } = require('perf_hooks');
|
||||
app.use(bodyparser.json());
|
||||
|
||||
|
||||
//getotp
|
||||
//1.getotp
|
||||
app.post('/getOtp',function(requ,res){
|
||||
|
||||
var mob =requ.body.mobile;
|
||||
@ -118,7 +118,7 @@ app.post('/getOtp',function(requ,res){
|
||||
});
|
||||
//=================================
|
||||
|
||||
//verifyotp
|
||||
//2.verifyotp
|
||||
app.post('/verifyOtp',function(requ,rese){
|
||||
|
||||
let bufferObjmob = Buffer.from(requ.body.mobile, "base64");
|
||||
@ -195,7 +195,7 @@ let otp = bufferObjotp.toString("utf8");
|
||||
});
|
||||
//=========================
|
||||
|
||||
//resend
|
||||
//3.resend
|
||||
app.post('/resendOtp',function(requ,rese){
|
||||
|
||||
|
||||
@ -253,9 +253,7 @@ app.post('/resendOtp',function(requ,rese){
|
||||
});
|
||||
//=================================
|
||||
|
||||
|
||||
//==================
|
||||
//1. List Plans
|
||||
//4. List Plans
|
||||
app.get('/listPlans',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) => {
|
||||
@ -296,7 +294,7 @@ app.get('/listPlans',function(req,res){
|
||||
});
|
||||
});
|
||||
//========================
|
||||
//2.subscribe plans
|
||||
//5.subscribe plans
|
||||
app.post('/subscribePlans',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) => {
|
||||
@ -372,29 +370,45 @@ let date = ("0" + date_ob.getDate()).slice(-2);
|
||||
|
||||
});
|
||||
//==================
|
||||
//3.News
|
||||
//6.News
|
||||
app.get('/listNews',function(req,res){
|
||||
let sql = "SELECT * FROM news ORDER BY id DESC";
|
||||
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 news WHERE status=1 ORDER BY id DESC";
|
||||
let query = db.query(sql,(err, results) => {
|
||||
|
||||
if(results.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
var last = new Date(date_ob.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
});
|
||||
//=======================
|
||||
//4.categories
|
||||
//7.categories
|
||||
app.get('/listCategories',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 category WHERE status=1";
|
||||
let query = db.query(sql,(err, results) => {
|
||||
|
||||
@ -423,16 +437,28 @@ app.get('/listCategories',function(req,res){
|
||||
},
|
||||
(err)=>{
|
||||
if(err) throw err;
|
||||
res.send(JSON.stringify({"data": finalresult}));
|
||||
var response_code="1";
|
||||
var response_msg="success";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": finalresult}));
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
//5.markets
|
||||
});
|
||||
//=================================
|
||||
//8.markets
|
||||
app.get('/listMarkets',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 m.id,m.location,m.city,m.state,m.country,m.product_id,m.category_id,m.created,m.updated,m.status,m.created_by,m.name as marketName,ca.name as categoryName,c.name as cityName,cn.name as countryName,s.name as stateName FROM market as m LEFT JOIN cities as c ON c.id=m.city LEFT JOIN countries as cn ON cn.id=m.country LEFT JOIN states as s ON s.id=m.state LEFT JOIN category as ca on ca.id=m.category_id WHERE m.status=1";
|
||||
let query = db.query(sql,(err, results) => {
|
||||
if(results.length > 0 ){
|
||||
@ -443,20 +469,33 @@ app.get('/listMarkets',function(req,res){
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
//6.Detailed category info
|
||||
});
|
||||
//====================
|
||||
//9.Detailed category info
|
||||
app.get('/categoryDetail/:categoryId',(req, res) => {
|
||||
let sql="SELECT * FROM product WHERE category_id="+req.params.categoryId
|
||||
let query = db.query(sql, (err, results) => {
|
||||
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 product WHERE category_id="+req.params.categoryId+" status=1"
|
||||
let query = db.query(sql, (err, resultss) => {
|
||||
if(err) throw err;
|
||||
|
||||
if(resultss.length > 0 ){
|
||||
|
||||
var process=results;
|
||||
var process=resultss;
|
||||
let finalresult=[];
|
||||
async.eachSeries(
|
||||
process,
|
||||
@ -476,16 +515,36 @@ app.get('/categoryDetail/:categoryId',(req, res) => {
|
||||
},
|
||||
(err)=>{
|
||||
if(err) throw err;
|
||||
res.send(JSON.stringify({"Data": finalresult}));
|
||||
var response_code="1";
|
||||
var response_msg="success";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": finalresult}));
|
||||
},
|
||||
);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": finalresult}));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
|
||||
//7.Total items from market
|
||||
});
|
||||
//==========================
|
||||
//10.Total items from market
|
||||
app.get('/totalItemFromMarket',function(req,res){
|
||||
let sql = "SELECT count(id)as marketItemCount FROM product_price WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 WEEK);";
|
||||
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 count(id)as marketItemCount FROM product_price WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 WEEK) and status=1";
|
||||
|
||||
let query = db.query(sql,(err, results) => {
|
||||
if(results.length > 0 ){
|
||||
@ -496,15 +555,28 @@ app.get('/totalItemFromMarket',function(req,res){
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
});
|
||||
//==========================
|
||||
//8. Recent News
|
||||
app.get('/recentNewsCount',function(req,res){
|
||||
let sql = "SELECT count(id)as recentNews FROM news WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 WEEK);";
|
||||
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 count(id)as recentNews FROM news WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 WEEK) and status=1";
|
||||
|
||||
let query = db.query(sql,(err, results) => {
|
||||
if(results.length > 0 ){
|
||||
@ -515,28 +587,41 @@ app.get('/recentNewsCount',function(req,res){
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
|
||||
//9. statewise product with price using product id
|
||||
});
|
||||
//==========================
|
||||
//11. statewise product with price using product id
|
||||
app.get('/statewiseProduct/:productId',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 DISTINCT s.name as stateName, s.id FROM market as m inner join states as s on s.id=m.state where m.status=1";
|
||||
|
||||
let query = db.query(sql, (err, results) => {
|
||||
let query = db.query(sql, (err, resultss) => {
|
||||
if(err) throw err;
|
||||
var process=results;
|
||||
var process=resultss;
|
||||
let finalresult=[];
|
||||
async.eachSeries(
|
||||
process,
|
||||
(result,callback) => {
|
||||
|
||||
var SID=result.id;
|
||||
let sql1 = "SELECT pp.created_date,m.name as marketName,pp.price,pp.units,me.name as measurement from product_price as pp left join market as m on m.id=pp.market_id left join product as p on p.id=pp.product_id left join measurement as me on me.id=pp.measurement WHERE m.state="+SID+" and pp.product_id="+req.params.productId;
|
||||
let sql1 = "SELECT pp.created_date,m.name as marketName,pp.price,pp.units,me.name as measurement from product_price as pp left join market as m on m.id=pp.market_id left join product as p on p.id=pp.product_id left join measurement as me on me.id=pp.measurement WHERE m.state="+SID+" and pp.status=1 and pp.product_id="+req.params.productId;
|
||||
db.query(sql1, (err, priceinfo) => {
|
||||
if(err) throw err;
|
||||
|
||||
result.priceinfo=priceinfo;
|
||||
let resultupdated=result;
|
||||
@ -548,206 +633,333 @@ app.get('/statewiseProduct/:productId',function(req,res){
|
||||
},
|
||||
(err)=>{
|
||||
if(err) throw err;
|
||||
res.send(JSON.stringify({"Data": finalresult}));
|
||||
res.send(JSON.stringify({"code":"1","message":"success","data": finalresult}));
|
||||
},
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
//10.News category
|
||||
});
|
||||
//==============================
|
||||
//12.News category
|
||||
app.get('/listNewsCategory',function(req,res){
|
||||
let sql = "SELECT * FROM news_category ORDER BY id DESC";
|
||||
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 news_category WHERE status=1 ORDER BY id DESC";
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
//11.This week filter
|
||||
});
|
||||
//==========================
|
||||
//13.This week filter
|
||||
app.get('/thisweekNews',function(req,res){
|
||||
let sql = "SELECT * FROM news WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 WEEK);";
|
||||
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 news WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 WEEK) and status=1";
|
||||
|
||||
let query = db.query(sql,(err, results) => {
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(results.length > 0 ){
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//12.next week filter
|
||||
//==================================
|
||||
//14.next week filter
|
||||
app.get('/nextweekNews',function(req,res){
|
||||
let sql = "SELECT * FROM news WHERE created_date >= DATE_ADD(NOW(), INTERVAL 1 WEEK);";
|
||||
|
||||
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 news WHERE created_date >= DATE_ADD(NOW(), INTERVAL 1 WEEK) and status=1";
|
||||
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
|
||||
}
|
||||
});
|
||||
//13.last month filter
|
||||
});
|
||||
//==========================
|
||||
//15.last month filter
|
||||
app.get('/lastmonthNews',function(req,res){
|
||||
let sql = "SELECT * FROM news WHERE YEAR(created_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) AND MONTH(created_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)";
|
||||
console.log(sql);
|
||||
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 news WHERE YEAR(created_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) AND MONTH(created_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) and status=1";
|
||||
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
|
||||
//14.custom range filter
|
||||
});
|
||||
//=================
|
||||
//16.custom range filter
|
||||
app.get('/customrangeNews/:startDate/:endDate',function(req,res){
|
||||
let sql = "select * from news where created_date between '"+req.params.startDate+"' and '"+req.params.endDate+"'";
|
||||
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 news where created_date between '"+req.params.startDate+"' and '"+req.params.endDate+"' and status=1";
|
||||
|
||||
let query = db.query(sql,(err, results) => {
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(results.length > 0 ){
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
//15.particular news category
|
||||
});
|
||||
//==============
|
||||
//17.particular news category
|
||||
app.get('/listNewsCategory/:newsCatId',function(req,res){
|
||||
let sql = "SELECT * FROM news where categories="+req.params.newsCatId;
|
||||
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 news where categories="+req.params.newsCatId+" and status=1";
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
|
||||
//16.particular news details
|
||||
});
|
||||
//=======================
|
||||
//18.particular news details
|
||||
app.get('/listNews/:newsId',function(req,res){
|
||||
let sql = "SELECT * FROM news where id="+req.params.newsId;
|
||||
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 news where id="+req.params.newsId+" and status=1";
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
|
||||
//17.price graph using productid & marketid
|
||||
});
|
||||
//======================
|
||||
//19.price graph using productid & marketid
|
||||
app.get('/weeklyPriceGraph/:marketId/:productId',function(req,res){
|
||||
let sql = "SELECT * FROM product_price where created_date >= DATE_SUB(NOW(), INTERVAL 1 WEEK) and product_id="+req.params.productId+" AND market_id="+req.params.marketId;
|
||||
|
||||
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 product_price where created_date >= DATE_SUB(NOW(), INTERVAL 1 WEEK) and product_id="+req.params.productId+" AND market_id="+req.params.marketId+" and status=1";
|
||||
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
//17.price graph using productid & marketid
|
||||
});
|
||||
//=================
|
||||
//20.price graph using productid & marketid //lastmonth
|
||||
app.get('/monthlyPriceGraph/:marketId/:productId',function(req,res){
|
||||
let sql = "SELECT * FROM product_price where YEAR(created_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) AND MONTH(created_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) and product_id="+req.params.productId+" AND market_id="+req.params.marketId;
|
||||
|
||||
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 product_price where YEAR(created_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) AND MONTH(created_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH) and product_id="+req.params.productId+" AND market_id="+req.params.marketId+" and status=1";
|
||||
|
||||
let query = db.query(sql,(err, resultss) => {
|
||||
|
||||
if(err) throw err
|
||||
if(resultss.length > 0 ){
|
||||
var response_code="1";
|
||||
var response_msg="Success";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": resultss}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
|
||||
//17.price graph using productid & marketid==>pending
|
||||
});
|
||||
//=====================
|
||||
//21.price graph using productid & marketid==>pending
|
||||
app.get('/statewisePriceGraph/:stateId/:productId',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 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) => {
|
||||
@ -759,14 +971,38 @@ app.get('/statewisePriceGraph/:stateId/:productId',function(req,res){
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_code="0";
|
||||
var response_msg="No Data";
|
||||
}
|
||||
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": results}));
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var response_code="2";
|
||||
var response_msg="This mobile number is register on another device please check";
|
||||
res.send(JSON.stringify({ "code":response_code,"message":response_msg,"data": ""}));
|
||||
}
|
||||
});
|
||||
});
|
||||
//===========================================================
|
||||
//************API END***************************************** */
|
||||
//=============================================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//| |
|
||||
|
Loading…
Reference in New Issue
Block a user