Commit eb5d0803 by 兰国旗

laolan

parent 8c1e5d04
const APIBase = require("../../api.base"); const APIBase = require("../../api.base");
const system = require("../../../system"); const system = require("../../../system");
const settings = require("../../../../config/settings");
/** /**
* 媒体聚合页项目-移动端调用相关接口 * 媒体聚合页项目-移动端调用相关接口
*/ */
...@@ -8,6 +7,7 @@ class Mediaaggregation extends APIBase { ...@@ -8,6 +7,7 @@ class Mediaaggregation extends APIBase {
constructor() { constructor() {
super(); super();
this.needinfoSve = system.getObject("service.media.needinfoSve"); this.needinfoSve = system.getObject("service.media.needinfoSve");
this.mediaaggregationSve = system.getObject("service.mediaaggregation.mediaaggregationSve");
} }
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
...@@ -40,5 +40,58 @@ class Mediaaggregation extends APIBase { ...@@ -40,5 +40,58 @@ class Mediaaggregation extends APIBase {
return opResult; return opResult;
} }
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async mediAaggregationApi(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.mediAaggregationAction(pobj, pobj.actionType, req);
return result;
}
async mediAaggregationAction(pobj, action_type, req) {
var opResult = null;
var self = this;
pobj.xctx = req.xctx;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess("测试接口");
break;
case "productList"://首页产品列表
opResult = await this.mediaaggregationSve.productList(pobj);
break;
case "rotationChartList"://首页轮播图
opResult = await this.mediaaggregationSve.rotationChartList(pobj);
break;
case "needProductList"://留资表单产品
opResult =await this.mediaaggregationSve.needProductList(pobj);
break;
case "popularRecommendationList"://热门推荐列表
opResult = await this.mediaaggregationSve.popularRecommendationList(pobj);
break;
case "productTypeFirst"://产品分类列表
opResult = await this.mediaaggregationSve.productTypeFirst(pobj);
break;
case "productTypeSecend"://产品分类列表
opResult = await this.mediaaggregationSve.productTypeSecend(pobj);
break;
case "productDetail"://产品详情页
opResult = await this.mediaaggregationSve.productDetail(pobj);
break;
// case "bottomMenuConfig"://吸底菜单
// opResult =await this.mediaaggregationSve.bottomMenuConfig(pobj);
// break;
default:
opResult = system.getResult(null, "action_type参数错误");
}
return opResult;
}
} }
module.exports = Mediaaggregation; module.exports = Mediaaggregation;
const system = require("../../../system");
const Dao = require("../../dao.base");
class MediaaggregationDao extends Dao {
constructor() {
super(Dao.getModelName(MediaaggregationDao));
}
/**
* 获取产品列表
*/
async productList() {
var returnRes = {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_product where deleted_at is null ";
var sql = "select count(1) as dataCount from mc_product where deleted_at is null ";
var list = await this.customQuery(sql);
returnRes.rows = list;
// var result = system.getResultSuccess(list);
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
var result = system.getResultSuccess(returnRes);
return result;
}
/**
* 轮播图
*/
async rotationChartList(){
var returnRes = {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_rotation_chart where deleted_at is null ";
var sql = "select * from mc_rotation_chart where deleted_at is null ";
var list = await this.customQuery(sql);
returnRes.rows = list;
// var result = system.getResultSuccess(list);
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
var result = system.getResultSuccess(returnRes);
return result;
}
/**
* 留资表单产品
*/
async needProductList(){
var returnRes = {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_second_level_need_config where deleted_at is null ";
var sql = "select * from mc_second_level_need_config where deleted_at is null ";
var list = await this.customQuery(sql);
returnRes.rows = list;
// var result = system.getResultSuccess(list);
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
var result = system.getResultSuccess(returnRes);
return result;
}
/**
* 热门推荐
*/
async popularRecommendationList(){
var returnRes = {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_popular_recommendation where deleted_at is null ";
var sql = "select * from mc_popular_recommendation where deleted_at is null ";
var list = await this.customQuery(sql);
returnRes.rows = list;
// var result = system.getResultSuccess(list);
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
var result = system.getResultSuccess(returnRes);
return result;
}
/**
* 产品分类一类
*/
async productTypeFirst(){
var returnRes = {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_product where deleted_at is null and p_id is null";
var sql = "select count(1) as dataCount from mc_product where deleted_at is null and p_id is null";
var list = await this.customQuery(sql);
returnRes.rows = list;
// var result = system.getResultSuccess(list);
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
var result = system.getResultSuccess(returnRes);
return result;
}
/**
* 产品分类二类
*/
async productTypeSecend(req){
var params = {
product_type_code: req.actionBody.product_type_code
};
var returnRes = {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_product left join mc_product_type on mc_product.product_type_id = mc_product_type.id where mc_product.deleted_at is null and mc_product_type.deleted_at is null and product_type_code = :product_type_code ";
var sql = "select * from mc_product left join mc_product_type on mc_product.product_type_id = mc_product_type.id where mc_product.deleted_at is null and mc_product_type.deleted_at is null and product_type_code = :product_type_code";
var list = await this.customQuery(sql,params);
returnRes.rows = list;
// var result = system.getResultSuccess(list);
var tmpResultCount = await this.customQuery(dataCount,params);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
var result = system.getResultSuccess(returnRes);
return result;
}
/**
* 获取产品详情
*/
async productDetail(req) {
var params = {
product_type_code: req.actionBody.product_type_code
};
var sql = "select * from mc_product where product_type_code = :product_type_code";
var list = await this.customQuery(sql, params);
return list;
}
// /**
// * 吸底菜单
// */
// async bottomMenuConfig(req) {
// var returnRes = {
// total: 0,//总记录条数
// rows: []
// };
// var dataCount = "select count(1) as dataCount from mc_bottom_menu_config where deleted_at is null ";
// var sql = "select count(1) as dataCount from mc_bottom_menu_config where deleted_at is null ";
// var list = await this.customQuery(sql);
// returnRes.rows = list;
// // var result = system.getResultSuccess(list);
// var tmpResultCount = await this.customQuery(dataCount);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var result = system.getResultSuccess(returnRes);
// return result;
// }
/**
*方案一
*/
// async firstAction(){
// }
}
module.exports = MediaaggregationDao;
\ No newline at end of file
const system = require("../../../system");
const mediaaggregationDao = system.getObject("db.mediaaggregation.mediaaggregationDao");
class MediaaggregationSve {
constructor() {
}
//首页产品列表
async productList(pobj) {
if (!pobj || !pobj.actionBody) {
return system.getResultFail(-100, "参数错误");
}
var res =await mediaaggregationDao.productList(pobj);
return system.getResultSuccess(res);
}
//首页轮播图
async rotationChartList(pobj) {
if (!pobj || !pobj.actionBody) {
return system.getResultFail(-100, "参数错误");
}
var res =await mediaaggregationDao.rotationChartList(pobj);
return system.getResultSuccess(res);
}
//留资表单产品
async needProductList(pobj) {
if (!pobj || !pobj.actionBody) {
return system.getResultFail(-100, "参数错误");
}
var res =await mediaaggregationDao.needProductList(pobj);
return system.getResultSuccess(res);
}
//热门推荐
async popularRecommendationList(pobj) {
if (!pobj || !pobj.actionBody) {
return system.getResultFail(-100, "参数错误");
}
var res =await mediaaggregationDao.popularRecommendationList(pobj);
return system.getResultSuccess(res);
}
//产品分类一类
async productTypeFirst(pobj) {
if (!pobj || !pobj.actionBody) {
return system.getResultFail(-100, "参数错误");
}
var res =await mediaaggregationDao.productTypeFirst(pobj);
return system.getResultSuccess(res);
}
//产品分类二类
async productTypeSecend(pobj) {
if (!pobj || !pobj.actionBody) {
return system.getResultFail(-100, "参数错误");
}
var res =await mediaaggregationDao.productTypeSecend(pobj);
return system.getResultSuccess(res);
}
//产品详情
async productDetail(pobj) {
if (!pobj || !pobj.actionBody) {
return system.getResultFail(-100, "参数错误");
}
var res =await mediaaggregationDao.productDetail(pobj);
return system.getResultSuccess(res);
}
// //吸底菜单
// async bottomMenuConfig(pobj) {
// if (!pobj || !pobj.actionBody) {
// return system.getResultFail(-100, "参数错误");
// }
// var res =await mediaaggregationDao.bottomMenuConfig(pobj);
// return system.getResultSuccess(res);
// }
}
module.exports = MediaaggregationSve;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment