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
be3270ca
Commit
be3270ca
authored
May 09, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
10dce1de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
89 deletions
+30
-89
center-manage/app/base/controller/impl/common/appCtl.js
+4
-0
center-manage/app/base/service/impl/common/appSve.js
+23
-3
center-manage/app/base/service/impl/common/pluginSve.js
+3
-86
No files found.
center-manage/app/base/controller/impl/common/appCtl.js
View file @
be3270ca
...
@@ -15,6 +15,10 @@ class AppCtl extends CtlBase {
...
@@ -15,6 +15,10 @@ class AppCtl extends CtlBase {
var
rtns
=
await
this
.
service
.
findAllApps
(
p
.
userid
);
var
rtns
=
await
this
.
service
.
findAllApps
(
p
.
userid
);
return
system
.
getResult
(
rtns
);
return
system
.
getResult
(
rtns
);
}
}
async
getApp
(
p
,
q
,
req
)
{
let
app
=
await
this
.
cacheManager
[
"AppCache"
].
cache
(
p
.
appkey
,
null
);
return
system
.
getResult
(
app
);
}
async
create
(
pobj
,
queryobj
,
req
)
{
async
create
(
pobj
,
queryobj
,
req
)
{
pobj
.
creator_id
=
pobj
.
userid
;
//设置创建者
pobj
.
creator_id
=
pobj
.
userid
;
//设置创建者
return
super
.
create
(
pobj
,
queryobj
,
req
)
return
super
.
create
(
pobj
,
queryobj
,
req
)
...
...
center-manage/app/base/service/impl/common/appSve.js
View file @
be3270ca
...
@@ -8,8 +8,9 @@ class AppService extends ServiceBase {
...
@@ -8,8 +8,9 @@ class AppService extends ServiceBase {
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"
);
}
}
async
getApp
(
appkey
)
{
async
getApp
(
p
)
{
return
this
.
cacheManager
[
"AppCache"
].
cache
(
appkey
,
null
);
let
app
=
this
.
cacheManager
[
"AppCache"
].
cache
(
p
.
appkey
,
null
);
return
app
;
}
}
async
findAllApps
(
uid
)
{
async
findAllApps
(
uid
)
{
var
apps
=
null
;
var
apps
=
null
;
...
@@ -43,6 +44,10 @@ class AppService extends ServiceBase {
...
@@ -43,6 +44,10 @@ class AppService extends ServiceBase {
}
}
return
dicRtn
;
return
dicRtn
;
}
}
//创建应用
//创建应用
//每个应用建立两个路由,一个api路由
//每个应用建立两个路由,一个api路由
//对api路由启用jwt插件
//对api路由启用jwt插件
...
@@ -77,11 +82,26 @@ class AppService extends ServiceBase {
...
@@ -77,11 +82,26 @@ class AppService extends ServiceBase {
return
app
;
return
app
;
});
});
}
}
//删除应用
async
update
(
pobj
,
qobj
){
var
self
=
this
;
return
this
.
db
.
transaction
(
async
function
(
t
)
{
await
self
.
dao
.
update
(
pobj
,
t
)
let
upobj
=
await
self
.
dao
.
findById
(
pobj
.
id
)
//令缓存失效
await
self
.
cacheManager
[
"AppCache"
].
invalidate
(
upobj
.
appkey
);
return
upobj
})
}
//删除应用
//删除应用
async
delete
(
pobj
,
qobj
){
async
delete
(
pobj
,
qobj
){
var
self
=
this
;
var
self
=
this
;
return
this
.
db
.
transaction
(
async
function
(
t
)
{
return
this
.
db
.
transaction
(
async
function
(
t
)
{
await
self
.
dao
.
delete
(
pobj
,
t
)
let
delobj
=
await
self
.
dao
.
delete
(
pobj
,
t
)
//令缓存失效
await
self
.
cacheManager
[
"AppCache"
].
invalidate
(
delobj
.
appkey
);
//删除路由
//删除路由
await
self
.
cdel
(
AppService
.
routeUrl
(
pobj
.
name
));
await
self
.
cdel
(
AppService
.
routeUrl
(
pobj
.
name
));
//删除api路由
//删除api路由
...
...
center-manage/app/base/service/impl/common/pluginSve.js
View file @
be3270ca
...
@@ -2,97 +2,14 @@ const system = require("../../../system");
...
@@ -2,97 +2,14 @@ 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
();
class
App
Service
extends
ServiceBase
{
class
Plugin
Service
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"
);
}
}
async
getApp
(
appkey
)
{
return
this
.
cacheManager
[
"AppCache"
].
cache
(
appkey
,
null
);
}
async
findAllApps
(
uid
)
{
var
apps
=
null
;
var
dicRtn
=
{};
var
wheresql
=
{};
if
(
uid
){
wheresql
[
this
.
db
.
Op
.
and
]
=
{
[
this
.
db
.
Op
.
or
]:
[
{
isPublish
:
false
,
creator_id
:
uid
},
{
isEnabled
:
true
,
isPublish
:
true
}
],
};
apps
=
await
this
.
dao
.
model
.
findAll
({
where
:
wheresql
,
attributes
:
[
'id'
,
'name'
,
'appkey'
,
'showimgUrl'
,
'appType'
,
'docUrl'
,
'homePage'
]
});
}
else
{
wheresql
=
{
isEnabled
:
true
,
isPublish
:
true
};
apps
=
await
this
.
dao
.
model
.
findAll
({
where
:
wheresql
,
attributes
:
[
'id'
,
'name'
,
'appkey'
,
'showimgUrl'
,
'appType'
,
'docUrl'
,
'homePage'
]
});
}
for
(
var
app
of
apps
)
{
var
tmk
=
uiconfig
.
config
.
pdict
.
app_type
[
app
.
appType
];
if
(
!
dicRtn
[
tmk
])
{
dicRtn
[
tmk
]
=
[];
dicRtn
[
tmk
].
push
(
app
);
}
else
{
dicRtn
[
tmk
].
push
(
app
);
}
}
return
dicRtn
;
}
//创建应用
//每个应用建立两个路由,一个api路由
//对api路由启用jwt插件
async
create
(
pobj
,
qobj
,
req
)
{
var
self
=
this
;
return
this
.
db
.
transaction
(
async
function
(
t
)
{
var
app
=
await
self
.
dao
.
create
(
pobj
,
t
);
//创建后台应用服务
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
})
//给api路由启动插件
if
(
svobj
&&
routeobj
){
try
{
app
.
appkey
=
svobj
.
id
;
await
app
.
save
({
transaction
:
t
});
}
catch
(
e
){
await
self
.
cdel
(
AppService
.
routeUrl
(
app
.
name
))
await
self
.
cdel
(
AppService
.
routeUrl
(
app
.
name
+
"_api"
))
await
self
.
cdel
(
AppService
.
serviceUrl
(
app
.
name
))
}
}
else
{
throw
new
Error
(
"创建应用服务失败"
);
}
return
app
;
});
}
//删除应用
async
delete
(
pobj
,
qobj
){
var
self
=
this
;
return
this
.
db
.
transaction
(
async
function
(
t
)
{
await
self
.
dao
.
delete
(
pobj
,
t
)
//删除路由
await
self
.
cdel
(
AppService
.
routeUrl
(
pobj
.
name
));
//删除api路由
await
self
.
cdel
(
AppService
.
routeUrl
(
pobj
.
name
+
"_api"
));
//删除服务
await
self
.
cdel
(
AppService
.
serviceUrl
(
pobj
.
name
));
return
{}
})
}
async
findAndCountAll
(
obj
)
{
var
self
=
this
;
const
apps
=
await
super
.
findAndCountAll
(
obj
);
return
apps
;
}
}
}
module
.
exports
=
App
Service
;
module
.
exports
=
Plugin
Service
;
// (async ()=>{
// (async ()=>{
// let u=new AppService();
// let u=new AppService();
// // let x=await u.cregister("jiangong")
// // let x=await u.cregister("jiangong")
...
...
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