Commit 10be319b by 宋毅

tj

parent bd7a99dc
......@@ -5,63 +5,29 @@ const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class APIBase {
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("service.common.oplogSve");
this.toolSve = system.getObject("service.trademark.toolSve");
this.exTime = 6 * 3600;//缓存过期时间,6小时
this.exTime = 2 * 3600;//缓存过期时间,2小时
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async verifySign(params, app_key) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!params.sign) {
return system.getResult(null, "请求参数sign为空");
}
if (!params.timestamp) {
return system.getResult(null, "请求参数timestamp为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResult(null, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
if (params.sign != resultTmpSign) {
return system.getResult(null, "签名验证失败");
async checkAcck(gname, methodname, pobj, query, req) {
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !!");
}
return system.getResultSuccess();
}
//-----------------------新的模式------------------开始
async doexecMethod(gname, methodname, pobj, query, req) {
async doexec(gname, methodname, pobj, query, req) {
req.requestId = this.getUUID();
try {
// //验证accesskey或验签
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (isPassResult.status != 0) {
// isPassResult.requestId = "";
// return isPassResult;
// }
var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
if (isPassResult.status != 0) {
isPassResult.requestId = "";
return isPassResult;
}
var rtn = await this[methodname](pobj, query, req);
this.logCtl.createDb({
appid: req.app.id,
......@@ -74,7 +40,7 @@ class APIBase {
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
rtn.requestId = req.requestId;
rtn.requestId = req.requestId
return rtn;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
......@@ -104,7 +70,5 @@ class APIBase {
return rtnerror;
}
}
//-----------------------新的模式------------------结束
}
module.exports = APIBase;
const system = require("../system");
const settings = require("../../config/settings");
const DocBase = require("./doc.base");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class APIBase extends DocBase {
constructor() {
super();
this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("service.common.oplogSve");
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async verifySign(params, app_key) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!params.sign) {
return system.getResult(null, "请求参数sign为空");
}
if (!params.times_tamp) {
return system.getResult(null, "请求参数times_tamp为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResult(null, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
if (params.sign != resultTmpSign) {
return system.getResult(null, "签名验证失败");
}
return system.getResultSuccess();
}
/**
* 白名单验证
* @param {*} gname 组名
* @param {*} methodname 方法名
*/
async isCheckWhiteList(gname, methodname) {
var fullname = gname + "." + methodname;
var lst = [
"test.testApi"
];
var x = lst.indexOf(fullname);
return x >= 0;
}
async checkAcck(gname, methodname, pobj, query, req) {
var appInfo = null;
var result = system.getResultSuccess();
var ispass = await this.isCheckWhiteList(gname, methodname);
var appkey = req.headers["accesskey"];
if (ispass) {
return result;
}//在百名单里面
if (appkey) {
appInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(appkey, { status: true }, 3000);
if (!appInfo || !appInfo.app) {
result.status = system.tokenFail;
result.msg = "请求头accesskey失效,请重新获取";
}
}//验证accesskey
else {
result.status = -1;
result.msg = "请求头没有相关访问参数,请验证后在进行请求";
}
return result;
}
async doexec(gname, methodname, pobj, query, req) {
var requestid = this.getUUID();
try {
//验证accesskey或验签
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (isPassResult.status != 0) {
// isPassResult.requestid = "";
// return isPassResult;
// }
var rtn = await this[methodname](pobj, query, req);
rtn.requestid = requestid;
this.logCtl.createDb({
appid: req.headers["app_id"] || "",
appkey: req.headers["accesskey"] || "",
requestId: requestid,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
return rtn;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.logCtl.error({
appid: req.headers["app_id"] || "",
appkey: req.headers["accesskey"] || "",
requestId: requestid,
op: pobj.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
optitle: "api调用出现异常,请联系管理员",
});
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
rtnerror.requestid = requestid;
return rtnerror;
}
}
}
module.exports = APIBase;
const system=require("../system");
const uuidv4 = require('uuid/v4');
class DocBase{
constructor(){
this.apiDoc={
group:"逻辑分组",
groupDesc:"",
name:"",
desc:"请对当前类进行描述",
exam:"概要示例",
methods:[]
};
this.initClassDoc();
}
initClassDoc(){
// this.descClass();
// this.descMethods();
}
descClass(){
var classDesc= this.classDesc();
this.apiDoc.group=classDesc.groupName;
this.apiDoc.groupDesc=classDesc.groupDesc;
this.apiDoc.name=classDesc.name;
this.apiDoc.desc=classDesc.desc;
this.apiDoc.exam=this.examHtml();
}
examHtml(){
var exam= this.exam();
exam=exam.replace(/\\/g,"<br/>");
return exam;
}
exam(){
throw new Error("请在子类中定义类操作示例");
}
classDesc(){
throw new Error(`
请重写classDesc对当前的类进行描述,返回如下数据结构
{
groupName:"auth",
groupDesc:"认证相关的包"
desc:"关于认证的类",
exam:"",
}
`);
}
descMethods(){
var methoddescs=this.methodDescs();
for(var methoddesc of methoddescs){
for(var paramdesc of methoddesc.paramdescs){
this.descMethod(methoddesc.methodDesc,methoddesc.methodName
,paramdesc.paramDesc,paramdesc.paramName,paramdesc.paramType,
paramdesc.defaultValue,methoddesc.rtnTypeDesc,methoddesc.rtnType);
}
}
}
methodDescs(){
throw new Error(`
请重写methodDescs对当前的类的所有方法进行描述,返回如下数据结构
[
{
methodDesc:"生成访问token",
methodName:"getAccessKey",
paramdescs:[
{
paramDesc:"访问appkey",
paramName:"appkey",
paramType:"string",
defaultValue:"x",
},
{
paramDesc:"访问secret",
paramName:"secret",
paramType:"string",
defaultValue:null,
}
],
rtnTypeDesc:"xxxx",
rtnType:"xxx"
}
]
`);
}
descMethod(methodDesc,methodName,paramDesc,paramName,paramType,defaultValue,rtnTypeDesc,rtnType){
var mobj=this.apiDoc.methods.filter((m)=>{
if(m.name==methodName){
return true;
}else{
return false;
}
})[0];
var param={
pname:paramName,
ptype:paramType,
pdesc:paramDesc,
pdefaultValue:defaultValue,
};
if(mobj!=null){
mobj.params.push(param);
}else{
this.apiDoc.methods.push(
{
methodDesc:methodDesc?methodDesc:"",
name:methodName,
params:[param],
rtnTypeDesc:rtnTypeDesc,
rtnType:rtnType
}
);
}
}
}
module.exports=DocBase;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class EnterpriseQueryAPI extends APIBase {
constructor() {
super();
this.enterSve = system.getObject("service.enterprise.enterpriseSve");
}
/**
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "gxCountByAuthor"://获取企业高薪信息数量
case "gxListByAuthor"://获取企业高薪信息列表
case "gameCountByAuthor"://获取企业游戏出版及运营数量
case "gameListByAuthor"://获取企业游戏出版及运营信息列表
case "licenseCountByAuthor"://获取企业证照信息数量
case "licenseListByAuthor"://获取企业证照信息列表
case "ipCountByAuthor"://获取企业域名信息数量
case "ipListByAuthor"://获取企业域名信息列表
case "getQccBranches"://获取企业的分支机构(从企查查获取)
case "getcountAll"://获取企业所有证照数量
opResult = await this.enterSve.opReqResult(pobj, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = EnterpriseQueryAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class LicenseQueryAPI extends APIBase {
constructor() {
super();
this.liecseSve = system.getObject("service.licenses.licenseSve");
}
/**
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getLicenses"://根据公司得到推荐要办的证书
//opResult = await this.liecseSve.getLicenses(action_body);
opResult = await this.liecseSve.opReqResult(pobj, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = LicenseQueryAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
const logCtl = system.getObject("service.common.oplogSve");
class opLog extends APIBase {
constructor() {
super();
}
async info(pobj, qobj, req) {
this.logCtl.info(pobj);
}
async error(pobj, qobj, req) {
this.logCtl.error(pobj);
}
}
module.exports = opLog;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class TmOrderAPI extends APIBase {
class OrderAPI extends APIBase {
constructor() {
super();
this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
......@@ -13,8 +13,8 @@ class TmOrderAPI extends APIBase {
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
......@@ -24,14 +24,8 @@ class TmOrderAPI extends APIBase {
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getCAProductDetail"://根据渠道产品码获取产品详情 ---应用中心
opResult = await this.utilsProductSve.getProductDetailByCode(pobj, pobj.actionBody);
break;
case "getCAProductListByTypeOneCode"://获取产品列表(根据产品一类编码获取) ---应用中心
opResult = await this.utilsProductSve.findByTypeOneCode(pobj, pobj.actionBody);
break;
case "getCAProductListByTypeCode"://获取产品列表(根据父类产品编码获取) ---应用中心
switch (action_type) {
case "getCAProductListByTypeCode"://创建订单
opResult = await this.utilsProductSve.findByTypeCode(pobj, pobj.actionBody);
break;
default:
......@@ -42,4 +36,4 @@ class TmOrderAPI extends APIBase {
}
}
module.exports = TmOrderAPI;
\ No newline at end of file
module.exports = OrderAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class PatentQueryAPI extends APIBase {
constructor() {
super();
this.patentSve = system.getObject("service.patent.patentycSve");
}
/**
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "CommomSearchbyApplicant"://根据申请人查询聚合
case "paCountByApplicantName"://根据申请人获取专利量
case "paShortListByApplicantName"://根据申请人获取专利详情列表
case "paDetailsBypubNo"://根据公开或授权号获取专利详情列表
case "paDetailsByfilingNo"://根据申请号获取专利详情列表
case "softwareCountByAuthor"://根据公司名称得到软著量
case "softwareListByAuthor"://根据公司名称得到软著详情
case "softwareDetailsByregNum"://根据登记号获取软著详情
case "worksCountByAuthor"://根据公司名称得到著作权量
case "worksListByAuthor"://根据公司名称得到著作权详情
case "worksDetailsByregNum"://根据登记号获取著作权详情
opResult = await this.patentSve.opReqResult(pobj, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = PatentQueryAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
/**
* 接收远程推送的商标数据api
*/
class ReceiveDataAPI extends APIBase {
constructor() {
super();
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
this.customerinfoSve = system.getObject("service.dborder.customerinfoSve");
this.customercontactsSve = system.getObject("service.dborder.customercontactsSve");
this.trademarkSve = system.getObject("service.dbtrademark.trademarkSve");
this.zcApiUrl = settings.reqZcApi();
this.pushFqbossDataUrl = settings.pushFqbossDataUrl();
this.pushlogSve = system.getObject("service.common.pushlogSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
return result;
}
async opActionProcess(action_process, action_type, action_body, pobj, req) {
// var logParam = {
// appid: req.app.id,
// appkey: req.app.uappKey,
// requestId: req.requestId || "",
// op: "/igirl-channel/zhichan/igirl-channel/app/base/api/impl/action/receiveData.js/opActionProcess",
// content: "参数信息:" + JSON.stringify(action_body),
// clientIp: pobj.clientIp,
// optitle: "接收推送过来的数据处理=>action_type=" + action_type,
// };
var opResult = null;
switch (action_type) {
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
logParam.resultInfo = JSON.stringify(opResult);
this.logCtl.info(logParam);
return opResult;
}
}
module.exports = ReceiveDataAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmQueryAPI extends APIBase {
constructor() {
super();
// this.tmqueryApi = system.getObject("api.trademark.tmqueryApi");
this.tmquerySve = system.getObject("service.trademark.tmquerySve");
// this.toolApi = system.getObject("api.tool.toolApi");
this.toolSve = system.getObject("service.trademark.toolSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "findTrademarkNameAccurate"://商标精确检索(相同商标检索)
opResult = await this.tmquerySve.findTrademarkNameAccurate(action_body, req);
break;
case "findTrademarkName"://近似商标检索
opResult = await this.tmquerySve.findTrademarkName(action_body, req);
break;
case "findTrademarkzchAccurate"://商标申请号检索
opResult = await this.tmquerySve.findTrademarkzchAccurate(action_body, req);
break;
case "findTrademarkzcr"://申请人查询
opResult = await this.tmquerySve.findTrademarkzcr(action_body, req);
break;
case "getCropperPic"://获取检索图片url
opResult = await this.toolSve.getCropperPic(action_body, req);
break;
case "imagequery"://图形检索
opResult = await this.tmquerySve.imagequery(action_body, req);
break;
case "findImageSearch"://图形检索查询
opResult = await this.tmquerySve.findImageSearch(action_body, req);
break;
case "tradeMarkDetail"://商标详情查询
opResult = await this.tmquerySve.tradeMarkDetail(action_body, req);
break;
case "sbzuixinsearch"://最新商标查询
opResult = await this.tmquerySve.sbzuixinsearch(action_body, req);
break;
case "noticequeryTMZCSQ"://近12期初审公告查询接口
opResult = await this.tmquerySve.noticequeryTMZCSQ(action_body, req);
break;
case "noticequery"://公告列表检索接口
opResult = await this.tmquerySve.noticequery(action_body, req);
break;
case "noticezcggsearch"://注册公告详情查询
opResult = await this.tmquerySve.noticezcggsearch(action_body, req);
break;
case "noticesearch"://初审公告详情查询
opResult = await this.tmquerySve.noticesearch(action_body, req);
break;
case "getCompanyInfoNoUser"://企业查询
opResult = await this.tmquerySve.getCompanyInfoNoUser(action_body, req);
break;
case "getNclDetail"://尼斯详情
opResult = await this.tmquerySve.getNclDetail(action_body, req);
break;
case "gettwoNcl"://获取尼斯群组
opResult = await this.tmquerySve.gettwoNcl(action_body, req);
break;
case "nclFuwuSearch"://尼斯分类检索
opResult = await this.tmquerySve.nclFuwuSearch(action_body, req);
break;
case "bycznfx"://商标智能分析 -----
opResult = await this.toolSve.bycznfx(action_body, req);
break;
case "tmConfirm"://商标方案确认
// opResult = await this.toolApi.bycznfx(action_body);
opResult = system.getResultSuccess(null, "商标方案确认成功");
break;
case "icheming"://商标智能分析 -----
opResult = await this.toolSve.icheming(action_body, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmQueryAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmToolsAPI extends APIBase {
constructor() {
super();
this.toolSve = system.getObject("service.trademark.toolSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "encryptStr"://
opResult = await this.toolSve.encryptStr(req.app, action_body.opStr);
break;
case "decryptStr"://
opResult = await this.toolSve.decryptStr(req.app, action_body.opStr);
break;
case "getOssConfig"://
opResult = await this.toolSve.getOssConfig();
break;
case "getNcl"://尼斯查询(一)
opResult = await this.toolSve.getNcl(action_body, req);
break;
case "getNclByLikeNameAndNcl"://尼斯查询(二)
opResult = await this.toolSve.getNclByLikeNameAndNcl(action_body, req);
break;
case "word2pic"://文字转图片
opResult = await this.toolSve.word2pic(action_body, req);
break;
case "uploadStandardTm"://商标样式转换
opResult = await this.toolSve.uploadStandardTm(action_body, req);
break;
case "pic2pdf"://图片转pdf
opResult = await this.toolSve.pic2pdf(action_body, req);
break;
case "getCompanyInfoByLikeName"://企业近似查询
opResult = await this.toolSve.getCompanyInfoByLikeName(action_body, req);
break;
case "getEntregistryByCompanyName"://企业精确查询
opResult = await this.toolSve.getEntregistryByCompanyName(action_body, req);
break;
case "adjustWTSSize"://调整委托书
opResult = await this.toolSve.adjustWTSSize(action_body, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmToolsAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmTransactionAPI extends APIBase {
constructor() {
super();
this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
}
/**
* 接口跳转-POST请求
* actionProcess 执行的流程
* actionType 执行的类型
* actionBody 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.action_type) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "addOrder"://添加订单
opResult = await this.orderinfoSve.createOrder(action_body, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmTransactionAPI;
\ No newline at end of file
......@@ -8,14 +8,14 @@ class TradetransferAPI extends APIBase {
this.aliclient = system.getObject("util.aliyunClient");
this.execlient = system.getObject("util.execClient");
this.transferurl = settings.reqTransferurl();
this.corderSve = system.getObject("service.dbcorder.orderinfoSve");
this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
}
//订单创建
async createtransfer(p, obj, req) {
console.log(p.actionBody, "actionBody...............................");
var orderinfo = await this.corderSve.createOrder(p.actionBody, req);
var orderinfo = await this.orderinfoSve.createOrder(p.actionBody, req);
console.log(orderinfo, "orderinfo............................");
if (orderinfo) {
if (orderinfo.status == "0") {
......
var APIBase = require("../../api.base");
var system = require("../../../system");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = system.getResult(null, "req Failure");
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getVerifyCode":
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess()
}
break;
case "loginUserByChannelUserId":
opResult = await this.utilsAuthSve.loginUserByChannelUserId(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByLgoin":
opResult = await this.utilsAuthSve.getReqUserPinByLgoin(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByLgoinVcode":
pobj.actionBody.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByRegister":
pobj.actionBody.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "logout":
opResult = await this.utilsAuthSve.userLogout(pobj, pobj.actionBody);
break;
case "putUserPwdByMobile":
opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async getAppTokenByHosts(pobj, qobj, req) {
var token = this.getUUID();
pobj.actionBody.reqType = "hosts";
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async getAppTokenByAppKey(pobj, qobj, req) {
var token = this.getUUID();
pobj.actionBody.reqType = "appkey";
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class PaymentAPI extends APIBase {
constructor() {
super();
this.execlient = system.getObject("util.execClient");
this.centerAppUrl = settings.centerAppUrl();
}
/**
* 接口跳转-POST请求
* actionProcess 执行的流程
* actionType 执行的类型
* actionBody 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, action_type, action_body, req) {
var opResult = null;
var url = "";
switch (action_type) {
// sy
case "getQrCode"://pc端订单支付二维码生成
url = this.centerAppUrl + "payment/paymentApi/getQrCode";
break;
case "queryOrder"://通联支付查询
url = this.centerAppUrl + "payment/paymentApi/queryOrder";
break;
case "receiveCallBackNotify"://通联支付查询
url = this.centerAppUrl + "payment/paymentApi/receiveCallBackNotify";
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
if (url) {
opResult = system.getResultSuccess(null, "action_type参数错误");
}
var opResultstr = await this.execlient.execPost(pobj, url);
opResult = JSON.parse(opResultstr.stdout)
return opResult;
}
}
module.exports = PaymentAPI;
\ No newline at end of file
const System = require("../../../system");
var settings = require("../../../../config/settings");
const querystring = require('querystring');
const AppServiceBase = require("../../app.base");
class EnterpriseService extends AppServiceBase {
constructor() {
super();
this.zcApiUrl = settings.reqZcApi();
};
async opReqResult(pobj, req) {
var url = this.zcApiUrl + "action/enterpriseQuery/springBoard";
var result = await this.restPostUrl(pobj, url);
return result;
};
}
module.exports = EnterpriseService;
\ No newline at end of file
const System = require("../../../system");
var settings = require("../../../../config/settings");
const querystring = require('querystring');
const AppServiceBase = require("../../app.base");
class LicenseService extends AppServiceBase {
constructor() {
super();
this.zcApiUrl = settings.reqZcApi();
};
async opReqResult(pobj, req) {
var url = this.zcApiUrl + "action/licenseQuery/springBoard";
var result = await this.restPostUrl(pobj, url);
return result;
};
}
module.exports = LicenseService;
\ No newline at end of file
const System = require("../../../system");
var settings = require("../../../../config/settings");
const querystring = require('querystring');
const AppServiceBase = require("../../app.base");
class PatentycService extends AppServiceBase {
constructor() {
super();
this.zcApiUrl = settings.reqZcApi();
};
async opReqResult(pobj, req) {
var url = this.zcApiUrl + "action/patentQuery/springBoard";
var result = await this.restPostUrl(pobj, url);
return result;
}
}
module.exports = PatentycService;
const system=require("../../../system");
var settings=require("../../../../config/settings");
class bigtmService {
constructor(){
this.GsbByTmSearchApi=system.getObject("api.tmquery.bytmsearch");
}
}
module.exports=bigtmService;
// var test = new TmqueryService();
// test.bigtmcompanyjuhe({status:3,tmreg_year:2018,seltype:1,apply_addr_province:""}).then(function(d){
// console.log("#################################");
// console.log(d);
// })
const system=require("../../../system");
var settings=require("../../../../config/settings");
class BytmmonitService {
constructor(){
}
}
module.exports=BytmmonitService;
// var test = new TmqueryService();
// test.bigtmcount({tmreg_year:2018,apply_addr_province:""}).then(function(d){
// console.log("#################################");
// console.log(d);
// })
const system = require("../../../system");
var settings = require("../../../../config/settings");
const crypto = require('crypto');
const cryptoJS = require("crypto-js");
var fs = require("fs");
// var AWS = require('aws-sdk');
var ak = "D0784B08541791E175B544D5317281B0";
var sk = "93AB12B3BFADB1356EC078D52B064A33";
var ossurl = "https://hangtang.s3.cn-north-1.jdcloud-oss.com";
class JdossService {
constructor() {
this.execClient = system.getObject("util.execClient");
}
async getJdOssConfig(app, opStr) {
var date = new Date();
var month = date.getMonth()+1;
month=month.toString();
if(month<10){
month="0"+month;
}
var day = date.getDate().toString();
if(day<10){
day="0"+day;
}
var time = date.getFullYear().toString()+month+day;
let timestamp = date.getTime();//当前的时间戳
timestamp = timestamp + 6 * 60 * 60 * 1000;
//格式化时间获取年月日
var dateAfter = new Date(timestamp);
var policyText = {
"expiration": dateAfter,
"conditions": [
{"bucket": "hangtang"},
["starts-with", "$key", "zc"],
{"Content-Type": "image/jpeg"},
{"X-Amz-Credential": ak+"/"+time+"/cn-north-1/s3/aws4_request"},
{"X-Amz-Algorithm": "AWS4-HMAC-SHA256"},
{"X-Amz-Date": date}
]
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature = crypto.createHmac('sha256', sk).update(policyBase64).digest("hex");
var data = {
"OSSAccessKeyId":ak,
"Bucket":"hangtang",
"Signature":signature,
"policy": policyBase64,
"success_action_status": 201,
"x-amz-algorithm":"AWS4-HMAC-SHA256",
"x-amz-credential":ak+"/"+time+"/cn-north-1/s3/aws4_request",
"x-amz-date":date,
"x-amz-signature":signature,
"url": ossurl
};
return system.getResultSuccess(data);
}
}
module.exports = JdossService;
const system = require("../../../system");
var settings = require("../../../../config/settings");
class TmqueryService {
constructor() {
this.zcApiUrl = settings.reqZcApi();
this.execClient = system.getObject("util.execClient");
}
async findTrademarkNameAccurate(queryobj, req) {//通过商标名来进行精准查询
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkNameAccurate";
return await this.opReqResult(url, queryobj, req);
}
async findTrademarkNameIndex(queryobj, req) {//根据商标名称模糊查询,首次查询,
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkNameIndex";
return await this.opReqResult(url, queryobj, req);
}
async findTrademarkName(queryobj, req) {//根据商标名称模糊查询
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkName";
return await this.opReqResult(url, queryobj, req);
}
async findTrademarkzchAccurate(queryobj, req) {//通过商标号来进行精准查询
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkzchAccurate";
return await this.opReqResult(url, queryobj, req);
}
async findTrademarkzcr(queryobj, req) {//通过注册人模糊查询
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkzcr";
return await this.opReqResult(url, queryobj, req);
}
async imagequery(queryobj, req) {//图像检索
var url = this.zcApiUrl + "api/trademark/tmqueryApi/imagequery";
return await this.opReqResult(url, queryobj, req);
}
async findImageSearch(queryobj, req) { //图像检索查询,
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findImageSearch";
return await this.opReqResult(url, queryobj, req);
}
async tradeMarkDetail(queryobj, req) {//商标详情
var url = this.zcApiUrl + "api/trademark/tmqueryApi/tradeMarkDetail";
return await this.opReqResult(url, queryobj, req);
}
async sbzuixinsearch(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/sbzuixinsearch";
return await this.opReqResult(url, queryobj, req);
}
async noticequeryTMZCSQ(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/noticequeryTMZCSQ";
return await this.opReqResult(url, queryobj, req);
}
async noticequery(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/noticequery";
return await this.opReqResult(url, queryobj, req);
}
async noticezcggsearch(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/noticezcggsearch";
return await this.opReqResult(url, queryobj, req);
}
async noticesearch(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/noticesearch";
return await this.opReqResult(url, queryobj, req);
}
async getCompanyInfoNoUser(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/getCompanyInfoNoUser";
return await this.opReqResult(url, queryobj, req);
}
async getNclDetail(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/getNclDetail";
return await this.opReqResult(url, queryobj, req);
}
async gettwoNcl(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/gettwoNcl";
return await this.opReqResult(url, queryobj, req);
}
async nclFuwuSearch(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/nclFuwuSearch";
return await this.opReqResult(url, queryobj, req);
}
async opReqResult(reqUrl, queryobj, req) {
var rtn = await this.execClient.execPushDataPost(queryobj, reqUrl, req.headers["token"], req.headers["request-id"]);
var data = JSON.parse(rtn.stdout);
return data;
}
}
module.exports = TmqueryService;
const system = require("../../../system");
var settings = require("../../../../config/settings");
const crypto = require('crypto');
const cryptoJS = require("crypto-js");
var fs = require("fs");
var accesskey = 'DHmRtFlw2Zr3KaRwUFeiu7FWATnmla';
var accessKeyId = 'LTAIyAUK8AD04P5S';
var url = "https://gsb-zc.oss-cn-beijing.aliyuncs.com";
class ToolService {
constructor() {
this.zcApiUrl = settings.reqZcApi();
this.execClient = system.getObject("util.execClient");
}
async getCropperPic(obj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getCropperPic";
return await this.opReqResult(url, obj, req);
}
//智能分析 bycquerytm.html
async bycznfx(obj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/bycznfx";
return await this.opReqResult(url, queryobj, req);
}
//根据尼斯编号获取尼斯子类,尼斯树节点点击时触发调用
async getNcl(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getNcl";
return await this.opReqResult(url, queryobj, req);
}
//根据大类、名称查询尼斯信息
async getNclByLikeNameAndNcl(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getNclByLikeNameAndNcl";
return await this.opReqResult(url, queryobj, req);
}
//文字转图片
async word2pic(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/word2pic";
return await this.opReqResult(url, queryobj, req);
}
//商标样式转换 彩色商标图样转黑白,调整图样宽高,生成符合商标局规范的标准商标图样
async uploadStandardTm(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/uploadStandardTm";
return await this.opReqResult(url, queryobj, req);
}
//营业执照(身份证明)图片文件转为符合商标局要求的pdf文件
async pic2pdf(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/pic2pdf";
return await this.opReqResult(url, queryobj, req);
}
//企业近似查询
async getCompanyInfoByLikeName(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getCompanyInfoByLikeName";
return await this.opReqResult(url, queryobj, req);
}
//企业注册信息查询
async getEntregistryByCompanyName(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getEntregistryByCompanyName";
return await this.opReqResult(url, queryobj, req);
}
//调整委托书 调整委托书大小使其符合商标局规范
async adjustWTSSize(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/adjustWTSSize";
return await this.opReqResult(url, queryobj, req);
}
//工商核名
async icheming(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/icheming";
return await this.opReqResult(url, queryobj, req);
}
async opReqResult(reqUrl, queryobj, req) {
var rtn = await this.execClient.execPushDataPost(queryobj, reqUrl, req.headers["token"], req.headers["request-id"]);
var data = JSON.parse(rtn.stdout);
return data;
}
async getOssConfig(queryobj, req) {
var policyText = {
"expiration": "2119-12-31T16:00:00.000Z",
"conditions": [
["content-length-range", 0, 1048576000],
["starts-with", "$key", "zc"]
]
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature = crypto.createHmac('sha1', accesskey).update(policyBase64).digest().toString('base64'); //base64
var data = {
OSSAccessKeyId: accessKeyId,
policy: policyBase64,
Signature: signature,
Bucket: 'gsb-zc',
success_action_status: 201,
url: url
};
return system.getResultSuccess(data);
};
//加密信息
async encryptStr(app, opStr) {
if (!opStr) {
return system.getResult(null, "opStr is empty");
}
let keyHex = cryptoJS.enc.Utf8.parse(app.uappKey);
let ivHex = cryptoJS.enc.Utf8.parse(app.appSecret.substring(0, 8));
var cipherStr = cryptoJS.TripleDES.encrypt(opStr, keyHex, { iv: ivHex }).toString();
return system.getResultSuccess(cipherStr);
}
//解密信息
async decryptStr(app, opStr) {
if (!opStr) {
return system.getResult(null, "opStr is empty");
}
let keyHex = cryptoJS.enc.Utf8.parse(app.uappKey);
let ivHex = cryptoJS.enc.Utf8.parse(app.appSecret.substring(0, 8));
var bytes = cryptoJS.TripleDES.decrypt(opStr, keyHex, {
iv: ivHex
});
var plaintext = bytes.toString(cryptoJS.enc.Utf8);
return system.getResultSuccess(plaintext);
}
}
module.exports = ToolService;
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const logCtl = system.getObject("service.common.oplogSve");
//商标查询操作
class UtilsAuthSve extends AppServiceBase {
constructor() {
super();
this.centerAppUrl = settings.centerAppUrl();
}
async loginUserByChannelUserId(pobj, actionBody) {
var opResult = null;
switch (pobj.actionProcess) {
case "gsbhome":
opResult = await this.getDefaultUserInfo(pobj, actionBody);
break;
default:
opResult = system.getResult(null, "action_process参数错误");
break;
}
return opResult;
}
async getDefaultUserInfo(pobj, actionBody) {
if (!actionBody.channelUserId) {
return system.getResult(null, "actionBody.channelUserId can not be empty");
}
var result = await this.cacheManager["AppUserPinByChannelUserId"].cache(actionBody.userpin, pobj, system.exTime);
return result;
}
//---------------登录-----------------------------------------------------
async getReqTokenByHosts(actionBody, tokenValue) { //获取token
if (["hosts", "appkey"].indexOf(actionBody.reqType) < 0) {
return system.getResult(null, "actionBody.reqType is error");
}
if (actionBody.reqType == "hosts") {
if (!actionBody.appHosts) {
return system.getResult(null, "actionBody.appHosts can not be empty");
}
}
if (actionBody.reqType == "appkey") {
if (!actionBody.appkey) {
return system.getResult(null, "actionBody.appkey can not be empty");
}
if (!actionBody.secret) {
return system.getResult(null, "actionBody.secret can not be empty");
}
}
var result = await this.cacheManager["AppTokenByHostsCache"].cache(tokenValue, actionBody, system.exTime);
return result;
}
async getReqUserPinByLgoin(pobj, actionBody) {
if (!actionBody.userName) {
return system.getResult(null, "actionBody.userName can not be empty");
}
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
var result = await this.cacheManager["AppUserPinByLoginPwdCache"].cache(actionBody.userpin, pobj, system.exTime);
return result;
}
async getReqUserPinByLgoinVcode(pobj, actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty");
}
if (!actionBody.vcode) {
return system.getResult(null, "actionBody.vcode can not be empty");
}
if (actionBody.reqType == "reg") {
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
}
var result = await this.cacheManager["AppUserPinByLoginVcodeCache"].cache(actionBody.userpin, pobj, system.exTime);
return result;
}
async getVerifyCodeByMoblie(pobj, actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty !");
}
return await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/getVerifyCodeByMoblie");
}
async putUserPwdByMobile(pobj, actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "pobj.mobile can not be empty !");
}
if (!actionBody.vcode) {
return system.getResult(null, "pobj.vcode can not be empty !");
}
if (!actionBody.newPwd) {
return system.getResult(null, "pobj.newPwd can not be empty !");
}
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !");
}
var result = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/modiPasswordByMobile");
if (result.status == 0 && actionBody.userpin) {
this.userLogout(pobj, actionBody);
}
return result;
}
async userLogout(pobj, actionBody) {
console.log(actionBody.userpin);
if (!actionBody.userpin) {
return system.getResult(null, "actionBody.userpin can not be empty !");
}
var cacheManager = system.getObject("db.common.cacheManager");
var userinfo = await this.cacheManager["AppUserPinByLoginPwdCache"].cache(actionBody.userpin, pobj, system.exTime);
if(userinfo.data){
pobj.actionBody.userName=userinfo.data.channel_username;
}else{
return system.getResultSuccess();
}
await cacheManager["AppUserPinByLoginVcodeCache"].invalidate(actionBody.userpin);
await cacheManager["AppUserPinByLoginPwdCache"].invalidate(actionBody.userpin);
var applogout=await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/logout");
return applogout;
}
}
module.exports = UtilsAuthSve;
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
//商标查询操作
class UtilsProductSve extends AppServiceBase {
constructor() {
super();
}
//--------------------------------应用中心获取产品信息-start-----------------------------------------------------
/**
* 根据产品类型码获取产品列表
* @param {*} actionBody
*/
async findByTypeCode(pobj, actionBody) {
if (!actionBody.typeCode) {
return system.getResult(null, "actionBody.typeCode can not be empty");
}
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.restPostUrl(pobj, url);
}
/**
* 根据产品类型码获取产品列表
* @param {*} actionBody
*/
async findByTypeOneCode(pobj, actionBody) {
if (!actionBody.typeOneCode) {
return system.getResult(null, "actionBody.typeOneCode can not be empty");
}
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.restPostUrl(pobj, url);
}
/**
* 获取产品详情
* @param {*} obj
*/
async getProductDetailByCode(pobj, actionBody) {
if (!actionBody.channelItemCode) {
return system.getResult(null, "actionBody.channelItemCode can not be empty");
}
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.restPostUrl(pobj, url);
}
//--------------------------------应用中心获取产品信息--end----------------------------------------------------
}
module.exports = UtilsProductSve;
var url=require("url");
var qr=require("qr-image")
module.exports = function (app) {
app.get('/api/qc', function(req,res){
var params = url.parse(req.url,true);
var detailLink = params.query.detailLink;
try {
var img = qr.image(detailLink,{size :10});
console.log(detailLink)
res.writeHead(200, {'Content-Type': 'image/png'});
img.pipe(res);
} catch (e) {
res.writeHead(414, {'Content-Type': 'text/html'});
res.end('<h1>414 Request-URI Too Large</h1>');
}
});
};
var url = require("url");
var system = require("../../base/system");
// var userSve = system.getObject("service.auth.userSve");
module.exports = function (app) {
//-----------------------新的模式------------------开始
app.all("/web/*", async function (req, res, next) {
var result = system.getResult(null, "req method must is post");
if (req.method != "POST") {
res.end(JSON.stringify(result));
return;
}
if (!req.body.actionType) {
result.msg = "actionType can not be empty";
res.end(JSON.stringify(result));
return;
}
if (["getAppTokenByHosts", "getAppTokenByAppKey"].indexOf(req.body.actionType) >= 0) {
req.body.actionBody.appHosts = req.host;
next();
return;
}
if (req.body.actionType == "receiveCallBackNotify") {
req.body.actionBody.app_hosts = req.host;
next();
return;
}
var token = req.headers["token"] || "";
if (!token) {
result.msg = "req headers token can not be empty";
res.end(JSON.stringify(result));
return;
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
if (result.status != 0) {
res.end(JSON.stringify(result));
return result;
}
req.body.appInfo = result.data;
req.body.actionProcess = result.data.app_code;
var lst = [
"subTmOrder", "getTmOrderList",
"getTmOrderInfo", "getTmApplyInfo",
"getTmNclList", "getNeedInfo",
"tmConfirm", "updateTmInfo",
"updateNclInfo", "updateContacts",
"updateCustomerInfo", "addOrderAndDelivery",
"updateOrderPayStatus"
];
if (lst.indexOf(req.body.actionType) >= 0) {
var userpin = req.headers["userpin"] || "";
if (!userpin) {
result.status = system.noLogin;
result.msg = "req headers userpin can not be empty";
res.end(JSON.stringify(result));
return;
} else {
var result = await cacheManager["AppUserPinByChannelUserId"].getCache(userpin, system.exTime);
if (result.status != 0) {
result.status = system.noLogin;
result.msg = "user login is invalidation";
res.end(JSON.stringify(result));
return result;
}
req.body.userInfo = result.data;
}
}//需要用户登录
next();
});
app.get('/web/:gname/:qname/:method', function (req, res) {
app.get('/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
classPath = gname + "." + classPath;
var tClientIp = system.get_client_ip(req);
req.clientIp = tClientIp;
......@@ -87,14 +20,14 @@ module.exports = function (app) {
params.push(req);
var p = null;
var invokeObj = system.getObject("api." + classPath);
if (invokeObj["doexecMethod"]) {
p = invokeObj["doexecMethod"].apply(invokeObj, params);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
app.post('/web/:gname/:qname/:method', function (req, res) {
app.post('/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
......@@ -113,13 +46,11 @@ module.exports = function (app) {
params.push(req);
var p = null;
var invokeObj = system.getObject("api." + classPath);
if (invokeObj["doexecMethod"]) {
p = invokeObj["doexecMethod"].apply(invokeObj, params);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
//-----------------------新的模式------------------结束
};
var url = require("url");
var system = require("../../base/system");
var fs = require('fs');
var marked = require("marked");
module.exports = function (app) {
app.get('/doc', function (req, res) {
var path = process.cwd() + "/app/front/entry/public/apidoc/README.md";
fs.readFile(path, function(err, data){
if(err){
console.log(err);
res.send("文件不存在!");
} else{
console.log(data);
str = marked(data.toString());
res.render('apidoc',{str});
}
});
});
app.get('/doc/:forder', function (req, res) {
var path = process.cwd() + "/app/front/entry/public/apidoc/README.md";
fs.readFile(path, function(err, data){
if(err){
console.log(err);
res.send("文件不存在!");
} else{
console.log(data);
str = marked(data.toString());
res.render('apidoc',{str});
}
});
});
app.get('/doc/api/:forder/:fileName', function (req, res) {
var forder = req.params["forder"];
var fileName = req.params["fileName"] || "README.md";
var path = process.cwd() + "/app/front/entry/public/apidoc";
if(forder) {
path = path + "/" + forder + "/" + fileName;
} else {
path = path + "/" + fileName;
}
fs.readFile(path, function(err, data){
if(err){
console.log(err);
res.send("文件不存在!");
} else{
console.log(data);
str = marked(data.toString());
console.log(str);
res.render('apidoc',{str});
}
});
});
};
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="keywords" content="api文档">
<meta name="baidu-site-verification" content="lATAxZAm8y" />
<meta name="viewport" content="width=device-width, initial-scale=0.8, maximum-scale=0.8, user-scalable=1">
<link href="https://cdn.bootcss.com/github-markdown-css/2.8.0/github-markdown.min.css" rel="stylesheet">
</head>
<body>
<div style="width:100%;text-align: center;font-size: 20px;">
渠道接入API文档
</div>
<div class="markdown-body" style="margin-left:40px;" id="doc-page">
<%- str%>
</div>
</body>
</html>
\ No newline at end of file
## 调用接口方式
### (一). 业务接口地址不需要进行修改
  1 [获取app信息](doc/api/appDesc/demoDesc.md#appParams)
  2 [获取token信息](doc/api/appDesc/demoDesc.md#getToken)
  3 [通用接口示例](doc/api/appDesc/demoDesc.md#demo)
### (二). 业务接口地址前面都加/web,且actionProcess参数可以不用填写
  1 [获取token信息](doc/api/appDesc/newDemoDesc.md#getToken)
  2 [通用接口示例](doc/api/appDesc/newDemoDesc.md#demo)
## ------------------以下为业务接口-------------------------
## 1. 商标操作相关接口
  1 [商标操作中心](doc/api/opTrademark/opTm.md)
## 2. 商标检索相关接口
  1 [商标检索中心](doc/api/opTrademark/tmSearch.md)
## 3. 支付相关接口
  1 [支付中心](doc/api/paymentDesc/payment.md)
## 4. 用户中心相关接口
  1 [用户中心](doc/api/user/user.md)
## 5. 专利检索接口
  1 [专利检索](doc/api/patentDesc/patent.md)
## 6. 证照相关接口
  1 [证照相关推荐](doc/api/licensesDesc/license.md)
\ No newline at end of file
<a name="menu" href="/doc">返回主目录</a>
1. [获取app信息](#appParams)
1. [获取token](#getToken)
1. [通用接口示例](#demo)
## **<a name="appParams"> 获取app信息</a>**
[返回到目录](#menu) <a name="menu" href="/doc">返回主目录</a>
#### 请求接口之前需要向合作方获取如下参数:
#### appkey:2019090811
#### secret:f99d413b767f09b5dff0b3610366cc46
#### 参数说明:appkey、secret为获取请求头token的参数。
## **<a name="getToken"> 获取token</a>**
[返回到目录](#menu) <a name="menu" href="/doc">返回主目录</a>
##### URL
[/auth/accessAuth/getToken]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"appkey": "2019090811", //Y string appkey
"secret": "f99d413b767f09b5dff0b3610366cc46"//Y string 密钥
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"token": "40d64e586551405c9bcafab87266bc04" //token用于其他接口请求时,放在请求头中
},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
```
## **<a name="demo"> 通用接口示例</a>**
[返回到目录](#menu) <a name="menu" href="/doc">返回主目录</a>
##### URL
[/auth/accessAuth]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
所有请求接口在请求前,必须获取token,并把token放在请求头Headers中,无特殊说明请求方式统一为POST请求。
通用请求接口示例:
请求头中需要传递的参数:tokenrequest-id
请求参数:
{
"actionProcess": "jd", //Y string 执行的渠道名称
"actionType": "demo", //Y string 渠道执行的类型
"actionBody": { //N JSON 要传递的body信息
"userId": "019101116473600000", //N string 用户ID
"userName": "张三" //N string 用户名称
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"opDesc": "京东云合作"
},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
返回值参数说明:
status 返回状态,0为成功,否则为失败
msg 成功或失败信息描述
data 接口返回的数据信息
requestId 请求头中的request-id,作为接口调用跟踪
```
<a name="menu" href="/doc">返回主目录</a>
1. [获取token](#getToken)
1. [通用接口示例](#demo)
## **<a name="getToken"> 获取token</a>**
[返回到目录](#menu) <a name="menu" href="/doc">返回主目录</a>
##### URL
[/web/auth/accessAuth/getAppTokenByHosts]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"actionType":"getAppTokenByHosts",//固定写法就行
"actionBody":{}
}
```
##### 或
##### URL
[/web/auth/accessAuth/getAppTokenByAppKey]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"actionType":"getAppTokenByAppKey",//固定写法就行
"actionBody":{
"appkey": "2019090811", //Y string appkey
"secret": "f99d413b767f09b5dff0b3610366cc46"//Y string 密钥
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"token": "40d64e586551405c9bcafab87266bc04" //token用于其他接口请求时,放在请求头中
},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
```
## **<a name="demo"> 通用接口示例(创建渠道用户信息)</a>**
[返回到目录](#menu) <a name="menu" href="/doc">返回主目录</a>
##### URL
[/web/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
所有请求接口在请求前,必须获取token,并把token放在请求头Headers中,无特殊说明请求方式统一为POST请求。
通用请求接口示例:
请求头中需要传递的参数:token
请求参数:
{
"actionType": "loginUserByChannelUserId", //Y string 渠道执行的类型
"actionBody": {
"channelUserId":"sy-test" //Y string 渠道用户ID
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"userpin": "3440126a4a6e4c2d890a818d5d1dd1e9"//用户登录后的userpin
},
"requestId": "1596022b5f654379899e6b113a473d2e"
}
返回值参数说明:
status 返回状态,0为成功,否则为失败
msg 成功或失败信息描述
data 接口返回的数据信息
requestId 请求头中的request-id,作为接口调用跟踪
```
<a name="menu" href="/doc">返回主目录</a>
1. [pc端订单支付二维码生成](#paypc)
## **<a name="paypc"> 订单支付</a>**
[返回到目录](#menu)
##### URL
[/api/payment/paymentApi/getQrCode]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:paypc
``` javascript
{
"uapp_id": "1", //平台渠道ID
"order_num": "1", //支付单号
"total_fee": "1",   //支付金额  分
"body_desc": "1",    //产品名称
"opType": "1", // 支付方式  alipay阿里  wx微信
}
```
#### 返回结果
```javascript
{
"status": 0,  //0 成功 小于0  失败
"msg": "SUCCESS",
"data": {
"payinfo": "https://syb.allinpay.com/apiweb/h5unionpay/native?key=l6lfPuHDErJrTW%2FN7WxSlg4n", //二维码url
"reqsn": "dfghrtjjn_1",  ////商户订单号_appid
"chnltrxid": "112094120001042656", // 支付渠道交易单号,如支付宝,微信平台的交易单号
"trxid": "112094120001042656",  // 交易单号,平台的交易流水号
"trxstatus": "0000"   // 交易状态,0000:交易成功、1001:交易不存在、
},
"requestId": "058244807fff4ab388bbda79afc04b28"
  }
```
<a name="menu" href="/doc">返回主目录</a>
1. [短信验证码](#smsCode)
1. [密码登录](#pwdLogin)
1. [验证码登录](#userPinByLgoinVcode)
1. [用户注册](#userPinByRegister)
1. [按照手机号和验证码修改密码](#putUserPwdByMobile)
1. [退出](#logout)
## **<a name="smsCode"> 短信验证码</a>**
[返回到目录](#menu)
##### URL
[/web/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:getVerifyCode
``` javascript
{
"mobile":"15010929366" // Y 手机号
}
```
#### 返回结果
```javascript
{
"status": 0, // 0为成功,否则失败
"msg": "success",
"data": null,
"requestId": "4f3ea2afee3542f88d6b938394af84d8"
}
```
## **<a name="pwdLogin"> 密码登录</a>**
[返回到目录](#menu)
##### URL
[/web/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:userPinByLgoin
``` javascript
{
"mobile":"15010929366", // Y 手机号
"password":"123456" // Y 密码
}
```
#### 返回结果
``` javascript
{
"status": 0,// 0为成功,2010为账户或密码错误,2060为重复登录,否则失败
"msg": "success",
"data": {
"userpin": "230ecdf3333944ff834f56fba10a02aa" //用户登录后的凭证,增、删、改、查、涉及用户的需要传递此值在请求头中
},
"requestId": "1b12b0e9c190436da000386ddf693c8f"
}
```
## **<a name="userPinByLgoinVcode"> 验证码登录</a>**
[返回到目录](#menu)
##### URL
[/web/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:userPinByLgoinVcode
``` javascript
{
"mobile":"15010929366", // Y 手机号
"vcode":"593555" // Y 验证码
}
```
#### 返回结果
``` javascript
{
"status": 0,// 0为成功,2030为验证码错误,2060为重复登录,否则失败
"msg": "success",
"data": {
"userpin": "230ecdf3333944ff834f56fba10a02aa" //用户登录后的凭证,增、删、改、查、涉及用户的需要传递此值在请求头中
},
"requestId": "1b12b0e9c190436da000386ddf693c8f"
}
```
## **<a name="userPinByRegister"> 用户注册</a>**
[返回到目录](#menu)
##### URL
[/web/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:userPinByRegister
``` javascript
{
"mobile":"15010929366", // Y 手机号
"vcode":"593555", // Y 验证码
"password":"123456" // Y 密码
}
```
#### 返回结果
``` javascript
{
"status": 0,// 0为成功,2030为验证码错误,2060为重复登录,否则失败
"msg": "success",
"data": {
"userpin": "230ecdf3333944ff834f56fba10a02aa" //用户登录后的凭证,增、删、改、查、涉及用户的需要传递此值在请求头中
},
"requestId": "1b12b0e9c190436da000386ddf693c8f"
}
```
## **<a name="putUserPwdByMobile"> 按照手机号和验证码修改密码</a>**
[返回到目录](#menu)
##### URL
[/web/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:putUserPwdByMobile
``` javascript
{
"mobile":"15010929366", // Y 手机号
"vcode":"593555", // Y 验证码
"newPwd":"123456" // Y 新密码
"userpin":"79009f97cebf4866834ee9e863d5f9b8" // N 用户登录凭证key
}
```
#### 返回结果
``` javascript
{
"status": 0,// 0为成功,2030为验证码错误,否则失败
"msg": "success",
"data": null,
"requestId": "1b12b0e9c190436da000386ddf693c8f"
}
```
## **<a name="logout"> 退出</a>**
[返回到目录](#menu)
##### URL
[/web/auth/accessAuth/springBoard]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 渠道执行的类型 actionType:logout
``` javascript
{
"userpin":"15010929366" // Y 用户登录凭证key
}
```
#### 返回结果
``` javascript
{
"status": 0,// 0为成功,否则失败
"msg": "success",
"data": null,
"requestId": "1b12b0e9c190436da000386ddf693c8f"
}
```
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