Commit d25877b7 by 庄冰

aaa

parent 980034a5
......@@ -260,42 +260,51 @@ class MediaaggregationDao extends Dao {
async redisInfo(sql, countSql, optionType, functionName, params = "") {
var template = "mediaaggregation";
let shaStr; // 将linkObj转为字符串并计算出sha256的值
let rtn; // 根据shaStr从redis库中查询返回的值。
let rtnObj = {
total: 0,//总记录条数
rows: []
};
// 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.rows = JSON.parse(rtn);
rtnObj.total = dataCount && dataCount.length > 0 ? dataCount[0].dataCount : 0;
return rtnObj;
} else {
rtnObj.rows = list;
rtnObj.total = dataCount && dataCount.length > 0 ? dataCount[0].dataCount : 0;
await this.redisClient.set(shaStr, JSON.stringify(rtnObj));
rtn = await this.redisClient.get(shaStr);
if (rtn) {
return rtnObj;
}
}
}
if (optionType == "del") {
await this.redisClient.delete(shaStr);
}
var list = await this.customQuery(sql);
var dataCount = await this.customQuery(countSql);
rtnObj.rows = list;
rtnObj.total = dataCount && dataCount.length > 0 ? dataCount[0].dataCount : 0;
return rtnObj;
// var template = "mediaaggregation";
// let shaStr; // 将linkObj转为字符串并计算出sha256的值
// let rtn; // 根据shaStr从redis库中查询返回的值。
// let rtnObj = {
// total: 0,//总记录条数
// rows: []
// };
// // 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.rows = JSON.parse(rtn);
// rtnObj.total = dataCount && dataCount.length > 0 ? dataCount[0].dataCount : 0;
// return rtnObj;
// } else {
// rtnObj.rows = list;
// rtnObj.total = dataCount && dataCount.length > 0 ? dataCount[0].dataCount : 0;
// await this.redisClient.set(shaStr, JSON.stringify(rtnObj));
// rtn = await this.redisClient.get(shaStr);
// if (rtn) {
// return rtnObj;
// }
// }
// }
// if (optionType == "del") {
// await this.redisClient.delete(shaStr);
// }
}
}
module.exports = MediaaggregationDao;
\ 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