Commit 68980b8d by 蒋勇

d

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