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
caaaa7ee
Commit
caaaa7ee
authored
May 10, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
be3270ca
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
37 deletions
+62
-37
center-manage/app/base/service/impl/common/appSve.js
+62
-37
No files found.
center-manage/app/base/service/impl/common/appSve.js
View file @
caaaa7ee
...
@@ -6,32 +6,34 @@ class AppService extends ServiceBase {
...
@@ -6,32 +6,34 @@ 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"
);
}
}
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
findAllApps
(
uid
)
{
async
findAllApps
(
uid
)
{
var
apps
=
null
;
var
apps
=
null
;
var
dicRtn
=
{};
var
dicRtn
=
{};
var
wheresql
=
{};
var
wheresql
=
{};
if
(
uid
)
{
if
(
uid
)
{
wheresql
[
this
.
db
.
Op
.
and
]
=
{
wheresql
[
this
.
db
.
Op
.
and
]
=
{
[
this
.
db
.
Op
.
or
]:
[
this
.
db
.
Op
.
or
]:
[
[
{
isPublish
:
false
,
creator_id
:
uid
},
{
isPublish
:
false
,
creator_id
:
uid
},
{
isEnabled
:
true
,
isPublish
:
true
}
{
isEnabled
:
true
,
isPublish
:
true
}
],
],
};
};
apps
=
await
this
.
dao
.
model
.
findAll
({
apps
=
await
this
.
dao
.
model
.
findAll
({
where
:
wheresql
,
where
:
wheresql
,
attributes
:
[
'id'
,
'name'
,
'appkey'
,
'showimgUrl'
,
'appType'
,
'docUrl'
,
'homePage'
]
});
attributes
:
[
'id'
,
'name'
,
'appkey'
,
'showimgUrl'
,
'appType'
,
'docUrl'
,
'homePage'
]
}
else
{
});
wheresql
=
{
isEnabled
:
true
,
isPublish
:
true
};
}
else
{
wheresql
=
{
isEnabled
:
true
,
isPublish
:
true
};
apps
=
await
this
.
dao
.
model
.
findAll
({
apps
=
await
this
.
dao
.
model
.
findAll
({
where
:
wheresql
,
where
:
wheresql
,
attributes
:
[
'id'
,
'name'
,
'appkey'
,
'showimgUrl'
,
'appType'
,
'docUrl'
,
'homePage'
]
});
attributes
:
[
'id'
,
'name'
,
'appkey'
,
'showimgUrl'
,
'appType'
,
'docUrl'
,
'homePage'
]
});
}
}
for
(
var
app
of
apps
)
{
for
(
var
app
of
apps
)
{
var
tmk
=
uiconfig
.
config
.
pdict
.
app_type
[
app
.
appType
];
var
tmk
=
uiconfig
.
config
.
pdict
.
app_type
[
app
.
appType
];
...
@@ -56,39 +58,62 @@ class AppService extends ServiceBase {
...
@@ -56,39 +58,62 @@ class AppService extends ServiceBase {
return
this
.
db
.
transaction
(
async
function
(
t
)
{
return
this
.
db
.
transaction
(
async
function
(
t
)
{
var
app
=
await
self
.
dao
.
create
(
pobj
,
t
);
var
app
=
await
self
.
dao
.
create
(
pobj
,
t
);
//创建后台应用服务
//创建后台应用服务
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
ps
=
[
"/web/auth/userCtl/pmlogin"
,
"/web/auth/userCtl/pmregister"
,
"/web/auth/userCtl/pmSendVCode"
,
"/web/auth/userCtl/pmloginByVCode"
]
let
ps
=
[
"/web/auth/userCtl/pmlogin"
,
"/web/auth/userCtl/pmregister"
,
"/web/auth/userCtl/pmSendVCode"
,
"/web/auth/userCtl/pmloginByVCode"
]
let
routeobj
=
await
self
.
cjsonregister
(
AppService
.
newRouteUrl
(
app
.
name
),
let
routeobj
=
await
self
.
cjsonregister
(
AppService
.
newRouteUrl
(
app
.
name
),
{
name
:
app
.
name
,
paths
:
ps
,
hosts
:[
app
.
domainName
],
strip_path
:
false
})
{
name
:
app
.
name
,
paths
:
ps
,
hosts
:
[
app
.
domainName
],
strip_path
:
false
})
let
ps2
=
[
"/api"
,
"/web"
]
let
ps2
=
[
"/api"
,
"/web"
]
let
routeapi
=
await
self
.
cjsonregister
(
AppService
.
newRouteUrl
(
app
.
name
),{
name
:
app
.
name
+
"_api"
,
hosts
:[
app
.
domainName
],
paths
:
ps2
,
strip_path
:
false
})
let
routeapi
=
await
self
.
cjsonregister
(
AppService
.
newRouteUrl
(
app
.
name
),
{
name
:
app
.
name
+
"_api"
,
hosts
:
[
app
.
domainName
],
paths
:
ps2
,
strip_path
:
false
})
let
r1
=
await
self
.
routeDao
.
create
({
name
:
app
.
name
,
center_id
:
routeobj
.
id
,
app_id
:
app
.
id
,
shosts
:
app
.
domainName
,
spaths
:
ps
.
join
(
","
)},
t
);
let
r1
=
await
self
.
routeDao
.
create
({
name
:
app
.
name
,
center_id
:
routeobj
.
id
,
app_id
:
app
.
id
,
shosts
:
app
.
domainName
,
spaths
:
ps
.
join
(
","
)
},
t
);
let
r2
=
await
self
.
routeDao
.
create
({
name
:
app
.
name
+
"_api"
,
center_id
:
routeapi
.
id
,
app_id
:
app
.
id
,
shosts
:
app
.
domainName
,
spaths
:
ps2
.
join
(
","
)},
t
);
let
r2
=
await
self
.
routeDao
.
create
({
name
:
app
.
name
+
"_api"
,
center_id
:
routeapi
.
id
,
app_id
:
app
.
id
,
shosts
:
app
.
domainName
,
spaths
:
ps2
.
join
(
","
)
},
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
;
await
app
.
save
({
transaction
:
t
});
await
app
.
save
({
transaction
:
t
});
}
catch
(
e
)
{
}
catch
(
e
)
{
await
self
.
cdel
(
AppService
.
routeUrl
(
app
.
name
))
await
self
.
cdel
(
AppService
.
routeUrl
(
app
.
name
))
await
self
.
cdel
(
AppService
.
routeUrl
(
app
.
name
+
"_api"
))
await
self
.
cdel
(
AppService
.
routeUrl
(
app
.
name
+
"_api"
))
await
self
.
cdel
(
AppService
.
serviceUrl
(
app
.
name
))
await
self
.
cdel
(
AppService
.
serviceUrl
(
app
.
name
))
}
}
}
else
{
}
else
{
throw
new
Error
(
"创建应用服务失败"
);
throw
new
Error
(
"创建应用服务失败"
);
}
}
return
app
;
return
app
;
});
});
}
}
async
translateWithBizCode
(
funcobjs
,
parentfunc
)
{
funcobjs
.
forEach
((
item
)
=>
{
if
(
item
.
children
)
{
if
(
parentfunc
){
item
.
bizCode
=
parentfunc
.
bizCode
+
"/"
+
item
.
name
}
else
{
item
.
bizCode
=
item
.
name
}
this
.
translateWithBizCode
(
item
.
children
,
item
)
}
else
{
if
(
parentfunc
){
item
.
bizCode
=
parentfunc
.
bizCode
+
"/"
+
item
.
name
}
else
{
item
.
bizCode
=
item
.
name
}
}
})
}
//删除应用
//删除应用
async
update
(
pobj
,
qobj
)
{
async
update
(
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
.
update
(
pobj
,
t
)
//如果存在functionJSON,那么就需要转换,构建编码路径
let
upobj
=
await
self
.
dao
.
findById
(
pobj
.
id
)
if
(
pobj
.
functionJSON
!=
""
)
{
let
funcobjs
=
JSON
.
parse
(
pobj
.
functionJSON
)
await
self
.
translateWithBizCode
(
funcobjs
,
null
)
pobj
.
functionJSON
=
JSON
.
stringify
(
funcobjs
)
}
await
self
.
dao
.
update
(
pobj
,
t
)
let
upobj
=
await
self
.
dao
.
findById
(
pobj
.
id
)
//令缓存失效
//令缓存失效
await
self
.
cacheManager
[
"AppCache"
].
invalidate
(
upobj
.
appkey
);
await
self
.
cacheManager
[
"AppCache"
].
invalidate
(
upobj
.
appkey
);
return
upobj
return
upobj
...
@@ -96,16 +121,16 @@ class AppService extends ServiceBase {
...
@@ -96,16 +121,16 @@ class AppService extends ServiceBase {
}
}
//删除应用
//删除应用
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
)
{
let
delobj
=
await
self
.
dao
.
delete
(
pobj
,
t
)
let
delobj
=
await
self
.
dao
.
delete
(
pobj
,
t
)
//令缓存失效
//令缓存失效
await
self
.
cacheManager
[
"AppCache"
].
invalidate
(
delobj
.
appkey
);
await
self
.
cacheManager
[
"AppCache"
].
invalidate
(
delobj
.
appkey
);
//删除路由
//删除路由
await
self
.
cdel
(
AppService
.
routeUrl
(
pobj
.
name
));
await
self
.
cdel
(
AppService
.
routeUrl
(
pobj
.
name
));
//删除api路由
//删除api路由
await
self
.
cdel
(
AppService
.
routeUrl
(
pobj
.
name
+
"_api"
));
await
self
.
cdel
(
AppService
.
routeUrl
(
pobj
.
name
+
"_api"
));
//删除服务
//删除服务
await
self
.
cdel
(
AppService
.
serviceUrl
(
pobj
.
name
));
await
self
.
cdel
(
AppService
.
serviceUrl
(
pobj
.
name
));
return
{}
return
{}
...
...
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