Commit fcdd7d84 by 蒋勇

d

parent dd54f122
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ChannelAPI extends APIBase {
constructor() {
super();
}
async getChannels(hostname){
let cacheManager = system.getObject("db.common.cacheManager");
let channels=await cacheManager["ChannelCache"].cache(hostname)
return channels;
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
];
}
exam() {
return ``
}
}
module.exports = ChannelAPI;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ChannelCache extends CacheBase {
constructor() {
super();
this.channelDao = system.getObject("db.common.channelDao");
}
isdebug() {
return settings.env == "dev";
}
desc() {
return "缓存本地应用对象";
}
prefix() {
return "g_channel_"
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
const configValue = await this.channelDao.model.findOne(
{where: { routehost: inputkey}});
if (configValue) {
return JSON.stringify(configValue);
}
return null;
}
}
module.exports = ChannelCache;
\ No newline at end of file
......@@ -65,6 +65,7 @@ class DbFactory{
//渠道和渠道路径方法映射
this.db.models.pathtomethod.belongsTo(this.db.models.channel,{constraints: false,});
this.db.models.channel.hasMany(this.db.models.pathtomethod,as:"pts",{constraints: false,});
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon(){
......
......@@ -283,6 +283,8 @@ class UserService extends ServiceBase {
return null;
}
}
//plkey--对应消费者jwt身份的key,插件解码token后,获取iss-key,查询出身份,利用
//身份中的secret验证签名
async jwtsign(plkey, secretstr, opts) {
let promise = new Promise(function (resv, rej) {
jwt.sign({ iss: plkey }, secretstr, opts, function (err, rtn) {
......
var url = require("url");
var System = require("../../base/system");
module.exports = function (app) {
app.all("*",async function(req, res,next){
if(!channels){
next()
}else{
res.end(JSON.stringify({status:0,msg:"ok"}));
}
})
app.get('/api/:gname/:qname/:method', function (req, res) {
// var classPath = req.params["qname"];
var methodName = req.params["method"];
......
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