Commit 553674c0 by 蒋勇

d

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