Commit 6a708d5d by 宋毅

tj

parent b43c73cd
......@@ -12,7 +12,13 @@ class APIBase {
async doexecMethod(gname, methodname, pobj, query, req) {
try {
if (!pobj.actionBody) {
pobj.actionBody = {};
}
var result = await this[methodname](pobj, query, req);
if (!result) {
result = system.getResult(null, "请求的方法返回值为空");
}
result.requestId = await this.getBusUid("scz");
if ("LOGS-SYTXPUBLIC-MSGQ" != settings.queuedName) {
pobj.actionBody.resultInfo = result;
......@@ -22,10 +28,11 @@ class APIBase {
}
return result;
} catch (e) {
console.log(e.stack, "api.base调用出现异常,请联系管理员..........");
var rtnerror = system.getResultFail(-200, "出现异常,error:" + e.stack);
var stackStr = e.stack ? e.stack : JSON.stringify(e);
console.log(stackStr, "api.base调用出现异常,请联系管理员..........");
var rtnerror = system.getResultFail(-200, "出现异常,error:" + stackStr);
pobj.actionBody.requestId = await this.getBusUid("err");
pobj.actionBody.errorInfo = e.stack;
pobj.actionBody.errorInfo = stackStr;
pobj.actionBody.opTitle = ",reqPath:" + req.path;
this.esUtils.addEsLogs(settings.queuedName + "apidoexec-error", pobj.actionBody);
return rtnerror;
......
const APIBase = require("../../api.base");
const system = require("../../../system");
const settings = require("../../../../config/settings")
class TestDataAPI extends APIBase {
constructor() {
super();
this.redisClient = system.getObject("util.redisClient");
this.configInfoDao = system.getObject("db.opLogs.configInfoDao");
}
/**
* 接口跳转-POST请求
* actionType 执行的功能模块
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
var tmpList = await this.configInfoDao.getList();
console.log(tmpList, ".........configInfoDao...............");
// for (let index = 0; index < 10; index++) {
// var num = index * 100;
// var tmpList = { "retcode": index, "msg": ("sy-success" + index.toString()), "sy-data": { "pageSize": 10, "curPage": 1, "search": {}, "orderArr": null, "total": 6, "rows": [{ "id": 1, "need_num": "N202006031601654", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 2, "need_num": "N202006031601655", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 3, "need_num": "N202006031601656", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 4, "need_num": "N202006031601657", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 5, "need_num": "N202006031601658", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": null, "isRefusal": null }, { "id": 6, "need_num": "N202006031601659", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": null, "isRefusal": null }] }, "requestId": "" };
// this.redisClient.zaddSortedSet("FAIL-" + settings.queuedName, num, tmpList);
// console.log(index, "..index................");
// }
// var tmpList = await this.redisClient.zrangeList("FAIL-" + settings.queuedName, 200, 200);
// var tmpList1 = await this.redisClient.zremrangebyscoreData("FAIL-" + settings.queuedName, 200, 200);
// var tmpList2 = await this.redisClient.zrangeList("FAIL-" + settings.queuedName, 200, 200);
// for (let index = 0; index < 1000000; index++) {
// var tmpList = { "retcode": index, "msg": "success", "data": { "pageSize": 10, "curPage": 1, "search": {}, "orderArr": null, "total": 6, "rows": [{ "id": 1, "need_num": "N202006031601654", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 2, "need_num": "N202006031601655", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 3, "need_num": "N202006031601656", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 4, "need_num": "N202006031601657", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 5, "need_num": "N202006031601658", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": null, "isRefusal": null }, { "id": 6, "need_num": "N202006031601659", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": null, "isRefusal": null }] }, "requestId": "" };
// this.redisClient.setDelayEventData(settings.queuedName, tmpList, 120);
// console.log(index, "..index................");
// }
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
// var result = await this.opActionType(pobj, pobj.actionType, req);
// return result;
}
async opActionType(pobj, actionType, req) {
var opResult = null;
switch (actionType) {
case "test":
var tmpParam = {
actionType: "test",
actionBody: pobj.actionBody
}
opResult = await this.execPostByTimeOut(tmpParam, "http://192.168.1.189:4012/api/test/testApi/springBoard"
, null, { token: "123456", userId: "sy123" });
break;
default:
opResult = system.getResult(null, "actionType参数错误");
break;
}
return opResult;
}
}
module.exports = TestDataAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class ProducerAPI extends APIBase {
constructor() {
super();
this.utilsTxCosSve = system.getObject("service.utilsSve.utilsTxCosSve");
}
async getCosInfo(pobj, qobj, req) {
var result = await this.utilsTxCosSve.getCosInfo();
return result;
}
}
module.exports = ProducerAPI;
\ No newline at end of file
const system = require("../../../system");
const AppServiceBase = require("../../app.base");
const { TXCOSCONFIG } = require("../../../../config/platform");
const COSSTS = require('qcloud-cos-sts');
//用户权限操作
class UtilsTxCosService extends AppServiceBase {
constructor() {
super();
this.configInfoDao = system.getObject("db.opLogs.configInfoDao");
}
/**
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async getCosInfo() {
var result = null;
if (TXCOSCONFIG.allowPrefix === '_ALLOW_DIR_/*') {
result = system.getResult(null, "请修改 allowPrefix 配置项,指定允许上传的路径前缀");
return result;
}
var configInfoResult = await this.configInfoDao.getList();
if (configInfoResult.status != 1) {
result = system.getResult(null, "db-configInfo list is empty");
return result;
}
var cosSecretId = configInfoResult.data.filter(f => f.c_key === "cosSecretId");
var cosSecretKey = configInfoResult.data.filter(f => f.c_key === "cosSecretKey");
var cosBucket = configInfoResult.data.filter(f => f.c_key === "cosBucket");
var cosRegion = configInfoResult.data.filter(f => f.c_key === "cosRegion");
var cosProxy = configInfoResult.data.filter(f => f.c_key === "cosProxy");
if (!cosSecretId || !cosSecretKey || !cosBucket || !cosRegion) {
result = system.getResult(null, "db-configInfo,cos info is empty");
return result;
}
// 获取临时密钥
var LongBucketName = cosBucket[0].c_value;
var ShortBucketName = LongBucketName.substr(0, LongBucketName.lastIndexOf('-'));
var AppId = LongBucketName.substr(LongBucketName.lastIndexOf('-') + 1);
var policy = {
'version': '2.0',
'statement': [{
'action': TXCOSCONFIG.allowActions,
'effect': 'allow',
'resource': [
'qcs::cos:' + cosRegion[0].c_value + ':uid/' + AppId + ':prefix//' + AppId + '/' + ShortBucketName + '/' + TXCOSCONFIG.allowPrefix,
],
}],
};
var startTime = Math.round(Date.now() / 1000);
var getParam = await new Promise(function (resv, rej) {
COSSTS.getCredential({
secretId: cosSecretId[0].c_value,
secretKey: cosSecretKey[0].c_value,
proxy: cosProxy ? cosProxy[0].c_value || "" : "",
region: cosRegion[0].c_value,
durationSeconds: TXCOSCONFIG.durationSeconds,
policy: policy,
}, function (err, tempKeys) {
if (err) {
rej(err);
} else {
resv(tempKeys);
}
});
});
result = getParam ? system.getResultSuccess(getParam) : system.getResult(null, "获取cos信息失败");
return result;
}
}
module.exports = UtilsTxCosService;
......@@ -25,9 +25,10 @@ module.exports = function (app) {
req.objs = system;
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
//跨域允许的请求方式
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
// res.header('Access-Control-Allow-Credentials', 'true');
if (req.method == 'OPTIONS') {
res.header('Access-Control-Allow-Credentials', 'true');
if (req.method.toLowerCase() == 'options') {
res.send(200); //让options请求快速返回/
}
else {
......
module.exports = {
TXCOSCONFIG: {
durationSeconds: 1800,
// 允许操作(上传)的对象前缀,可以根据自己网站的用户登录态判断允许上传的目录,例子: user1/* 或者 * 或者a.jpg
// 请注意当使用 * 时,可能存在安全风险,详情请参阅:https://cloud.tencent.com/document/product/436/40265
// allowPrefix: '_ALLOW_DIR_/*',
allowPrefix: '*',
// 密钥的权限列表
allowActions: [
// 所有 action 请看文档 https://cloud.tencent.com/document/product/436/31923
// 简单上传
'name/cos:PutObject',
'name/cos:PostObject',
// 分片上传
'name/cos:InitiateMultipartUpload',
'name/cos:ListMultipartUploads',
'name/cos:ListParts',
'name/cos:UploadPart',
'name/cos:CompleteMultipartUpload'
],
}
}
\ No newline at end of file
......@@ -4,20 +4,15 @@ module.exports = function (app) {
//-----------------------新的模式---------api---------开始
app.all("/api/*", async function (req, res, next) {
if (req.path === "/api/uploadAction/txCos/getCosInfo") {
next();
return;
}
var result = system.getResult(null, "req method must is post");
if (req.method != "POST") {
res.end(JSON.stringify(result));
return;
}
// if (["getAppTokenByHosts", "getAppTokenByAppKey"].indexOf(req.body.actionType) >= 0) {
// req.body.actionBody.appHosts = req.host;
// next();
// return;
// }
// if (req.path.indexOf("/taskapi/") >= 0) {
// next();
// return;
// }
if (!req.body.actionType) {
result.msg = "actionType can not be empty";
res.end(JSON.stringify(result));
......
......@@ -44,6 +44,7 @@
"nodemailer": "^6.3.0",
"pinyin": "^2.9.0",
"puppeteer": "^1.20.0",
"qcloud-cos-sts": "^3.0.2",
"qr-image": "^3.2.0",
"sequelize": "^4.37.8",
"sequelize-cli": "^4.1.1",
......
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