Commit 553674c0 by 蒋勇

d

parent ddb0b99d
...@@ -23,6 +23,7 @@ class UserCtl extends CtlBase { ...@@ -23,6 +23,7 @@ class UserCtl extends CtlBase {
async exit(pobj, qobj, req) { async exit(pobj, qobj, req) {
} }
//注册时,分为两种类型,一种是普通pr,一种是租户
async pmregister(pobj, qobj, req) { async pmregister(pobj, qobj, req) {
//平台注册设置平台的应用ID //平台注册设置平台的应用ID
pobj.app_id=settings.pmappid; pobj.app_id=settings.pmappid;
......
...@@ -10,16 +10,17 @@ var dbf=system.getObject("db.common.connection"); ...@@ -10,16 +10,17 @@ var dbf=system.getObject("db.common.connection");
var db=dbf.getCon(); var db=dbf.getCon();
db.sync({force:true}).then(async ()=>{ db.sync({force:true}).then(async ()=>{
const apps=await system.getObject("service.common.appSve"); const apps=await system.getObject("service.common.appSve");
const usS=await system.getObject("service.auth.userSve");
let appnew=await apps.create( { let appnew=await apps.create( {
"name":"center-app", "name":"center-app",
"domainName":"t9.com", "domainName":"t9.com",
"backend":"cm.com" "backend":"192.168.4.1"
}); });
let Role=db.models["role"]; let Role=db.models["role"];
await Role.create({code:"ta",name:"租户",app_id:appnew.id,company_id:settings.pmcompanyid}) await Role.create({code:"ta",name:"租户",app_id:appnew.id,company_id:settings.pmcompanyid})
await Role.create({code:"pr",name:"个人",app_id:appnew.id,company_id:settings.pmcompanyid}) await Role.create({code:"pr",name:"个人",app_id:appnew.id,company_id:settings.pmcompanyid})
const us=await system.getObject("service.auth.userSve");
let usuper=await us.pmregister({userName:"sm",password:"951753",isSuper:true,isAdmin:true,isEnabled:true,nickName:"superman",app_id:appnew.id,company_id:settings.id}) let usuper=await usS.pmregister({userName:"sm",password:"951753",isSuper:true,isAdmin:true,isEnabled:true,nickName:"superman",app_id:appnew.id,company_id:settings.id})
......
...@@ -7,6 +7,10 @@ module.exports = (db, DataTypes) => { ...@@ -7,6 +7,10 @@ module.exports = (db, DataTypes) => {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: false, allowNull: false,
},//和user的from相同,在注册user时,去创建 },//和user的from相同,在注册user时,去创建
companykey: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
...@@ -49,20 +49,16 @@ class AppService extends ServiceBase { ...@@ -49,20 +49,16 @@ class AppService extends ServiceBase {
async create(pobj, qobj, req) { async create(pobj, qobj, req) {
var self = this; var self = this;
return this.db.transaction(async function (t) { return this.db.transaction(async function (t) {
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
var app = await self.dao.create(pobj, t); var app = await self.dao.create(pobj, t);
//创建后台应用服务 //创建后台应用服务
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
let svobj=await self.cjsonregister(AppService.newServiceUrl(),{name:app.name,url:"http://"+app.backend}) let svobj=await self.cjsonregister(AppService.newServiceUrl(),{name:app.name,url:"http://"+app.backend})
//添加路由 //添加路由
let routeobj=await self.cjsonregister(AppService.newRouteUrl(app.name),{name:app.name,hosts:[app.domainName]}) let routeobj=await self.cjsonregister(AppService.newRouteUrl(app.name),{name:app.name,hosts:[app.domainName]})
let routeapi=await self.cjsonregister(AppService.newRouteUrl(app.name),{name:app.name+"_api",hosts:[app.domainName],paths:["/api"],strip_path:false}) let routeapi=await self.cjsonregister(AppService.newRouteUrl(app.name),{name:app.name+"_api",hosts:[app.domainName],paths:["/api"],strip_path:false})
let r1=await self.routeDao.create({name:app.name,center_id:routeobj.id},t); let r1=await self.routeDao.create({name:app.name,center_id:routeobj.id},t);
let r2=await self.routeDao.create({name:app.name+"_api",center_id:routeapi.id},t); let r2=await self.routeDao.create({name:app.name+"_api",center_id:routeapi.id},t);
//给api路由启动插件 //给api路由启动插件
await self.cjsonregister(AppService.bindPluginUrl(app.name+"_api"),{name:"jwt"}) await self.cjsonregister(AppService.bindPluginUrl(app.name+"_api"),{name:"jwt"})
if(svobj && routeobj && r1 && r2){ if(svobj && routeobj && r1 && r2){
try{ try{
app.appkey=svobj.id; app.appkey=svobj.id;
......
...@@ -4,7 +4,7 @@ const settings = require("../../../../config/settings"); ...@@ -4,7 +4,7 @@ const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
class RouteService extends ServiceBase { class RouteService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(AppService)); super("common", ServiceBase.getDaoName(RouteService));
} }
//创建应用 //创建应用
......
const system = require("../system"); const system = require("../system");
var moment = require('moment'); var moment = require('moment');
const settings = require("../../config/settings"); const settings = require("../../config/settings");
const uuidv4 = require('uuid/v4');
class ServiceBase { class ServiceBase {
constructor(gname, daoName) { constructor(gname, daoName) {
//this.dbf=system.getObject("db.connection"); //this.dbf=system.getObject("db.connection");
this.db = system.getObject("db.common.connection").getCon(); this.db = system.getObject("db.common.connection").getCon();
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
console.log(">>>>>>>>>>>>>>..",daoName)
this.daoName = daoName; this.daoName = daoName;
this.dao = system.getObject("db." + gname + "." + daoName); this.dao = system.getObject("db." + gname + "." + daoName);
this.restS = system.getObject("util.restClient"); this.restS = system.getObject("util.restClient");
...@@ -18,10 +20,16 @@ class ServiceBase { ...@@ -18,10 +20,16 @@ class ServiceBase {
var md5 = this.md5(str + "_" + settings.salt); var md5 = this.md5(str + "_" + settings.salt);
return md5.toString().toLowerCase(); return md5.toString().toLowerCase();
} }
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
static getDaoName(ClassObj) { static getDaoName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Service")).toLowerCase() + "Dao"; console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>..");
let rtnstr=ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Service")).toLowerCase() + "Dao";
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>..",rtnstr);
return rtnstr;
} }
async findAndCountAll(obj) { async findAndCountAll(obj) {
const apps = await this.dao.findAndCountAll(obj); const apps = await this.dao.findAndCountAll(obj);
......
...@@ -199,9 +199,11 @@ class System { ...@@ -199,9 +199,11 @@ class System {
} }
var objabspath = classpath + "/" + filename + ".js"; var objabspath = classpath + "/" + filename + ".js";
//判断文件的存在性 //判断文件的存在性
//如果不存在,需要查看packageName //如果不存在,需要查看packageName
//如果packageName=web.service,dao //如果packageName=web.service,dao
if (System.objTable[objabspath] != null) { if (System.objTable[objabspath] != null) {
return System.objTable[objabspath]; return System.objTable[objabspath];
} else { } else {
......
...@@ -17,7 +17,7 @@ var settings = { ...@@ -17,7 +17,7 @@ var settings = {
defaultpwd:"gsb2020", defaultpwd:"gsb2020",
basepath : path.normalize(path.join(__dirname, '../..')), basepath : path.normalize(path.join(__dirname, '../..')),
port : process.env.NODE_PORT || 80, port : process.env.NODE_PORT || 80,
kongurl:"http://127.0.0.1:8001/", kongurl:"http://192.168.4.119:8001/",
pmappid:1, pmappid:1,
pmcompanyid:1, pmcompanyid:1,
redis:function(){ redis:function(){
......
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