From 4e6faf300a22dfba5ca1bfd4082cfc13e3bada4c Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Fri, 4 Oct 2024 22:20:10 -0400 Subject: [PATCH] getAllMarketjobs --- api/controller.js | 2 +- service/jobs.js | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/api/controller.js b/api/controller.js index e64c62d..fc412ab 100644 --- a/api/controller.js +++ b/api/controller.js @@ -7,7 +7,7 @@ const ebroker = require('../service/ebroker'); var controllers = { getMarketJobs: function(req, res) { - jobs.getmarketjobs(req, res, function(err, result) { + jobs.getAllMarketjobs(req, res, function(err, result) { res.status(200).json({'status': 'OK', 'internal_return': 0, 'result_list': result.result,'total_record': result.total_record }) }); }, diff --git a/service/jobs.js b/service/jobs.js index 2b4b1b8..9c4d00b 100644 --- a/service/jobs.js +++ b/service/jobs.js @@ -5,6 +5,47 @@ const db = require('../app/db') const logger = require('../app/logger'); var jobs = { + getAllMarketjobs: function (req, res, next) { + + //console.log("REQ---->",req.body.uid); + logger.info("------lll---->"); + logger.info(req.query); + var data = { + "limit": (req.query.limit != null && req.query.limit !== "") ? req.query.limit : 60, + "page": req.query.page + }; + let Qstring =""; // "SELECT uid,id,username FROM members LIMIT 10"; + let QextraString =""; + + Qstring = " SELECT j.title,j.description,m.id AS job_id,m.expire,m.job_description,j.price, m.depend_uid AS offer_depend_uid, " + + " 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,mb.uid AS market_uid, 0 AS interest_count " + + " FROM members_jobs_offer m " + + " LEFT JOIN members_jobs j ON j.id=m.job_id " + + " LEFT JOIN members mb ON mb.id = m.member_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 + } + }); + }, getmarketjobs: function (req, res, next) { //console.log("REQ---->",req.body.uid);