Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
553674c0
Commit
553674c0
authored
Apr 19, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
ddb0b99d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
13 deletions
+25
-13
center-manage/app/base/controller/impl/auth/userCtl.js
+1
-0
center-manage/app/base/db/initData.js
+4
-3
center-manage/app/base/db/models/common/company.js
+4
-0
center-manage/app/base/service/impl/auth/userSve.js
+0
-0
center-manage/app/base/service/impl/common/appSve.js
+1
-5
center-manage/app/base/service/impl/common/routeSve.js
+1
-1
center-manage/app/base/service/sve.base.js
+11
-3
center-manage/app/base/system.js
+2
-0
center-manage/app/config/settings.js
+1
-1
No files found.
center-manage/app/base/controller/impl/auth/userCtl.js
View file @
553674c0
...
...
@@ -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
;
...
...
center-manage/app/base/db/initData.js
View file @
553674c0
...
...
@@ -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
us
S
.
pmregister
({
userName
:
"sm"
,
password
:
"951753"
,
isSuper
:
true
,
isAdmin
:
true
,
isEnabled
:
true
,
nickName
:
"superman"
,
app_id
:
appnew
.
id
,
company_id
:
settings
.
id
})
...
...
center-manage/app/base/db/models/common/company.js
View file @
553674c0
...
...
@@ -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
,
...
...
center-manage/app/base/service/impl/auth/userSve.js
View file @
553674c0
This diff is collapsed.
Click to expand it.
center-manage/app/base/service/impl/common/appSve.js
View file @
553674c0
...
...
@@ -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
;
...
...
center-manage/app/base/service/impl/common/routeSve.js
View file @
553674c0
...
...
@@ -4,7 +4,7 @@ const settings = require("../../../../config/settings");
const
appconfig
=
system
.
getSysConfig
();
class
RouteService
extends
ServiceBase
{
constructor
()
{
super
(
"common"
,
ServiceBase
.
getDaoName
(
App
Service
));
super
(
"common"
,
ServiceBase
.
getDaoName
(
Route
Service
));
}
//创建应用
...
...
center-manage/app/base/service/sve.base.js
View file @
553674c0
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
);
...
...
center-manage/app/base/system.js
View file @
553674c0
...
...
@@ -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
{
...
...
center-manage/app/config/settings.js
View file @
553674c0
...
...
@@ -17,7 +17,7 @@ var settings = {
defaultpwd
:
"gsb2020"
,
basepath
:
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
)),
port
:
process
.
env
.
NODE_PORT
||
80
,
kongurl
:
"http://1
27.0.0.1
:8001/"
,
kongurl
:
"http://1
92.168.4.119
:8001/"
,
pmappid
:
1
,
pmcompanyid
:
1
,
redis
:
function
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment