Commit 7b62ade9 by 宋毅

tj

parent de29e016
......@@ -10,58 +10,11 @@ class APIBase {
this.toolSve = system.getObject("service.trademark.toolSve");
this.exTime = 6 * 3600;//缓存过期时间,6小时
}
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, "签名验证失败");
}
return system.getResultSuccess();
}
//-----------------------新的模式------------------开始
async doexecMetho(gname, methodname, pobj, query, req) {
async doexecMethod(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 rtn = await this[methodname](pobj, query, req);
this.logCtl.createDb({
appid: req.app.id,
......
......@@ -29,16 +29,19 @@ class AccessAuthAPI extends WEBBase {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getVerifyCode"://获取默认模板的手机验证码
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
case "getUserPinByChannelUserId"://获取渠道用户userpin信息,通过userName
opResult = await this.utilsAuthSve.getUserPinByChannelUserId(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess()
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
if (opResult.status == 2060) {
return system.getResultSuccess({ userpin: opResult.data.userpin }, opResult.msg)
}
break;
case "getLoginByUserName"://通过账户登录
opResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
case "getVerifyCode"://获取默认模板的手机验证码
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
return system.getResultSuccess()
}
break;
case "userPinByLgoin"://通过账户和密码登录
......
......@@ -20,12 +20,6 @@ class WEBBase {
async doexecMethod(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 rtn = await this[methodname](pobj, query, req);
this.logCtl.createDb({
appid: req.app.id,
......
......@@ -31,15 +31,15 @@ class UtilsAuthSve extends AppServiceBase {
return result;
}
/**
* 通过账户登录
* 渠道通过账户进行登录,有则返回用户信息,没有则创建用户
* @param {*} pobj
* @param {*} actionBody {userName:XX}
* @param {*} actionBody {channelUserId:XX}
*/
async getLoginByUserName(pobj, actionBody) {//通过账户获取用户信息--------------actionBody.userName
if (!actionBody.userName) {
return system.getResult(null, "actionBody.userName can not be empty");
async getUserPinByChannelUserId(pobj, actionBody) {//渠道通过账户进行登录,有则返回用户信息,没有则创建用户---actionBody.channelUserId
if (!actionBody.channelUserId) {
return system.getResult(null, "actionBody.channelUserId can not be empty");
}
var acckapp = await this.restClient.execPost(pobj, settings.centerAppUrl() + "auth/accessAuth/getLoginByUserName");
var acckapp = await this.restClient.execPost(pobj, settings.centerAppUrl() + "auth/accessAuth/getUserPinByChannelUserId");
var result = acckapp.stdout;
if (result) {
var tmp = JSON.parse(result);
......@@ -121,9 +121,6 @@ class UtilsAuthSve extends AppServiceBase {
if (!actionBody.newPwd) {
return system.getResult(null, "pobj.newPwd can not be empty !");
}
if (!actionBody.userpin) {
return system.getResult(null, "pobj.userpin can not be empty !");
}
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !");
}
......
......@@ -87,8 +87,8 @@ module.exports = function (app) {
req.body.appInfo = result.data;
req.body.actionProcess = result.data.app_code;
var lst = [
"addOrder", "getH5PayUrl", "getOrderQrCode", "queryOrderStatus", "getOrderInfo", "getOrderDeliveryInfo","getOrderDetails",
"getOrderDeliveryFlowInfo", "getOrderDeliveryFlowList", "getOrderLogInfo", "updateContacts", "updateTmOrder","delOrder",
"addOrder", "getH5PayUrl", "getOrderQrCode", "queryOrderStatus", "getOrderInfo", "getOrderDeliveryInfo", "getOrderDetails",
"getOrderDeliveryFlowInfo", "getOrderDeliveryFlowList", "getOrderLogInfo", "updateContacts", "updateTmOrder", "delOrder",
"getNeedInfo",//---暂时没有用到
"tmConfirm", "updateTmInfo",
"updateNclInfo", "updateContacts",
......@@ -144,7 +144,7 @@ module.exports = function (app) {
var p = null;
var invokeObj = system.getObject("api." + classPath);
if (invokeObj["doexecMethod"]) {
p = invokeObj["doexecMethod"].apply(invokeObj, params);
p = invokeObj["doexecMethod"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
......@@ -181,6 +181,35 @@ module.exports = function (app) {
//-----------------------新的模式---------api---------开始
app.all("/api/*", 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;
}
var token = req.headers["token"] || "";
if (!token) {
result.msg = "req headers token can not be empty";
result.data = null;
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;
}
req.body.appInfo = result.data;
req.body.actionProcess = result.data.app_code;
next();
});
app.get('/api/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
......@@ -201,7 +230,7 @@ module.exports = function (app) {
var p = null;
var invokeObj = system.getObject("api." + classPath);
if (invokeObj["doexecMethod"]) {
p = invokeObj["doexecMethod"].apply(invokeObj, params);
p = invokeObj["doexecMethod"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
......
......@@ -33,7 +33,7 @@
```
## **<a name="pwdLogin"> 密码登录</a>**
## **<a name="pwdLogin"> 帐号密码登录</a>**
[返回到目录](#menu)
##### URL
[/web/auth/accessAuth/springBoard]
......@@ -43,7 +43,7 @@
``` javascript
{
"mobile":"15010929366", // Y 手机号
"userName":"15010929366", // Y 用户名
"password":"123456" // Y 密码
}
```
......@@ -139,8 +139,6 @@
"newPwd":"123456" // Y 新密码
"userpin":"79009f97cebf4866834ee9e863d5f9b8" // N 用户登录凭证key
}
```
......
1.获取请求token
1.获取请求token
......@@ -19,8 +19,31 @@ HTTP请求方式 POST
},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
2.查看需求方案列表信息
地址:[/#/comapnylist?needNo=XXX&userId=jfklajflsjfs&nickName=松XXX&mobile=15010929368&orgName=汉唐集团]
2.渠道通过账户进行登录,有则返回用户信息,没有则创建用户
地址:[/web/auth/accessAuth/springBoard]
请求方式:POST
请求头中需要有token(token值从接口1中获取)
{
"actionType": "getUserPinByChannelUserId",
"actionBody": {
"channelUserId":"xxxxxxxxx",// Y 渠道用户ID
"channelUserName":"",// N 渠道用户名
"mobile":"", // N 渠道用户手机号
"nickName":"", // N 用户昵称
"orgName":"" // N 公司名称
}
}
返回结果
{
"status": 0,//0成功,否则失败
"msg": "success",
"data": {userpin:"c54abe7249a2a1195d236b333f79"},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
3.查看需求方案列表信息
地址:[/#/needProxy?needNo=XXX&userId=jfklajflsjfs&nickName=松XXX&mobile=15010929368&orgName=汉唐集团]
请求方式:GET
请求头中需要有token(token值从接口1中获取)
参数说明:
......@@ -29,10 +52,10 @@ HTTP请求方式 POST
userId//用户唯一码
nickName//用户名称
mobile//用户手机号
orgName//公司名称
orgName//公司名称
3.推送公司表单材料
4.推送公司表单材料
地址:[/api/opreceive/ic/springBoard]
请求方式:POST
请求头中需要有token(token值从接口1中获取)
......@@ -53,7 +76,7 @@ HTTP请求方式 POST
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
4.推送公司状态
5.推送公司状态
地址:[/api/opreceive/ic/springBoard]
请求方式:POST
请求头中需要有token(token值从接口1中获取)
......@@ -74,7 +97,7 @@ HTTP请求方式 POST
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
4.关闭需求接口
6.关闭需求接口
地址:[/api/opreceive/need/springBoard]
请求方式:POST
请求头中需要有token(token值从接口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