Commit f08f1ec0 by 王栋源

wdy

parent c9dc7756
......@@ -2,10 +2,12 @@ const system = require("../system");
const settings = require("../../config/settings");
const moment = require('moment');
const uuid = require('uuid');
const sha256 = require('sha256');
class APIBase {
constructor() {
this.execClient = system.getObject("util.execClient");
this.redisClient = system.getObject("util.redisClient");
this.userCenterAction = {
"GetOverviewInfoByUser": "getOverviewInfoByUser",
"GetOrderList": "getOrderList",
......@@ -15,7 +17,7 @@ class APIBase {
"GetApplyListByUserAndType": "getApplyListByUserAndType",
"GetApplyAndSolutionInfo": "getApplyAndSolutionInfo",
"GetPriceDetail": "selPrice2TX",
"GetOverviewInfoByUser": "getOverviewInfoByUser",
// "GetOverviewInfoByUser": "getOverviewInfoByUser",
"SubmitGoodsInfo": "submitGoodsinfo",
"SubmitNeed": "needSubmit",
"GetNeedList": "needList",
......@@ -27,6 +29,15 @@ class APIBase {
"SendVerificationCode": "sendVerificationCode",
"CheckBusinessNameList": "checkBusinessNameList",
};
this.queryAction = [
"GetOrderList","getOrderList","GetOverviewInfoByUser","getOverviewInfoByUser","GetOrderList","getOrderList",
"GetQualificationCertificateOrderList","getQcOrderList","GetQcOrderList","GetOrderDetail","getOrderDetail",
"GetApplyListByUserAndType","getApplyListByUserAndType","GetApplyAndSolutionInfo","getApplyAndSolutionInfo",
"GetPriceDetail","getPriceDetail","GetNeedList","getNeedList","GetNeedDetail","getNeedDetail","GetOrderListByStatus",
"getOrderListByStatus","GetQualificationCertificateListByUserAndType","getQualificationCertificateListByUserAndType",
"GetQualificationCertificateDetail","getQualificationCertificateDetail"
];
}
//-----------------------新的模式------------------开始
......@@ -46,6 +57,14 @@ class APIBase {
}
console.log(JSON.stringify(reqParams), "....req......base......");
try {
var shaStr = await sha256(JSON.stringify(reqParams));
//查询缓存
if(this.queryAction.indexOf(reqParams.actionType)>=0){
var cacheRes = await this.redisClient.getCache(shaStr);
if(cacheRes){
return JSON.parse(cacheRes);
}
}
var result = await this[methodname](reqParams, query, req);
if (!result) {
result = system.getResult(null, "请求的方法返回值为空");
......@@ -57,6 +76,9 @@ class APIBase {
result = await this.handleTxResult(result);
delete req.body["Action"];
}//处理tx返回数据
//保存缓存
await this.redisClient.setWithEx(shaStr, JSON.stringify(result), 5);
return result;
} catch (error) {
var stackStr = error.stack ? error.stack : JSON.stringify(error);
......
......@@ -78,7 +78,7 @@ class NeedInfoService extends ServiceBase {
return system.getResultFail(-203, "servicer is empty");
}
if (!serviceinfo.data.is_enabled) {
return system.getResultFail(-300, "servicer isn't enable");
return system.getResultFail(-300, "servicer isnt enable");
}
actionBody.ServicerCode = serviceinfo.data.servicer_code;
actionBody.ServicerName = serviceinfo.data.servicer_name;
......
......@@ -160,7 +160,7 @@ class NeedSolutionService extends ServiceBase {
path_code: needInfo.dataValues.consult_type,
region_id: needInfo.dataValues.region_id
}
var serviceinfo = await this.needInfoDao.findServiceByProductType(urlobj);
var serviceinfo = await self.needInfoDao.findServiceByProductType(urlobj);
if (serviceinfo.status < 0) {
return system.getResultFail(-203, "servicer is empty");
}
......
......@@ -646,7 +646,7 @@ class OrderInfoService extends ServiceBase {
return system.getResultFail(-203, "txproduct is empty");
}
if (!txproductinfo.data.is_enabled) {
return system.getResultFail(-300, "servicer isn't enable");
return system.getResultFail(-300, "servicer isnt enable");
}
var txobj = {
"version": "1.0",
......
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