Commit 71d38fcd by 蒋勇

d

parent 00499818
#!/bin/bash #!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2 FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com" MAINTAINER jy "jiangyong@gongsibao.com"
ADD center-manage /apps/center-manage/ ADD icp-deliver /apps/icp-deliver/
WORKDIR /apps/center-manage/ WORKDIR /apps/icp-deliver/
RUN cnpm install -S RUN cnpm install -S
CMD ["node","/apps/center-manage/main.js"] CMD ["node","/apps/icp-deliver/main.js"]
......
...@@ -10,6 +10,7 @@ class AppCtl extends CtlBase { ...@@ -10,6 +10,7 @@ class AppCtl extends CtlBase {
constructor() { constructor() {
super("common", CtlBase.getServiceName(AppCtl)); super("common", CtlBase.getServiceName(AppCtl));
this.userCtl = system.getObject("service.auth.userSve"); this.userCtl = system.getObject("service.auth.userSve");
} }
async findAllApps(p, q, req) { async findAllApps(p, q, req) {
var rtns = await this.service.findAllApps(p.userid); var rtns = await this.service.findAllApps(p.userid);
...@@ -19,6 +20,40 @@ class AppCtl extends CtlBase { ...@@ -19,6 +20,40 @@ class AppCtl extends CtlBase {
let app= await this.cacheManager["AppCache"].cache(p.appkey, null); let app= await this.cacheManager["AppCache"].cache(p.appkey, null);
return system.getResult({funcJson:JSON.parse(app.functionJSON)}); return system.getResult({funcJson:JSON.parse(app.functionJSON)});
} }
async translateToRouter(funarray,results,parent){
funarray.forEach(item=>{
let result={}
result.path=item.code
result.name=item.code
result.meta={
hideInMenu: false,
hideInBread:false,
notCache: true,
title:item.title,
icon:'replaceIconName'
}
result.component="replaceRightPath"
if(parent){
parent.children.push(result)
}else{
results.push(result)
}
if(item.children && item.children.length>0){
result.children=[]
this.translateToRouter(item.children,results,result)
}
})
}
async buildFrontRouter(p,q,req){
let appkey=p.appkey
let app= await this.cacheManager["AppCache"].cache(appkey, null);
let funobj=JSON.parse(app.functionJSON)
let results=[]
await this.translateToRouter(funobj,results,null)
let rtns=await this.service.upFrontRoute(results,app.id)
await this.cacheManager["AppCache"].invalidate(appkey, null);
return system.getResult({url:rtns.url})
}
async getFuncs(p,q,req){ async getFuncs(p,q,req){
let appkey=p.appkey let appkey=p.appkey
let app= await this.cacheManager["AppCache"].cache(appkey, null); let app= await this.cacheManager["AppCache"].cache(appkey, null);
...@@ -78,3 +113,11 @@ class AppCtl extends CtlBase { ...@@ -78,3 +113,11 @@ class AppCtl extends CtlBase {
} }
} }
module.exports = AppCtl; module.exports = AppCtl;
var p={"appkey":"08cb8300-ef1e-4e35-ba49-3de36ba497d2"}
let acl=new AppCtl()
acl.buildFrontRouter(p).then(res=>{
console.log(res.data)
})
\ No newline at end of file
...@@ -15,7 +15,7 @@ module.exports = (db, DataTypes) => { ...@@ -15,7 +15,7 @@ module.exports = (db, DataTypes) => {
backend:DataTypes.STRING,//域名 backend:DataTypes.STRING,//域名
homePage: DataTypes.STRING,//首页 homePage: DataTypes.STRING,//首页
functionJSON: DataTypes.TEXT,//功能清单地址--前端通过loadJson下载数据 functionJSON: DataTypes.TEXT,//功能清单地址--前端通过loadJson下载数据
docUrl: DataTypes.STRING,//接口文档地址 docUrl: DataTypes.STRING,//前端路由配置文件
configUrl: DataTypes.STRING,//基础信息配置信息地址 configUrl: DataTypes.STRING,//基础信息配置信息地址
logoUrl: DataTypes.STRING,//应用Logo logoUrl: DataTypes.STRING,//应用Logo
bkimageUrl: DataTypes.STRING,//应用背景图 bkimageUrl: DataTypes.STRING,//应用背景图
......
...@@ -2,16 +2,32 @@ const system = require("../../../system"); ...@@ -2,16 +2,32 @@ const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
const fs=require("fs")
class AppService extends ServiceBase { class AppService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(AppService)); super("common", ServiceBase.getDaoName(AppService));
this.userS = system.getObject("service.auth.userSve"); this.userS = system.getObject("service.auth.userSve");
this.routeDao = system.getObject("db.common.routeDao"); this.routeDao = system.getObject("db.common.routeDao");
this.ossC= system.getObject("util.ossClient");
} }
async getApp(p) { async getApp(p) {
let app = this.cacheManager["AppCache"].cache(p.appkey, null); let app = this.cacheManager["AppCache"].cache(p.appkey, null);
return app; return app;
} }
async upFrontRoute(jsonObject,app_id){
var self=this
return this.db.transaction(async function (t) {
let keyfile=self.getUUID()+".json"
let tmpdirfile="/tmp"+keyfile
let str=JSON.stringify(jsonObject[0].children)
fs.writeFileSync(tmpdirfile,str)
let result=await self.ossC.upfile(keyfile,tmpdirfile)
fs.unlinkSync(tmpdirfile)
await self.db.models.app.update({docUrl:result.url,id:app_id},{where:{id:app_id},transaction:t})
return result
})
}
async findAllApps(uid) { async findAllApps(uid) {
var apps = null; var apps = null;
var dicRtn = {}; var dicRtn = {};
......
...@@ -4,8 +4,8 @@ class OSSClient{ ...@@ -4,8 +4,8 @@ class OSSClient{
constructor(){ constructor(){
this.client=new OSS({ this.client=new OSS({
endpoint: 'https://oss-cn-beijing.aliyuncs.com', endpoint: 'https://oss-cn-beijing.aliyuncs.com',
accessKeyId: 'LTAIyAUK8AD04P5S', accessKeyId: 'LTAI4GC5tSKvqsH2hMqj6pvd',
accessKeySecret: 'DHmRtFlw2Zr3KaRwUFeiu7FWATnmla' accessKeySecret: '3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5'
}); });
this.client.useBucket('gsb-zc'); this.client.useBucket('gsb-zc');
} }
......
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