Files
WrenchBoardBannersMicro/service/banners.js
T
CHIEFSOFT\ameye 0791a57f91 first commit
2024-02-25 06:38:59 -05:00

107 lines
4.1 KiB
JavaScript

'use strict';
const request = require('request');
const db = require('../app/db')
const logger = require('../app/logger');
var banners = {
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
};
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
// }
// });
var bannerArray = {
"pending": {
"banner": {
"image": "bannerimage.png",
"icon": "bannerimage.icon",
"style": "style1",
"text": "This is Banner Main text"
}
},
"current": {
"banner": {
"image": "bannerimage.png",
"icon": "bannerimage.icon",
"style": "style2",
"text": "This is Banner Main text"
}
},
"recommend": {
"banner": {
"image": "bannerimage.png",
"icon": "bannerimage.icon",
"style": "style3",
"text": "This is Banner Main text"
}
},
"another1task": {
"banner": {
"image": "bannerimage.png",
"icon": "bannerimage.icon",
"style": "style4",
"text": "This is Banner Main text"
}
},
"pastdue": {
"banner": {
"image": "bannerimage.png",
"icon": "bannerimage.icon",
"style": "style5",
"text": "This is Banner Main text"
}
}
};
let resultItem ={
"result": bannerArray,
"total_record": 5
}
next(null, resultItem ); // pass control to the next handler
}
};
module.exports = banners;