Commit 68980b8d by 蒋勇

d

parents a4642df5 5315b103
...@@ -26,7 +26,8 @@ class APIBase extends DocBase { ...@@ -26,7 +26,8 @@ class APIBase extends DocBase {
"auth.getAccessKey", "auth.getAccessKey",
"meta.getBaseComp", "meta.getBaseComp",
"meta.doc", "meta.doc",
"meta.clearAllCache" "meta.clearAllCache",
"meta.upline",
]; ];
var x = lst.indexOf(fullname); var x = lst.indexOf(fullname);
return x >= 0; return x >= 0;
...@@ -55,7 +56,7 @@ class APIBase extends DocBase { ...@@ -55,7 +56,7 @@ class APIBase extends DocBase {
//检查访问token //检查访问token
var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req); var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
if (!isPassResult.ispass) { if (!isPassResult.ispass) {
var tmpResult = system.getResultFail(system.tokenFail, "访问token失效,请重新获取"); var tmpResult = system.getResultFail(system.tokenFail, "访问token失效,请重新获取");
tmpResult.requestId = ""; tmpResult.requestId = "";
return tmpResult; return tmpResult;
} }
......
...@@ -8,12 +8,19 @@ class BaseCompAPI extends APIBase { ...@@ -8,12 +8,19 @@ class BaseCompAPI extends APIBase {
super(); super();
this.cachsearchesSve = system.getObject("service.common.cachsearchesSve"); this.cachsearchesSve = system.getObject("service.common.cachsearchesSve");
} }
async upline(pobj, gobj, req){
console.log("......................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...");
console.log(JSON.stringify(pobj));
console.log("......................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...");
return system.getResult(pobj);
}
async clearAllCache(pobj, gobj, req) { async clearAllCache(pobj, gobj, req) {
return await this.cachsearchesSve.clearAllCache(pobj); return await this.cachsearchesSve.clearAllCache(pobj);
} }
async getBaseComp() { async getBaseComp() {
if (cacheBaseComp) { if (cacheBaseComp) {
return cacheBaseComp; return system.getResult(cacheBaseComp);
} }
var vuePath = settings.basepath + "/app/front/vues/base"; var vuePath = settings.basepath + "/app/front/vues/base";
var baseComps = []; var baseComps = [];
...@@ -30,8 +37,8 @@ class BaseCompAPI extends APIBase { ...@@ -30,8 +37,8 @@ class BaseCompAPI extends APIBase {
baseComps.push(comp); baseComps.push(comp);
}); });
} }
// cacheBaseComp = escape(JSON.stringify(baseComps)); cacheBaseComp = { basecom: baseComps };
return system.getResult({ basecom: baseComps }); return system.getResult(cacheBaseComp);
} }
exam() { exam() {
......
...@@ -37,8 +37,20 @@ class CacheBase { ...@@ -37,8 +37,20 @@ class CacheBase {
return JSON.parse(cacheValue); return JSON.parse(cacheValue);
} }
} }
async invalidate(inputkey){ async getCache(inputkey, ex) {
const cachekey=this.prefix+inputkey; const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null") {
return null;
} else {
if (ex) {
this.redisClient.set(cachekey, cacheValue, ex);
}
return JSON.parse(cacheValue);
}
}
async invalidate(inputkey) {
const cachekey = this.prefix + inputkey;
this.redisClient.delete(cachekey); this.redisClient.delete(cachekey);
return 0; return 0;
} }
......
...@@ -14,21 +14,27 @@ class VCodeCache extends CacheBase { ...@@ -14,21 +14,27 @@ class VCodeCache extends CacheBase {
return "缓存给手机发送的验证码60妙"; return "缓存给手机发送的验证码60妙";
} }
prefix() { prefix() {
return "g_vcode_" return "g_vcode:appkey_"
} }
async buildCacheVal(cachekey, inputkey, val, ex, ...items) { async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
//inputkey采用appkey_mobile的形式 //【XXX】您的验证码是:602639(5分钟内有效),工作人员不会索取,请勿泄露。-------描述在模板中配置
var mobile = inputkey.split("_")[1]; var pobj = val;
var tmplCode = val;
var signName = items ? items[0] : "";
var vcode = await this.smsUtil.getUidStr(6, 10); var vcode = await this.smsUtil.getUidStr(6, 10);
// var content=tmpl.replace(/\|vcode\|/g,vcode); if (pobj && pobj.reqType) {
//this.smsUtil.sendMsg(mobile,content); switch (pobj.reqType) {
if (!tmplCode && !signName) { case "defaultVcode":
this.smsUtil.sendMsg(mobile, vcode); this.smsUtil.sendMsg(pobj.mobile, vcode);
} //tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码 break;
else { case "defaultOtherVcode":
this.smsUtil.aliSendMsg(mobile, tmplCode, signName, JSON.stringify({ code: vcode })); this.smsUtil.aliSendMsg(pobj.mobile, pobj.tmplCode, pobj.signName, JSON.stringify({ code: vcode }));
break;
case "otherVcode":
this.smsUtil.aliOtherSendMsg(pobj.mobile, pobj.accessKeyId, pobj.accessKeySecret, pobj.tmplCode,
pobj.signName, JSON.stringify({ code: vcode }));
break;
default:
break;
}
} }
return JSON.stringify({ vcode: vcode }); return JSON.stringify({ vcode: vcode });
} }
......
...@@ -174,6 +174,9 @@ System.userNameLoginFail = 2020; ...@@ -174,6 +174,9 @@ System.userNameLoginFail = 2020;
System.verifyVCodeFail = 2030; System.verifyVCodeFail = 2030;
//opencode存储的值已经失效 //opencode存储的值已经失效
System.verifyOpencodeFail = 2040; System.verifyOpencodeFail = 2040;
//重复操作
System.redoFail = 2050;
module.exports = System; module.exports = System;
// rc=System.getObject("tool.restClient"); // rc=System.getObject("tool.restClient");
......
...@@ -3,6 +3,7 @@ const uuidv4 = require('uuid/v4'); ...@@ -3,6 +3,7 @@ const uuidv4 = require('uuid/v4');
class AuthUtils { class AuthUtils {
constructor() { constructor() {
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.exTime = 5 * 3600;//缓存过期时间,5小时
} }
getUUID() { getUUID() {
var uuid = uuidv4(); var uuid = uuidv4();
...@@ -16,11 +17,11 @@ class AuthUtils { ...@@ -16,11 +17,11 @@ class AuthUtils {
*/ */
async getTokenInfo(appkey, secret) { async getTokenInfo(appkey, secret) {
var rtnKey = this.getUUID(); var rtnKey = this.getUUID();
var cacheAccessKey = await this.cacheManager["ApiAccessKeyClientCache"].cache(appkey, rtnKey, 3600); var cacheAccessKey = await this.cacheManager["ApiAccessKeyCache"].cache(appkey, rtnKey, this.exTime);
if (cacheAccessKey) { if (cacheAccessKey) {
rtnKey = cacheAccessKey.accessKey; rtnKey = cacheAccessKey.accessKey;
}//获取之前的token值 }//获取之前的token值
var appData = await this.cacheManager["ApiAccessKeyCache"].cache(rtnKey, secret, 3600, appkey); var appData = await this.cacheManager["ApiAccessKeyCache"].cache(rtnKey, secret, this.exTime, appkey);
if (!appData) { if (!appData) {
return system.getResultFail(system.getAppInfoFail, "key或secret错误."); return system.getResultFail(system.getAppInfoFail, "key或secret错误.");
} }
......
...@@ -4,7 +4,7 @@ const exec = util.promisify(require('child_process').exec); ...@@ -4,7 +4,7 @@ const exec = util.promisify(require('child_process').exec);
class ExecClient { class ExecClient {
constructor() { constructor() {
this.cmdPostPattern = "curl -k -H 'Content-type: application/json' -d '{data}' {url}"; this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}";
this.cmdGetPattern = "curl -G -X GET '{url}'"; this.cmdGetPattern = "curl -G -X GET '{url}'";
} }
......
const system=require("../system"); const system = require("../system");
const Core = require('@alicloud/pop-core'); const Core = require('@alicloud/pop-core');
class SmsClient{ class SmsClient {
constructor(){ constructor() {
this.smsTeml="http://123.57.156.109:4103/api/Send"; this.smsTeml = "http://123.57.156.109:4103/api/Send";
this.restClient=system.getObject("util.restClient"); this.restClient = system.getObject("util.restClient");
this.aliclient=new Core({ this.aliclient = new Core({
accessKeyId: 'LTAI4FtNp3wcqFzaADvo1WtZ', accessKeyId: 'LTAI4FtNp3wcqFzaADvo1WtZ',
accessKeySecret: 'VBKn1Anx4UmMF0LKNz7PVaCFG1phcg', accessKeySecret: 'VBKn1Anx4UmMF0LKNz7PVaCFG1phcg',
endpoint: 'https://dysmsapi.aliyuncs.com', endpoint: 'https://dysmsapi.aliyuncs.com',
...@@ -13,7 +13,7 @@ class SmsClient{ ...@@ -13,7 +13,7 @@ class SmsClient{
} }
async aliSendMsg(to,tmplcode,signName,jsonContent){ async aliSendMsg(to, tmplcode, signName, jsonContent) {
var params = { var params = {
"RegionId": "default", "RegionId": "default",
"PhoneNumbers": to, "PhoneNumbers": to,
...@@ -31,13 +31,38 @@ class SmsClient{ ...@@ -31,13 +31,38 @@ class SmsClient{
}) })
} }
async sendMsg(to,content){ async aliOtherSendMsg(to, accessKeyId, accessKeySecret, tmplcode, signName, jsonContent) {
var txtObj ={ var params = {
"appId":8, "RegionId": "default",
"mobilePhone":to, "PhoneNumbers": to,
"content":content "SignName": signName,
"TemplateCode": tmplcode,
"TemplateParam": jsonContent
};
var requestOption = {
method: 'POST'
};
var otherAliclient = new Core({
accessKeyId: accessKeyId,
accessKeySecret: accessKeySecret,
endpoint: 'https://dysmsapi.aliyuncs.com',
apiVersion: '2017-05-25'
});
otherAliclient.request('SendSms', params, requestOption).then((result) => {
console.log(JSON.stringify(result));
}, (ex) => {
console.log(ex);
});
}
async sendMsg(to, content) {
var txtObj = {
"appId": 8,
"mobilePhone": to,
"content": content
} }
return this.restClient.execPost(txtObj,this.smsTeml); return this.restClient.execPost(txtObj, this.smsTeml);
} }
async getUidStr(len, radix) { async getUidStr(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
...@@ -60,7 +85,7 @@ class SmsClient{ ...@@ -60,7 +85,7 @@ class SmsClient{
} }
} }
module.exports=SmsClient; module.exports = SmsClient;
// var sms=new SmsClient(); // var sms=new SmsClient();
// sms.aliSendMsg("13381139519","SMS_173946419","iboss",JSON.stringify({code:"hello"})); // sms.aliSendMsg("13381139519","SMS_173946419","iboss",JSON.stringify({code:"hello"}));
...@@ -10,8 +10,13 @@ var settings = { ...@@ -10,8 +10,13 @@ var settings = {
user: "root", user: "root",
password: "123456", password: "123456",
config: { config: {
<<<<<<< HEAD
host: '192.168.4.119', host: '192.168.4.119',
port: 3306, port: 3306,
=======
host: '43.247.184.35',
port: 8899,
>>>>>>> 5315b1038a0ea78ef8d6584e1c774432afe365d1
dialect: 'mysql', dialect: 'mysql',
operatorsAliases: false, operatorsAliases: false,
pool: { pool: {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
refwhereorg:{isPosition:true}, refwhereorg:{isPosition:true},
crow:null, crow:null,
selCompanyKey:null, selCompanyKey:null,
selComid:null,
} }
}, },
mounted:function(){ mounted:function(){
...@@ -23,6 +24,8 @@ ...@@ -23,6 +24,8 @@
created:function(){ created:function(){
var cmpid=this.$router.history.current.query.compid; var cmpid=this.$router.history.current.query.compid;
this.selCompanyKey=cmpid; this.selCompanyKey=cmpid;
var cmpid2=this.$router.history.current.query.comidnum;
this.selComid=cmpid2;
}, },
methods:{ methods:{
beforesave(model){ beforesave(model){
...@@ -127,6 +130,7 @@ ...@@ -127,6 +130,7 @@
this.formatroles([orgroot.data]); this.formatroles([orgroot.data]);
expandkeys.push(orgroot.data.id); expandkeys.push(orgroot.data.id);
this.$refs.userGrid.linkInInitQuery("opath","/"); this.$refs.userGrid.linkInInitQuery("opath","/");
this.$refs.userGrid.linkInInitQuery("owner_id",this.selComid);
return resolve([orgroot.data]); return resolve([orgroot.data]);
}else{ }else{
console.log(node.level,node.id); console.log(node.level,node.id);
...@@ -190,6 +194,9 @@ ...@@ -190,6 +194,9 @@
}, },
onsel(node,data){ onsel(node,data){
this.$refs.userGrid.linkInInitQuery("opath",data.orgpath); this.$refs.userGrid.linkInInitQuery("opath",data.orgpath);
this.$refs.userGrid.linkInInitQuery("owner_id",this.selComid);
this.currentPath=data.orgpath; this.currentPath=data.orgpath;
this.$refs.orgtree.isEdit=false; this.$refs.orgtree.isEdit=false;
}, },
...@@ -279,6 +286,7 @@ ...@@ -279,6 +286,7 @@
this.orgidchageto=null; this.orgidchageto=null;
this.crow=null; this.crow=null;
this.$refs.userGrid.linkInInitQuery("opath",this.currentPath); this.$refs.userGrid.linkInInitQuery("opath",this.currentPath);
this.$refs.userGrid.linkInInitQuery("owner_id",this.selComid);
} }
} }
}, },
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
this.$router.push({path:"/comapps",query:{"compid":row.companykey}}); this.$router.push({path:"/comapps",query:{"compid":row.companykey}});
} }
if(key=="comorgs"){ if(key=="comorgs"){
this.$router.push({path:"/comorgs",query:{"compid":row.companykey}}); this.$router.push({path:"/comorgs",query:{"compid":row.companykey,"comidnum":row.id}});
} }
}, },
onColFormater(row,column,cellvalue,index){ onColFormater(row,column,cellvalue,index){
......
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