resources

This commit is contained in:
CHIEFSOFT\ameye
2024-02-27 06:58:15 -05:00
parent 3e481a1af4
commit 81362cffe8
4 changed files with 128 additions and 181 deletions
+7 -15
View File
@@ -1,27 +1,19 @@
'use strict';
const properties = require('../package.json')
const jobs = require('../service/jobs');
const banners = require('../service/banners');
const resourcecategory = require('../service/resourcecategory');
const logger = require('../app/logger');
var controllers = {
getFamilyBanners: function(req, res) {
banners.getfamilybanners(req, res, function(err, result) {
// logger.info(result);
/*
"status": "OK",
"total_record": 1,
"internal_return": 0,
"result_list"
*/
getFamilyResourceCat: function(req, res) { //famresourcecat
resourcecategory.getfamilybanners(req, res, function(err, result) {
res.status(200).json({'status': 'OK', 'internal_return': 0, 'result_list': result.result,'total_record': result.total_record })
//res.status(200).json({'status': 'OK', 'result_list': result })
});
},
getHomeBanners: function(req, res) {
//homebanners
banners.homebanners(req, res, function(err, dist) {
getResourceCat: function(req, res) {
//homebanners
resourcecategory.homebanners(req, res, function(err, dist) {
if (err) {
res.send(err);
}
+3 -4
View File
@@ -3,10 +3,9 @@
const controller = require('./controller');
module.exports = function(app) {
app.route('/familybanners')
.get(controller.getFamilyBanners);
app.route('/famresourcecat')
.get(controller.getFamilyResourceCat);
app.route('/homebanners')
.get(controller.getHomeBanners);
.get(controller.getResourceCat);
};
-56
View File
@@ -1,56 +0,0 @@
'use strict';
const request = require('request');
const db = require('../app/db')
const logger = require('../app/logger');
var jobs = {
getmarketjobs: function (req, res, next) {
//console.log("REQ---->",req.body.uid);
var data = {
"uid": req.body.uid,
"member_id": req.body.member_id,
"limit": (req.body.limit != null && req.body.limit !== "") ? req.body.limit : 20,
"sessionid": req.body.sessionid,
"page": req.body.page
};
let Qstring =""; // "SELECT uid,id,username FROM members LIMIT 10";
let QextraString ="";
if ( req.body.uid != null && req.body.uid !== ""){
QextraString= " AND j.country IN (SELECT c.country FROM members_wallet w " +
" LEFT JOIN currency c ON c.code =w.currency " +
" LEFT JOIN members m ON m.id = w.member_id " +
" WHERE m.uid = '"+req.body.uid+"' )";
}
Qstring = " SELECT j.title,j.description,m.id AS job_id,m.expire,m.job_description,j.price, " +
" m.offer_code,j.timeline_days, to_char(m.expire, 'Dy Mon dd, yyyy HH:MI AM') AS expire2," +
" m.uid AS offer_uid,j.uid AS job_uid,m.added::date AS offer_added,j.country AS job_country, " +
" c.code AS currency_code, c.description AS currency_description,j.country, j.category " +
" FROM members_jobs_offer m " +
" LEFT JOIN members_jobs j ON j.id=m.job_id " +
" LEFT JOIN currency c ON c.country=j.country " +
" WHERE m.status = 1 AND m.client_id=0 " +
" AND m.expire IS NOT NULL " +
" AND m.public_view = 1 AND m.expire> now() AND j.status = 1 " + QextraString +
" ORDER BY m.expire DESC LIMIT "+ data.limit;
// logger.info(Qstring);
db.query(Qstring, function (err, result) {
try {
if (err) throw err;
let resultItem ={
"result": result.rows,
"total_record": result.rowCount
}
// logger.info(result);
next(null, resultItem); // pass control to the next handler
// next(null, result.rows); // pass control to the next handler
} catch (e) {
next(e.message, null); // pass control to the next handler
}
});
}
};
module.exports = jobs;
+118 -106
View File
@@ -4,95 +4,108 @@ const request = require('request');
const db = require('../app/db')
const logger = require('../app/logger');
var banners = {
var resourcecategory = {
getfamilybanners: function (req, res, next) {
//console.log("REQ---->",req.body.uid);
var data = {
"uid": req.body.uid,
"member_id": req.body.member_id,
"limit": (req.body.limit != null && req.body.limit !== "") ? req.body.limit : 20,
"sessionid": req.body.sessionid,
"page": req.body.page
};
"uid": req.body.uid,
"member_id": req.body.member_id,
"limit": (req.body.limit != null && req.body.limit !== "") ? req.body.limit : 20,
"sessionid": req.body.sessionid,
"page": req.body.page
};
let Qstring =""; // "SELECT uid,id,username FROM members LIMIT 10";
let QextraString ="";
if ( req.body.uid != null && req.body.uid !== ""){
QextraString= " AND j.country IN (SELECT c.country FROM members_wallet w " +
" LEFT JOIN currency c ON c.code =w.currency " +
" LEFT JOIN members m ON m.id = w.member_id " +
" WHERE m.uid = '"+req.body.uid+"' )";
" LEFT JOIN currency c ON c.code =w.currency " +
" LEFT JOIN members m ON m.id = w.member_id " +
" WHERE m.uid = '"+req.body.uid+"' )";
}
Qstring = " SELECT j.title,j.description,m.id AS job_id,m.expire,m.job_description,j.price, " +
" m.offer_code,j.timeline_days, to_char(m.expire, 'Dy Mon dd, yyyy HH:MI AM') AS expire2," +
" m.uid AS offer_uid,j.uid AS job_uid,m.added::date AS offer_added,j.country AS job_country, " +
" c.code AS currency_code, c.description AS currency_description,j.country, j.category " +
" FROM members_jobs_offer m " +
" LEFT JOIN members_jobs j ON j.id=m.job_id " +
" LEFT JOIN currency c ON c.country=j.country " +
" WHERE m.status = 1 AND m.client_id=0 " +
" AND m.expire IS NOT NULL " +
" AND m.public_view = 1 AND m.expire> now() AND j.status = 1 " + QextraString +
" ORDER BY m.expire DESC LIMIT "+ data.limit;
" m.offer_code,j.timeline_days, to_char(m.expire, 'Dy Mon dd, yyyy HH:MI AM') AS expire2," +
" m.uid AS offer_uid,j.uid AS job_uid,m.added::date AS offer_added,j.country AS job_country, " +
" c.code AS currency_code, c.description AS currency_description,j.country, j.category " +
" FROM members_jobs_offer m " +
" LEFT JOIN members_jobs j ON j.id=m.job_id " +
" LEFT JOIN currency c ON c.country=j.country " +
" WHERE m.status = 1 AND m.client_id=0 " +
" AND m.expire IS NOT NULL " +
" AND m.public_view = 1 AND m.expire> now() AND j.status = 1 " + QextraString +
" ORDER BY m.expire DESC LIMIT "+ data.limit;
// // logger.info(Qstring);
// db.query(Qstring, function (err, result) {
// try {
// if (err) throw err;
// let resultItem ={
// "result": result.rows,
// "total_record": result.rowCount
// }
// // logger.info(result);
// next(null, resultItem); // pass control to the next handler
// // next(null, result.rows); // pass control to the next handler
// } catch (e) {
// next(e.message, null); // pass control to the next handler
// }
// // logger.info(Qstring);
// db.query(Qstring, function (err, result) {
// try {
// if (err) throw err;
// let resultItem ={
// "result": result.rows,
// "total_record": result.rowCount
// }
// // logger.info(result);
// next(null, resultItem); // pass control to the next handler
// // next(null, result.rows); // pass control to the next handler
// } catch (e) {
// next(e.message, null); // pass control to the next handler
// }
// });
// });
var bannerArray = {
"pending": {
"banner": {
"image": "https://www.wrenchboard.com/assets/images/apps/banners/recommend-banner.jpg",
"icon": "bannerimage.icon",
"style": "style1",
"text": "Pending",
"description": "Waiting for you to get started",
"action": "mytask"
}
},
"current": {
"banner": {
"image": "https://www.wrenchboard.com/assets/images/apps/banners/recommend-banner.jpg",
"icon": "bannerimage.icon",
"style": "style2",
"text": "Current",
"description": "Your currently active task",
"action": "mytask"
}
},
"recommend": {
"banner": {
"image": "https://www.wrenchboard.com/assets/images/apps/banners/recommend-banner.jpg",
"icon": "bannerimage.icon",
"style": "style3",
"text": "Recomend",
"description": "Send to parent to approve",
"action": "familymarket"
}
},
"pastdue": {
"banner": {
"image": "https://www.wrenchboard.com/assets/images/apps/banners/recommend-banner.jpg",
"icon": "bannerimage.icon",
"style": "style5",
"text": "Past Due",
"description": "Ask for more time if past due",
"action": "mytask"
}
"tab_categories": {
"data": [
{
"uid": "f1b99eee-607b-42f5-ad2f-d4f95065ccb9",
"name": "blog",
"content": "Blog",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"enabled": 1,
"action" : "work-in-progress"
},
{
"uid": "8208c72d-c5e1-43b2-bbe3-de285845427c",
"name": "onsale",
"content": "Questions?",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"enabled": 1,
"action" : "work-in-progress"
},
{
"uid": "3428c6db-af5f-49bf-b879-4a533d6b98bf",
"name": "owned",
"content": "Interesting",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"enabled": 1,
"action" : "work-in-progress"
},
{
"uid": "3b0ff711-dd42-4488-a7f4-a5fffd364701",
"name": "created",
"content": "My Items",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"enabled": 1,
"action" : "work-in-progress"
},
{
"uid": "f50eb4ca-37b3-45f0-93e9-e2b33b8b93d7",
"name": "created",
"content": "My Items",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"enabled": 1,
"action" : "work-in-progress"
},
{
"uid": "5751a446-7d52-498a-a0a2-06c926cdd5c4",
"name": "created",
"content": "My Items",
"banner": "https://www.wrenchboard.com/assets/images/apps/banners/family-login.jpg",
"enabled": 1,
"action" : "work-in-progress"
},
]
}
};
@@ -106,7 +119,7 @@ var banners = {
// "action": "thisaction"
// }
// },
let resultItem ={
"result": bannerArray,
"total_record": 4
@@ -115,12 +128,12 @@ var banners = {
},
homebanners: function (req, res, next) {
var result=[];
var result=[];
this.RecoCheckOffers(req, res, function(err, result){
logger.info("************************ aaaa");
logger.info(result);
logger.info("************************ bbbb");
logger.info("************************ aaaa");
logger.info(result);
logger.info("************************ bbbb");
});
var result_list =[
@@ -224,37 +237,37 @@ var result=[];
},
RecoCheckOffers : function (req, res, next) {
let Qstring ="SELECT * FROM members_jobs_offer WHERE expire > now() "+
"AND status = 1 AND client_id > 0 AND client_id =" +req.body.member_id;
logger.info(Qstring);
let Qstring ="SELECT * FROM members_jobs_offer WHERE expire > now() "+
"AND status = 1 AND client_id > 0 AND client_id =" +req.body.member_id;
logger.info(Qstring);
db.query(Qstring, function (err, result) {
try {
if (err) throw err;
let resultItem ={
"result":
"result":
[
{
"title": "Share RecoCheckOffers with a friend.",
"contract": null,
"card_type": "INVITE",
"card_style": null,
"description": "Show WrenchBoard to a friend and earn free coupons. Get started.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-refer.jpg",
"banner_location": "LOCAL",
"link_path": "referral",
"button_text": "Continue",
"short_button_text": "View now",
"short_title": "Invite a Friend - get Rewards",
"short_description": "Share WrenchBoard with a friend.",
"short_style": "short_style by"
"title": "Share RecoCheckOffers with a friend.",
"contract": null,
"card_type": "INVITE",
"card_style": null,
"description": "Show WrenchBoard to a friend and earn free coupons. Get started.",
"blog_id": "0",
"card_icon": "icon1",
"offer_id": "0",
"banner": "banner-refer.jpg",
"banner_location": "LOCAL",
"link_path": "referral",
"button_text": "Continue",
"short_button_text": "View now",
"short_title": "Invite a Friend - get Rewards",
"short_description": "Share WrenchBoard with a friend.",
"short_style": "short_style by"
}
]
,
"total_record": result.rowCount
]
,
"total_record": result.rowCount
};
logger.info(result);
next(null, resultItem); // pass control to the next handler
@@ -266,7 +279,6 @@ var result=[];
},
RecoCheckFamilyLogin : function (req, res, next) {},
RecoCheckFamilyCount : function (req, res, next) {},
RecoCheckFamilyCount : function (req, res, next) {},
RecoCheckCoupons : function (req, res, next) {},
RecoCheckTaskDue : function (req, res, next) {},
RecoCheckTaskReview : function (req, res, next) {},
@@ -275,4 +287,4 @@ var result=[];
RecoReferAFreind : function (req, res, next) {},
RecoPendingInterestCount : function (req, res, next) {}
};
module.exports = banners;
module.exports = resourcecategory;