Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
api-service-gateway
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
朱允伟
api-service-gateway
Commits
ef20a45c
Commit
ef20a45c
authored
Oct 12, 2021
by
朱允伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
<fix> 接口执行网关连接调整,sql语句格式化调整
parent
2ea0bad8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
22 deletions
+29
-22
api-service-gateway/src/main/resources/application.yml
api-service-gateway/src/main/resources/application.yml
+2
-2
api-service-project/api-service-application/src/main/java/com/zorkdata/apiservice/application/impl/ApiServiceApplicationImpl.java
...piservice/application/impl/ApiServiceApplicationImpl.java
+19
-12
api-service-project/api-service-facade/src/main/java/com/zorkdata/apiservice/facade/impl/ApiServicueFacadeImpl.java
...orkdata/apiservice/facade/impl/ApiServicueFacadeImpl.java
+8
-8
No files found.
api-service-gateway/src/main/resources/application.yml
View file @
ef20a45c
...
@@ -6,8 +6,8 @@ spring:
...
@@ -6,8 +6,8 @@ spring:
name
:
@
artifactId@
name
:
@
artifactId@
api-service-address
:
api-service-address
:
path
:
/v1/dataService/**
path
:
/v1/dataService/**
uri
:
http://
192.168.70.46
:6725
uri
:
http://
localhost
:6725
url
:
http://
192.168.70.46
:6725/v1/dataService/api/getApiLimit
url
:
http://
localhost
:6725/v1/dataService/api/getApiLimit
...
...
api-service-project/api-service-application/src/main/java/com/zorkdata/apiservice/application/impl/ApiServiceApplicationImpl.java
View file @
ef20a45c
...
@@ -118,6 +118,8 @@ public class ApiServiceApplicationImpl implements ApiApplication {
...
@@ -118,6 +118,8 @@ public class ApiServiceApplicationImpl implements ApiApplication {
public
static
final
String
ORDER_ASC
=
"asc"
;
public
static
final
String
ORDER_ASC
=
"asc"
;
@Value
(
"${api-getway-address}"
)
private
String
gateWayAddress
;
@Override
@Override
public
InvokeResult
addGroup
(
ApiGroupDTO
apiGroupDTO
,
String
username
)
{
public
InvokeResult
addGroup
(
ApiGroupDTO
apiGroupDTO
,
String
username
)
{
...
@@ -226,26 +228,27 @@ public class ApiServiceApplicationImpl implements ApiApplication {
...
@@ -226,26 +228,27 @@ public class ApiServiceApplicationImpl implements ApiApplication {
return
apiGroupRepository
.
findAll
(
specification
,
pageable
);
return
apiGroupRepository
.
findAll
(
specification
,
pageable
);
}
}
@Value
(
"${server.port}"
)
private
String
prot
;
@Override
@Override
public
Api
addApi
(
ApiDTO
apiDTO
,
String
username
,
Integer
userid
)
{
public
Api
addApi
(
ApiDTO
apiDTO
,
String
username
,
Integer
userid
)
{
String
name
=
apiDTO
.
getName
();
String
name
=
apiDTO
.
getName
();
String
querySql
=
apiDTO
.
getQuerySql
();
if
(
org
.
springframework
.
util
.
StringUtils
.
hasLength
(
querySql
)){
apiDTO
.
setQuerySql
(
formatQuerySQL
(
querySql
));
}
Integer
count
=
0
;
Integer
count
=
0
;
try
{
try
{
count
=
apiRepository
.
selectApiName
(
name
);
count
=
apiRepository
.
selectApiName
(
name
);
//count=0代表名称不存在,可进行新增
//count=0代表名称不存在,可进行新增
if
(
count
.
equals
(
0
))
{
if
(
count
.
equals
(
0
))
{
apiDTO
.
setSourceWay
(
"create"
);
apiDTO
.
setSourceWay
(
"create"
);
apiDTO
.
setPath
(
"http://
127.0.0.1:"
+
prot
+
"/v1/dataService/api/executeApi/"
+
apiDTO
.
getName
());
apiDTO
.
setPath
(
"http://
"
+
gateWayAddress
+
"/v1/dataService/api/executeApi/"
+
apiDTO
.
getName
());
apiRepository
.
save
(
ApiAssembler
.
toApi
(
apiDTO
,
username
,
userid
));
apiRepository
.
save
(
ApiAssembler
.
toApi
(
apiDTO
,
username
,
userid
));
}
else
{
}
else
{
if
(
apiDTO
.
getId
().
equals
(
0
))
{
if
(
apiDTO
.
getId
().
equals
(
0
))
{
throw
new
RuntimeException
(
"保存Api接口失败!,名称已存在"
);
throw
new
RuntimeException
(
"保存Api接口失败!,名称已存在"
);
}
else
{
}
else
{
apiDTO
.
setSourceWay
(
"create"
);
apiDTO
.
setSourceWay
(
"create"
);
apiDTO
.
setPath
(
"http://
127.0.0.1:"
+
prot
+
"/v1/dataService/api/executeApi/"
+
apiDTO
.
getName
());
apiDTO
.
setPath
(
"http://
"
+
gateWayAddress
+
"/v1/dataService/api/executeApi/"
+
apiDTO
.
getName
());
apiRepository
.
save
(
ApiAssembler
.
toApi
(
apiDTO
,
username
,
userid
));
apiRepository
.
save
(
ApiAssembler
.
toApi
(
apiDTO
,
username
,
userid
));
}
}
}
}
...
@@ -265,14 +268,14 @@ public class ApiServiceApplicationImpl implements ApiApplication {
...
@@ -265,14 +268,14 @@ public class ApiServiceApplicationImpl implements ApiApplication {
//count=0代表名称不存在,可进行新增
//count=0代表名称不存在,可进行新增
if
(
count
.
equals
(
0
))
{
if
(
count
.
equals
(
0
))
{
apiDTO
.
setSourceWay
(
"regist"
);
apiDTO
.
setSourceWay
(
"regist"
);
apiDTO
.
setPath
(
"http://
127.0.0.1:"
+
prot
+
"/v1/dataService/api/executeApi/"
+
apiDTO
.
getName
());
apiDTO
.
setPath
(
"http://
"
+
gateWayAddress
+
"/v1/dataService/api/executeApi/"
+
apiDTO
.
getName
());
apiRepository
.
save
(
ApiAssembler
.
toApi
(
apiDTO
,
username
,
userid
));
apiRepository
.
save
(
ApiAssembler
.
toApi
(
apiDTO
,
username
,
userid
));
}
else
{
}
else
{
if
(
apiDTO
.
getId
().
equals
(
0
))
{
if
(
apiDTO
.
getId
().
equals
(
0
))
{
throw
new
RuntimeException
(
"保存Api接口失败!,名称已存在"
);
throw
new
RuntimeException
(
"保存Api接口失败!,名称已存在"
);
}
else
{
}
else
{
apiDTO
.
setSourceWay
(
"regist"
);
apiDTO
.
setSourceWay
(
"regist"
);
apiDTO
.
setPath
(
"http://
127.0.0.1:"
+
prot
+
"/v1/dataService/api/executeApi/"
+
apiDTO
.
getName
());
apiDTO
.
setPath
(
"http://
"
+
gateWayAddress
+
"/v1/dataService/api/executeApi/"
+
apiDTO
.
getName
());
apiRepository
.
save
(
ApiAssembler
.
toApi
(
apiDTO
,
username
,
userid
));
apiRepository
.
save
(
ApiAssembler
.
toApi
(
apiDTO
,
username
,
userid
));
}
}
}
}
...
@@ -455,7 +458,7 @@ public class ApiServiceApplicationImpl implements ApiApplication {
...
@@ -455,7 +458,7 @@ public class ApiServiceApplicationImpl implements ApiApplication {
ApiViewDTO
apiViewDTO
=
new
ApiViewDTO
();
ApiViewDTO
apiViewDTO
=
new
ApiViewDTO
();
apiViewDTO
.
setId
(
item
.
getId
());
apiViewDTO
.
setId
(
item
.
getId
());
apiViewDTO
.
setName
(
item
.
getName
());
apiViewDTO
.
setName
(
item
.
getName
());
apiViewDTO
.
setPath
(
item
.
getPath
());
apiViewDTO
.
setPath
(
"http://"
+
gateWayAddress
+
"/v1/dataService/api/executeApi/"
+
item
.
getName
());
apiViewDTO
.
setDescription
(
item
.
getDescription
());
apiViewDTO
.
setDescription
(
item
.
getDescription
());
apiViewDTO
.
setApiAuthDTOList
(
ApiAuthAssembler
.
toApiAuthDTOList
(
item
.
getApiAuthList
()));
apiViewDTO
.
setApiAuthDTOList
(
ApiAuthAssembler
.
toApiAuthDTOList
(
item
.
getApiAuthList
()));
String
datasourceStr
=
item
.
getDatasource
();
String
datasourceStr
=
item
.
getDatasource
();
...
@@ -1301,19 +1304,19 @@ public class ApiServiceApplicationImpl implements ApiApplication {
...
@@ -1301,19 +1304,19 @@ public class ApiServiceApplicationImpl implements ApiApplication {
switch
(
requestType
)
{
switch
(
requestType
)
{
case
GET:
case
GET:
result
=
restTemplate
.
getForObject
(
uir
,
String
.
class
,
httpEntity
);
result
=
restTemplate
.
getForObject
(
uir
,
String
.
class
,
httpEntity
);
invokeResult
=
InvokeResult
.
success
(
"接口GET请求成功"
,
result
);
invokeResult
=
InvokeResult
.
success
(
result
,
"接口GET请求成功"
);
break
;
break
;
case
POST:
case
POST:
result
=
restTemplate
.
postForObject
(
uir
,
httpEntity
,
String
.
class
);
result
=
restTemplate
.
postForObject
(
uir
,
httpEntity
,
String
.
class
);
invokeResult
=
InvokeResult
.
success
(
"接口POST请求成功"
,
result
);
invokeResult
=
InvokeResult
.
success
(
result
,
"接口POST请求成功"
);
break
;
break
;
case
PUT:
case
PUT:
restTemplate
.
put
(
uir
,
httpEntity
);
restTemplate
.
put
(
uir
,
httpEntity
);
invokeResult
=
InvokeResult
.
success
(
"
接口PUT请求成功!"
,
"{'message':'接口PUT请求成功!'}
"
);
invokeResult
=
InvokeResult
.
success
(
"
{'message':'接口PUT请求成功!'}"
,
"接口PUT请求成功!
"
);
break
;
break
;
case
DELETE:
case
DELETE:
restTemplate
.
delete
(
uir
,
httpEntity
);
restTemplate
.
delete
(
uir
,
httpEntity
);
invokeResult
=
InvokeResult
.
success
(
"
接口DELETE请求成功!"
,
"{'message':'接口DELETE请求成功!'}
"
);
invokeResult
=
InvokeResult
.
success
(
"
{'message':'接口DELETE请求成功!'}"
,
"接口DELETE请求成功!
"
);
break
;
break
;
default
:
default
:
invokeResult
=
InvokeResult
.
fail
();
invokeResult
=
InvokeResult
.
fail
();
...
@@ -1443,4 +1446,8 @@ public class ApiServiceApplicationImpl implements ApiApplication {
...
@@ -1443,4 +1446,8 @@ public class ApiServiceApplicationImpl implements ApiApplication {
}
}
return
bodyParams
;
return
bodyParams
;
}
}
private
String
formatQuerySQL
(
String
querySql
){
return
querySql
.
replace
(
"$ { "
,
"${"
).
replace
(
" }"
,
"}"
);
}
}
}
api-service-project/api-service-facade/src/main/java/com/zorkdata/apiservice/facade/impl/ApiServicueFacadeImpl.java
View file @
ef20a45c
...
@@ -88,12 +88,12 @@ public class ApiServicueFacadeImpl implements ApiFacade {
...
@@ -88,12 +88,12 @@ public class ApiServicueFacadeImpl implements ApiFacade {
InvokeResult
invokeResult
;
InvokeResult
invokeResult
;
try
{
try
{
invokeResult
=
InvokeResult
.
success
();
invokeResult
=
InvokeResult
.
success
();
Api
api
=
apiApplication
.
addApi
(
apiDTO
,
username
,
userid
);
apiApplication
.
addApi
(
apiDTO
,
username
,
userid
);
invokeResult
.
set
Data
(
api
);
invokeResult
.
set
Message
(
"api生成成功!"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"
保存Api
失败"
,
e
);
log
.
error
(
"
Api生成
失败"
,
e
);
invokeResult
=
InvokeResult
.
fail
();
invokeResult
=
InvokeResult
.
fail
();
invokeResult
.
setMessage
(
"
保存Api
失败"
+
e
.
getMessage
());
invokeResult
.
setMessage
(
"
Api生成
失败"
+
e
.
getMessage
());
}
}
return
invokeResult
;
return
invokeResult
;
}
}
...
@@ -187,12 +187,12 @@ public class ApiServicueFacadeImpl implements ApiFacade {
...
@@ -187,12 +187,12 @@ public class ApiServicueFacadeImpl implements ApiFacade {
InvokeResult
invokeResult
;
InvokeResult
invokeResult
;
try
{
try
{
invokeResult
=
InvokeResult
.
success
();
invokeResult
=
InvokeResult
.
success
();
Api
api
=
apiApplication
.
registApi
(
apiDTO
,
username
,
userid
);
apiApplication
.
registApi
(
apiDTO
,
username
,
userid
);
invokeResult
.
set
Data
(
api
);
invokeResult
.
set
Message
(
"api注册成功!"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"
保存Api
失败"
,
e
);
log
.
error
(
"
Api注册
失败"
,
e
);
invokeResult
=
InvokeResult
.
fail
();
invokeResult
=
InvokeResult
.
fail
();
invokeResult
.
setMessage
(
"
保存Api
失败"
+
e
.
getMessage
());
invokeResult
.
setMessage
(
"
Api注册
失败"
+
e
.
getMessage
());
}
}
return
invokeResult
;
return
invokeResult
;
}
}
...
...
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