Commit 730ec760 by 兰国旗

laolan

parent 741ae9fe
const system = require("../../../system");
const Dao = require("../../dao.base");
class MediaaggregationDao extends Dao {
constructor() {
super(Dao.getModelName(MediaaggregationDao));
this.redisClient = system.getObject("util.redisClient");
}
/**
......@@ -16,13 +18,18 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_product where deleted_at is null and product_type_code = :product_type_code and is_enabled = 1 ";
var countSql = "select count(1) as dataCount from mc_product where deleted_at is null and product_type_code = :product_type_code and is_enabled = 1 ";
var sql = "select * from mc_product where deleted_at is null and product_type_code = :product_type_code and is_enabled = 1 ";
var optionType = "get";
var functionName = "productList";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName, params);
var list = await this.customQuery(sql, params);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount, params);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_product where deleted_at is null and product_type_code = :product_type_code and is_enabled = 1 ";
// var sql = "select * from mc_product where deleted_at is null and product_type_code = :product_type_code and is_enabled = 1 ";
// var list = await this.customQuery(sql, params);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount, params);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -34,13 +41,18 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_rotation_chart where deleted_at is null and pic_type = 2 and is_enabled = 1 ";
var countSql = "select count(1) as dataCount from mc_rotation_chart where deleted_at is null and pic_type = 2 and is_enabled = 1 ";
var sql = "select * from mc_rotation_chart where deleted_at is null and pic_type = 2 and is_enabled = 1 ";
var optionType = "get";
var functionName = "rotationChartList";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName);
var list = await this.customQuery(sql);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_rotation_chart where deleted_at is null and pic_type = 2 and is_enabled = 1 ";
// var sql = "select * from mc_rotation_chart where deleted_at is null and pic_type = 2 and is_enabled = 1 ";
// var list = await this.customQuery(sql);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -52,13 +64,19 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_rotation_chart where deleted_at is null and pic_type = 1 and is_enabled = 1 ";
var countSql = "select count(1) as dataCount from mc_rotation_chart where deleted_at is null and pic_type = 1 and is_enabled = 1 ";
var sql = "select * from mc_rotation_chart where deleted_at is null and pic_type = 1 and is_enabled = 1 ";
var optionType = "get";
var functionName = "tablePicList";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName);
var list = await this.customQuery(sql);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_rotation_chart where deleted_at is null and pic_type = 1 and is_enabled = 1 ";
// var sql = "select * from mc_rotation_chart where deleted_at is null and pic_type = 1 and is_enabled = 1 ";
// var list = await this.customQuery(sql);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -70,13 +88,18 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_second_level_need_config where deleted_at is null ";
var countSql = "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 optionType = "get";
var functionName = "needProductList";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName);
var list = await this.customQuery(sql);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// 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 tmpResultCount = await this.customQuery(dataCount);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -88,13 +111,19 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_popular_recommendation where deleted_at is null and is_enabled = 1 ";
var countSql = "select count(1) as dataCount from mc_popular_recommendation where deleted_at is null and is_enabled = 1 ";
var sql = "select * from mc_popular_recommendation where deleted_at is null and is_enabled = 1 ";
var optionType = "get";
var functionName = "popularRecommendationList";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName);
var list = await this.customQuery(sql);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_popular_recommendation where deleted_at is null and is_enabled = 1 ";
// var sql = "select * from mc_popular_recommendation where deleted_at is null and is_enabled = 1 ";
// var list = await this.customQuery(sql);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -106,13 +135,18 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_product_type where deleted_at is null and p_id = 0 ";
var countSql = "select count(1) as dataCount from mc_product_type where deleted_at is null and p_id = 0 ";
var sql = "select * from mc_product_type where deleted_at is null and p_id = 0 ";
var optionType = "get";
var functionName = "productTypeFirst";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName);
var list = await this.customQuery(sql);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_product_type where deleted_at is null and p_id = 0 ";
// var sql = "select * from mc_product_type where deleted_at is null and p_id = 0 ";
// var list = await this.customQuery(sql);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -127,13 +161,18 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_product_type where deleted_at is null and p_code = :p_code ";
var countSql = "select count(1) as dataCount from mc_product_type where deleted_at is null and p_code = :p_code ";
var sql = "select * from mc_product_type where deleted_at is null and p_code = :p_code ";
var optionType = "get";
var functionName = "productTypeSecend";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName, params);
var list = await this.customQuery(sql, params);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount, params);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_product_type where deleted_at is null and p_code = :p_code ";
// var sql = "select * from mc_product_type where deleted_at is null and p_code = :p_code ";
// var list = await this.customQuery(sql, params);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount, params);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
/**
......@@ -143,9 +182,15 @@ class MediaaggregationDao extends Dao {
var params = {
code: req.actionBody.code
};
var countSql = "select count(1) as dataCount from mc_product where deleted_at is null and is_enabled = 1 and code = :code ";
var sql = "select * from mc_product where deleted_at is null and is_enabled = 1 and code = :code ";
var list = await this.customQuery(sql, params);
return list;
var optionType = "get";
var functionName = "productDetail";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName, params);
// var sql = "select * from mc_product where deleted_at is null and is_enabled = 1 and code = :code ";
// var list = await this.customQuery(sql, params);
return returnRes;
}
/**
......@@ -156,13 +201,18 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_bottom_menu_config where deleted_at is null ";
var countSql = "select count(1) as dataCount from mc_bottom_menu_config where deleted_at is null ";
var sql = "select * from mc_bottom_menu_config where deleted_at is null ";
var optionType = "get";
var functionName = "bottomMenuConfig";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName);
var list = await this.customQuery(sql);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_bottom_menu_config where deleted_at is null ";
// var sql = "select * from mc_bottom_menu_config where deleted_at is null ";
// var list = await this.customQuery(sql);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -174,17 +224,22 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_cycle_product where deleted_at is null ";
var countSql = "select count(1) as dataCount from mc_cycle_product where deleted_at is null ";
var sql = "select * from mc_cycle_product where deleted_at is null ";
var optionType = "get";
var functionName = "cycleProduct";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName);
var list = await this.customQuery(sql);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_cycle_product where deleted_at is null ";
// var sql = "select * from mc_cycle_product where deleted_at is null ";
// var list = await this.customQuery(sql);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
/**
* 二级留资页热门推荐
*/
......@@ -196,13 +251,19 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_second_level_need_config where deleted_at is null and code = :code ";
var countSql = "select count(1) as dataCount from mc_second_level_need_config where deleted_at is null and code = :code ";
var sql = "select * from mc_second_level_need_config where deleted_at is null and code = :code";
var optionType = "get";
var functionName = "secondLevelNeedConfig"
var returnRes = this.redisInfo(sql, countSql, optionType, functionName, params);
var list = await this.customQuery(sql, params);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount, params);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
// var dataCount = "select count(1) as dataCount from mc_second_level_need_config where deleted_at is null and code = :code ";
// var sql = "select * from mc_second_level_need_config where deleted_at is null and code = :code";
// var list = await this.customQuery(sql, params);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount, params);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -219,20 +280,33 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
if(apiType && apiType == '1'){//二类产品资质选项(选取数据线索的数据)
var dataCount = "select count(1) as dataCount from mc_clue_maintenance where deleted_at is null";
if (apiType && apiType == '1') {//二类产品资质选项(选取数据线索的数据)
var countSql = "select count(1) as dataCount from mc_clue_maintenance where deleted_at is null";
var sql = "select clue_info from mc_clue_maintenance where deleted_at is null";
var functionName = "clueMaintenance";
}
if(apiType && apiType == '2'){//留资表单产品列表(我需要)
var dataCount = "select count(1) as dataCount from mc_clue_maintenance where deleted_at is null and code = :code ";
if (apiType && apiType == '2') {//留资表单产品列表(我需要)
var countSql = "select count(1) as dataCount from mc_clue_maintenance where deleted_at is null and code = :code ";
var sql = "select clue_info from mc_clue_maintenance where deleted_at is null and code = :code ";
var functionName = "clueMaintenanceCode";
}
var optionType = "get";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName, params);
// if (apiType && apiType == '1') {//二类产品资质选项(选取数据线索的数据)
// var dataCount = "select count(1) as dataCount from mc_clue_maintenance where deleted_at is null";
// var sql = "select clue_info from mc_clue_maintenance where deleted_at is null";
// }
// if (apiType && apiType == '2') {//留资表单产品列表(我需要)
// var dataCount = "select count(1) as dataCount from mc_clue_maintenance where deleted_at is null and code = :code ";
// var sql = "select clue_info from mc_clue_maintenance where deleted_at is null and code = :code ";
// }
// var list = await this.customQuery(sql, params);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount, params);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
var list = await this.customQuery(sql, params);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount, params);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
......@@ -248,15 +322,74 @@ class MediaaggregationDao extends Dao {
total: 0,//总记录条数
rows: []
};
var dataCount = "select count(1) as dataCount from mc_cycle_product where deleted_at is null and cycle_type = :cycle_type ";
var sql = "select * from mc_cycle_product where deleted_at is null and cycle_type = :cycle_type ";
var functionName;
var sql = "select * from mc_cycle_product where deleted_at is null and cycle_type = :cycle_type";
var countSql = "select count(1) as dataCount from mc_cycle_product where deleted_at is null and cycle_type = :cycle_type ";
var list = await this.customQuery(sql, params);
returnRes.rows = list;
var tmpResultCount = await this.customQuery(dataCount, params);
returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
switch (req.actionBody.cycle_type) {
case "1":
functionName = "cycleProductSecend1";
break;
case "2":
functionName = "cycleProductSecend2";
break;
case "3":
functionName = "cycleProductSecend3";
break;
}
var optionType = "get";
var returnRes = this.redisInfo(sql, countSql, optionType, functionName, params);
//删除
// var optionType = "del";
// var returnRes = this.redisInfo(sql, countSql, optionType, functionName, params);
// var dataCount = "select count(1) as dataCount from mc_cycle_product where deleted_at is null and cycle_type = :cycle_type ";
// var sql = "select * from mc_cycle_product where deleted_at is null and cycle_type = :cycle_type ";
// var list = await this.customQuery(sql, params);
// returnRes.rows = list;
// var tmpResultCount = await this.customQuery(dataCount, params);
// returnRes.total = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return returnRes;
}
async redisInfo(sql, countSql, optionType, functionName, params = "") {
var template = "mediaaggregation";
let shaStr; // 将linkObj转为字符串并计算出sha256的值
let rtn; // 根据shaStr从redis库中查询返回的值。
let rtnObj; // 1.如果从redis中查到数据,则是redis中返回的数据,2.否则就是将要储存到redis中的数据。
// shaStr = await sha256(JSON.stringify(params));
// shaStr = template + "_" + shaStr + "_" + functionName;
shaStr = template + "_" + functionName;
rtn = await this.redisClient.get(shaStr);
if (params) {
var list = await this.customQuery(sql, params);
var dataCount = await this.customQuery(countSql, params);
} else {
var list = await this.customQuery(sql);
var dataCount = await this.customQuery(countSql);
}
if (optionType == "get") {
if (rtn) {
rtnObj = JSON.parse(rtn);
return rtnObj;
} else {
list.total = dataCount;
await this.redisClient.set(shaStr, JSON.stringify(list));
rtn = await this.redisClient.get(shaStr);
if (rtn) {
rtnObj = JSON.parse(rtn);
return rtnObj;
}
}
}
if (optionType == "del") {
if (rtn) {
await this.redisClient.delete(shaStr);
}
}
}
}
module.exports = MediaaggregationDao;
\ No newline at end of file
......@@ -3,7 +3,7 @@ const mediaaggregationDao = system.getObject("db.mediaaggregation.mediaaggregati
class MediaaggregationSve {
constructor() {
}
//服务列表
async productList(pobj) {
......
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