Commit eaf8cd17 by linboxuan

lin add getAllService

parent 25859d1b
var APIBase = require("../../api.base"); var APIBase = require("../../api.base");
var system = require("../../../system"); var system = require("../../../system");
class AccessAuthAPI extends APIBase { class AccessAuthAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils"); this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.appmobilemsgSve = system.getObject("service.dbapp.appmobilemsgSve"); this.appmobilemsgSve = system.getObject("service.dbapp.appmobilemsgSve");
this.utilsappSve = system.getObject("service.utilsSve.utilsappSve"); this.utilsappSve = system.getObject("service.utilsSve.utilsappSve");
} }
async getOssInfo(pobj, qobj, req) {//获取oss信息 async getOssInfo(pobj, qobj, req) {//获取oss信息
var result = await this.utilsappSve.getAppOssInfo(pobj); var result = await this.utilsappSve.getAppOssInfo(pobj);
return result; return result;
} }
async getTokenByHosts(pobj, qobj, req) { async getTokenByHosts(pobj, qobj, req) {
var result = await this.opPlatformUtils.getReqTokenByHosts(pobj); var result = await this.opPlatformUtils.getReqTokenByHosts(pobj);
return result; return result;
} }
async getVerifyCodeByMoblie(pobj, qobj, req) {//获取默认模板的手机验证码 async getVerifyCodeByMoblie(pobj, qobj, req) {//获取默认模板的手机验证码
if (!pobj.actionBody.mobile) { if (!pobj.actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty !"); return system.getResult(null, "actionBody.mobile can not be empty !");
}
var itemResult = await this.appmobilemsgSve.getItemByUappId(pobj);
var result = system.getResult(null, "get msg error");
if (itemResult.status != 0) {
result = await this.opPlatformUtils.fetchDefaultVCode(pobj.actionBody.mobile, pobj.appInfo.uapp_key);
return result;
}
var param = {
mobile: pobj.actionBody.mobile,
tmplCode: itemResult.data.tmpl_code,
signName: itemResult.data.sign_name,
accessKeyId: itemResult.data.access_key_id,
accessKeySecret: itemResult.data.access_key_secret
}
result = await this.opPlatformUtils.fetchOtherVCode(param, pobj.appInfo.uapp_key);
return result;
} }
var itemResult = await this.appmobilemsgSve.getItemByUappId(pobj);
async login(pobj, qobj, req) {//通过账户和密码登录 var result = system.getResult(null, "get msg error");
if (!pobj.actionBody.userName) { if (itemResult.status != 0) {
return system.getResult(null, "actionBody.userName can not be empty !"); result = await this.opPlatformUtils.fetchDefaultVCode(pobj.actionBody.mobile, pobj.appInfo.uapp_key);
} return result;
if (!pobj.actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty !");
}
var result = await this.opPlatformUtils.getReqUserPinByLgoin(pobj);
return result;
} }
async getLoginByUserName(pobj, qobj, req) {//通过账户获取用户信息----------------------------actionBody.channelUserId var param = {
if (!pobj.actionBody.channelUserId) { mobile: pobj.actionBody.mobile,
return system.getResult(null, "actionBody.channelUserId can not be empty !"); tmplCode: itemResult.data.tmpl_code,
} signName: itemResult.data.sign_name,
var result = await this.opPlatformUtils.getLoginByUserName(pobj); accessKeyId: itemResult.data.access_key_id,
return result; accessKeySecret: itemResult.data.access_key_secret
} }
result = await this.opPlatformUtils.fetchOtherVCode(param, pobj.appInfo.uapp_key);
return result;
}
async loginByVerifyCode(pobj, qobj, req) {//通过短信登录或注册信息 async login(pobj, qobj, req) {//通过账户和密码登录
if (!pobj.actionBody.mobile) { if (!pobj.actionBody.userName) {
return system.getResult(null, "actionBody.mobile can not be empty !"); return system.getResult(null, "actionBody.userName can not be empty !");
} }
if (!pobj.actionBody.vcode) { if (!pobj.actionBody.password) {
return system.getResult(null, "actionBody.vcode can not be empty !"); return system.getResult(null, "actionBody.password can not be empty !");
}
var result = await this.opPlatformUtils.getReqUserPinByLgoinVcode(pobj);
return result;
} }
async modiPasswordByMobile(pobj, qobj, req) {//通过手机验证码修改用户密码 var result = await this.opPlatformUtils.getReqUserPinByLgoin(pobj);
var actionBody = pobj.actionBody; return result;
if (!actionBody.mobile) { }
return system.getResult(null, "actionBody.mobile can not be empty !"); async getLoginByUserName(pobj, qobj, req) {//通过账户获取用户信息----------------------------actionBody.channelUserId
} if (!pobj.actionBody.channelUserId) {
if (!actionBody.vcode) { return system.getResult(null, "actionBody.channelUserId can not be empty !");
return system.getResult(null, "actionBody.vcode can not be empty !");
}
if (!actionBody.newPwd) {
return system.getResult(null, "actionBody.newPwd can not be empty !");
}
var result = await this.opPlatformUtils.putUserPwdByMobile(pobj, actionBody);
return result;
} }
var result = await this.opPlatformUtils.getLoginByUserName(pobj);
return result;
}
async putUserMobileByVcode(pobj, qobj, req) {//通过手机验证码修改手机号、邮箱 async loginByVerifyCode(pobj, qobj, req) {//通过短信登录或注册信息
var actionBody = pobj.actionBody; if (!pobj.actionBody.mobile) {
if (!actionBody.vcode) { return system.getResult(null, "actionBody.mobile can not be empty !");
return system.getResult(null, "actionBody.vcode can not be empty !");
}
if(!pobj.userInfo){
return system.getResult(null, "userpin can not be empty !");
}
var result = await this.opPlatformUtils.putUserMobileByVcode(pobj, actionBody);
return result;
} }
async getLoginInfo(pobj, qobj, req) {//通过userpin获取用户信息 if (!pobj.actionBody.vcode) {
var actionBody = pobj.actionBody; return system.getResult(null, "actionBody.vcode can not be empty !");
if (!actionBody.userpin) {
return system.getResult(null, "actionBody.userpin can not be empty !");
}
var result = await this.opPlatformUtils.getUserLoginInfo(pobj, actionBody);
return result;
} }
async logout(pobj, qobj, req) { var result = await this.opPlatformUtils.getReqUserPinByLgoinVcode(pobj);
var result = await this.opPlatformUtils.logout(pobj); return result;
return result; }
async modiPasswordByMobile(pobj, qobj, req) {//通过手机验证码修改用户密码
var actionBody = pobj.actionBody;
if (!actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty !");
} }
async getAppInfo(pobj, qobj, req) { if (!actionBody.vcode) {
var result = await this.utilsappSve.getAppInfo(pobj); return system.getResult(null, "actionBody.vcode can not be empty !");
return result;
} }
if (!actionBody.newPwd) {
return system.getResult(null, "actionBody.newPwd can not be empty !");
}
var result = await this.opPlatformUtils.putUserPwdByMobile(pobj, actionBody);
return result;
}
/** async putUserMobileByVcode(pobj, qobj, req) {//通过手机验证码修改手机号、邮箱
* 获取所有渠道 var actionBody = pobj.actionBody;
* @returns {Promise<void>} if (!actionBody.vcode) {
*/ return system.getResult(null, "actionBody.vcode can not be empty !");
async getAllChannels(){ }
var result = await this.utilsappSve.getAllChannels(); if (!pobj.userInfo) {
return result; return system.getResult(null, "userpin can not be empty !");
} }
var result = await this.opPlatformUtils.putUserMobileByVcode(pobj, actionBody);
return result;
}
async getLoginInfo(pobj, qobj, req) {//通过userpin获取用户信息
var actionBody = pobj.actionBody;
if (!actionBody.userpin) {
return system.getResult(null, "actionBody.userpin can not be empty !");
}
var result = await this.opPlatformUtils.getUserLoginInfo(pobj, actionBody);
return result;
}
async logout(pobj, qobj, req) {
var result = await this.opPlatformUtils.logout(pobj);
return result;
}
async getAppInfo(pobj, qobj, req) {
var result = await this.utilsappSve.getAppInfo(pobj);
return result;
}
/**
* 获取所有渠道
* @returns {Promise<void>}
*/
async getAllChannels() {
var result = await this.utilsappSve.getAllChannels();
return result;
}
async getAllService() {
var result = await this.utilsappSve.getAllService();
return result;
}
} }
module.exports = AccessAuthAPI; module.exports = AccessAuthAPI;
\ No newline at end of file
...@@ -52,12 +52,12 @@ class UtilsAppSve extends AppServiceBase { ...@@ -52,12 +52,12 @@ class UtilsAppSve extends AppServiceBase {
async getAppInfo(pobj) { async getAppInfo(pobj) {
var uapp_id = pobj.uappId || ""; var uapp_id = pobj.uappId || "";
var app = await this.appDao.findOne({app_code:uapp_id}); var app = await this.appDao.findOne({ app_code: uapp_id });
if(app) { if (app) {
return system.getResultSuccess(app); return system.getResultSuccess(app);
} }
if(!app) { if (!app) {
return system.getResult(null, "渠道码错误") return system.getResult(null, "渠道码错误")
} }
} }
...@@ -65,10 +65,20 @@ class UtilsAppSve extends AppServiceBase { ...@@ -65,10 +65,20 @@ class UtilsAppSve extends AppServiceBase {
* 获取所有渠道 * 获取所有渠道
* @returns {Promise<{msg: *, data: (*|null), status: number}>} * @returns {Promise<{msg: *, data: (*|null), status: number}>}
*/ */
async getAllChannels(){ async getAllChannels() {
let sql = `SELECT DISTINCT(uapp_id),app_name FROM p_app`; let sql = `SELECT DISTINCT(uapp_id),app_name FROM p_app`;
let result = await this.appDao.customQuery(sql); let result = await this.appDao.customQuery(sql);
return system.getResultSuccess(result); return system.getResultSuccess(result);
} }
/**
* 获取所有渠道
* @returns {Promise<{msg: *, data: (*|null), status: number}>}
*/
async getAllService() {
let sql = `select uapp_id,app_hosts,app_name,\`desc\` from p_app`;
let result = await this.appDao.customQuery(sql);
return system.getResultSuccess(result);
}
} }
module.exports = UtilsAppSve; module.exports = UtilsAppSve;
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