Commit 6fd0109a by 宋毅

tj

parent 0cff6407
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
}
/**
* 接口跳转-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 "getNeedUserPinByChannelUserId"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
//获取需求信息
pobj.actionType = "getItemByNeedNo";
var needResult = await this.utilsNeedSve.getItemByNeedNo(pobj, pobj.actionBody);
if (needResult.status != 0) {
return needResult;
}
opResult.data.channelTypeCode = needResult.data.channelTypeCode;
opResult.data.typeCode = needResult.data.typeCode
break;
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
opResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (opResult.status != 0 && opResult.status != 2060) {
return opResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (opResult.status == 2060) {
opResult.msg = opResult.msg;
opResult.data.userpin = opResult.data.userpin;
}
break;
case "getVerifyCode"://获取默认模板的手机验证码
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess()
}
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 "putUserPwdByMobile"://通过手机验证码修改用户密码
opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody);
break;
case "getLoginInfo"://通过userpin获取用户登录信息
opResult = await this.utilsAuthSve.getLoginInfo(pobj, pobj.actionBody);
break;
case "logout"://用户退出
opResult = await this.utilsAuthSve.userLogout(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
......@@ -14,7 +14,7 @@ class UtilsOpOrderService extends AppServiceBase {
}
var reqUrl = this.centerOrderUrl + "opaction/opOrder/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
this.opUpdatePushInfo(result, pobj, actionBody, "pushUpdateContacts");
this.opUpdatePushInfo(result, pobj, actionBody, "pushUpdateOrderContacts");
result.data = null;
return result;
}
......@@ -42,7 +42,7 @@ class UtilsOpOrderService extends AppServiceBase {
channel_nickname: pobj.userInfo.channel_nickname
};
delete result.data["orderStatus"];
this.utilsPushSve.pushInfo(result.data, opType, 1);
this.utilsPushSve.pushOrderInfo(result.data, opType, 1);
}
}
}
......
......@@ -79,16 +79,13 @@ class UtilsOrderService extends AppServiceBase {
return verifyResult;
}
pobj.actionType = "getProductInterface";
pobj.actionBody.productPriceId = pobj.actionBody.product_info.price_item.id;
pobj.actionBody.product_id = pobj.actionBody.product_info.id;
var productItemInterfaceResult = await this.restPostUrl(pobj, url);
// if (productItemInterfaceResult.status != 0) {
// return productItemInterfaceResult;
// }
pobj.actionBody.product_info.interface_info = productItemInterfaceResult.data;
pobj.actionType = "addOrder";
var reqUrl = this.centerOrderUrl + "action/order/springBoard";
console.log(pobj);
// console.log(pobj);
var result = await this.restPostUrl(pobj, reqUrl);
result.totalSum = actionBody.totalSum;
return result;
......@@ -444,8 +441,8 @@ class UtilsOrderService extends AppServiceBase {
channel_username: opResult.data.order_info.channelUserId,
channel_nickname: opResult.data.order_info.channelUserId
};
// this.utilsPushSve.pushInfo(opResult.data, "pushBusiness",0);
this.utilsPushSve.pushInfo(opResult.data, "pushOrder", 0);
// this.utilsPushSve.pushOrderInfo(opResult.data, "pushOrderBusiness",0);
this.utilsPushSve.pushOrderInfo(opResult.data, "pushOrder", 0);
}
opResult.data = null;
return opResult;
......
......@@ -7,7 +7,7 @@ class UtilsPushService extends AppServiceBase {
super();
this.pushlogSve = system.getObject("service.common.pushlogSve");
};
async pushInfo(actionBody, opType, isDelProductInfo) {
async pushOrderInfo(actionBody, opType, isDelProductInfo) {
var interface_list = actionBody.product_info.interface_info;
if (!interface_list) {
return "";
......
......@@ -183,6 +183,11 @@ module.exports = function (app) {
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) {
result.msg = "actionType can not be empty";
res.end(JSON.stringify(result));
......
1.获取请求token
1.获取请求token
1.获取请求token
[/web/auth/accessAuth/getAppTokenByAppKey]
[/api/auth/accessAuth/getAppTokenByAppKey]
请求方式:POST
参数格式 JSON
HTTP请求方式 POST
......@@ -20,35 +20,8 @@ HTTP请求方式 POST
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
2.渠道通过账户进行登录,有则返回用户信息,没有则创建用户
地址:[/web/auth/accessAuth/springBoard]
请求方式:POST
请求头中需要有token(token值从接口1中获取)
{
"actionType": "getNeedUserPinByChannelUserId",
"actionBody": {
"needNo":"N2020021413152wiWI2e",// Y 需求号
"channelUserId":"15010929366",// Y 渠道用户ID
"channelUserName":"",// N 渠道用户名
"mobile":"15010929366", // N 渠道用户手机号
"nickName":"", // N 用户昵称
"orgName":"" // N 公司名称
}
}
返回结果
{
"status": 0,//0成功,否则失败
"msg": "success",
"data": {
"userpin":"c54abe7249a2a1195d236b333f79",
"channelTypeCode":"",//阿里公司注册编码:普通公司注册:esp.companyreg、云上公司注册:esp.companyreg_cloud
"typeCode":"gszc"//gszc公司注册,ysgszc云上公司注册
},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
3.渠道通过账户进行登录,有则返回用户信息,没有则创建用户
地址:[/web/auth/accessAuth/springBoard]
3.渠道通过账户进行登录,有则返回用户信息,没有则创建用户------>供后端调用
地址:[/api/opreceive/accessAuth/springBoard]
请求方式:POST
请求头中需要有token(token值从接口1中获取)
{
......@@ -83,7 +56,6 @@ HTTP请求方式 POST
orgName//公司名称
token//token值
4.推送公司表单材料
地址:[/api/opreceive/ic/springBoard]
请求方式:POST
......@@ -142,4 +114,33 @@ HTTP请求方式 POST
"msg": "success",
"data": null,
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
2.渠道通过账户进行登录,有则返回用户信息,没有则创建用户---->供前端调用
地址:[/web/auth/accessAuth/springBoard]
请求方式:POST
请求头中需要有token(token值从接口1中获取)
{
"actionType": "getNeedUserPinByChannelUserId",
"actionBody": {
"needNo":"N2020021413152wiWI2e",// Y 需求号
"channelUserId":"15010929366",// Y 渠道用户ID
"channelUserName":"",// N 渠道用户名
"mobile":"15010929366", // N 渠道用户手机号
"nickName":"", // N 用户昵称
"orgName":"" // N 公司名称
}
}
返回结果
{
"status": 0,//0成功,否则失败
"msg": "success",
"data": {
"userpin":"c54abe7249a2a1195d236b333f79",
"channelTypeCode":"",//阿里公司注册编码:普通公司注册:esp.companyreg、云上公司注册:esp.companyreg_cloud
"typeCode":"gszc"//gszc公司注册,ysgszc云上公司注册
},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
\ 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