Commit eaf8cd17 by linboxuan

lin add getAllService

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