Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
jz-dmp-service
Commits
0b6d8222
Commit
0b6d8222
authored
Jan 19, 2021
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
23e98c88
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
516 additions
and
4 deletions
+516
-4
HttpClientUtils.java
src/main/java/com/jz/common/utils/web/HttpClientUtils.java
+41
-0
DmpApiMangeController.java
...modules/controller/dataService/DmpApiMangeController.java
+128
-0
DmpOrgMangeController.java
...modules/controller/dataService/DmpOrgMangeController.java
+27
-3
ApiInterfaceInfoListReq.java
.../controller/dataService/bean/ApiInterfaceInfoListReq.java
+25
-0
AuthListInfoReq.java
.../modules/controller/dataService/bean/AuthListInfoReq.java
+32
-0
OrganizationManageDetailQueryReq.java
...er/dataService/bean/OrganizationManageDetailQueryReq.java
+25
-0
DmpApiMangeService.java
...n/java/com/jz/dmp/modules/service/DmpApiMangeService.java
+46
-0
DmpOrgMangeService.java
...n/java/com/jz/dmp/modules/service/DmpOrgMangeService.java
+8
-0
DmpApiMangeServiceImpl.java
...m/jz/dmp/modules/service/impl/DmpApiMangeServiceImpl.java
+156
-0
DmpOrgMangeServiceImpl.java
...m/jz/dmp/modules/service/impl/DmpOrgMangeServiceImpl.java
+28
-1
No files found.
src/main/java/com/jz/common/utils/web/HttpClientUtils.java
View file @
0b6d8222
...
@@ -305,6 +305,46 @@ public class HttpClientUtils {
...
@@ -305,6 +305,46 @@ public class HttpClientUtils {
return
result
;
return
result
;
}
}
/**
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
*
* @return
* @throws IOException
* @throws ClientProtocolException
*/
public
static
String
postFormUrlencoded
(
String
url
,
String
json
)
{
LOGGER
.
info
(
"===================POST request start======================="
);
LOGGER
.
info
(
"url:"
+
url
);
LOGGER
.
info
(
"json:"
+
json
);
String
charset
=
"UTF-8"
;
CloseableHttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
try
{
httpClient
=
HttpClients
.
createDefault
();
httpPost
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
50000
).
setConnectTimeout
(
50000
).
build
();
//设置请求和传输超时时间
httpPost
.
setConfig
(
requestConfig
);
/* StringEntity se = new StringEntity(json, "UTF-8");
se.setContentType("application/x-www-form-urlencoded");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"));
System.out.println("-------------" + JSONObject.toJSONString(se));httpPost.setEntity(se);*/
httpPost
.
setEntity
(
new
StringEntity
(
json
,
"UTF-8"
));
httpPost
.
setHeader
(
"Content-type"
,
"application/x-www-form-urlencoded"
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
if
(
response
!=
null
)
{
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
{
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
}
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
LOGGER
.
info
(
"===================POST request end======================="
);
return
result
;
}
/**
/**
* 带参
* 带参
*
*
...
@@ -617,6 +657,7 @@ public class HttpClientUtils {
...
@@ -617,6 +657,7 @@ public class HttpClientUtils {
/**
/**
* 发送 getJsonForParam请求
* 发送 getJsonForParam请求
*
* @author Bellamy
* @author Bellamy
*/
*/
public
static
String
getJsonForParam
(
String
url
,
Map
<
String
,
Object
>
paramMap
)
{
public
static
String
getJsonForParam
(
String
url
,
Map
<
String
,
Object
>
paramMap
)
{
...
...
src/main/java/com/jz/dmp/modules/controller/dataService/DmpApiMangeController.java
0 → 100644
View file @
0b6d8222
package
com
.
jz
.
dmp
.
modules
.
controller
.
dataService
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.dmp.modules.controller.dataService.bean.*
;
import
com.jz.dmp.modules.service.DmpApiMangeService
;
import
com.jz.dmp.modules.service.DmpOrgMangeService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
/**
* 数据服务Api管理--调用gateway 接口
*
* @author Bellamy
* @since 2021-01-18 10:56:18
*/
@RestController
@RequestMapping
(
"/apiMange"
)
@Api
(
tags
=
"数据服务-Api管理"
)
public
class
DmpApiMangeController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DmpApiMangeController
.
class
);
/**
* 服务对象
*/
@Autowired
private
DmpApiMangeService
dmpApiMangeService
;
/**
* 授权给他人的API-列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation
(
value
=
"授权给他人的API-列表分页查询"
,
notes
=
"列表分页查询"
)
@PostMapping
(
value
=
"/apiAuthListPage"
)
public
JsonResult
getApiAuthListPage
(
@RequestBody
@Validated
AuthListInfoReq
req
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpApiMangeService
.
queryApiAuthListPage
(
req
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
/**
* 取消授权
*
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation
(
value
=
"取消授权"
,
notes
=
"取消授权"
)
@GetMapping
(
value
=
"/cancelApiAuth"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"授权id"
,
required
=
true
)
public
JsonResult
getCancelApiAuth
(
@RequestParam
String
id
,
HttpServletRequest
httpRequest
)
{
if
(
StringUtils
.
isEmpty
(
id
))
{
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"授权id不能为空!"
);
}
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpApiMangeService
.
cancelApiAuth
(
id
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
/**
* 发布的API-API列表分页查询
*
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation
(
value
=
"发布的API-API列表分页查询"
,
notes
=
"列表分页查询"
)
@PostMapping
(
value
=
"/listPage"
)
public
JsonResult
getApiListPage
(
@RequestBody
@Validated
ApiInterfaceInfoListReq
req
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpApiMangeService
.
queryApiListPage
(
req
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
/**
* 删除api
*
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation
(
value
=
"删除api"
,
notes
=
"删除api"
)
@GetMapping
(
value
=
"/delApiInfo"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"apiKey"
,
value
=
"apiKey"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"类型"
,
required
=
false
)})
public
JsonResult
delApiInfo
(
@RequestParam
String
apiKey
,
@RequestParam
(
required
=
false
)
String
type
,
HttpServletRequest
httpRequest
)
{
if
(
StringUtils
.
isEmpty
(
apiKey
))
{
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"apiKey不能为空!"
);
}
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpApiMangeService
.
delApiInfo
(
apiKey
,
type
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/controller/dataService/DmpOrgMangeController.java
View file @
0b6d8222
...
@@ -67,7 +67,7 @@ public class DmpOrgMangeController {
...
@@ -67,7 +67,7 @@ public class DmpOrgMangeController {
*/
*/
@ApiOperation
(
value
=
"删除组织"
,
notes
=
"删除组织"
)
@ApiOperation
(
value
=
"删除组织"
,
notes
=
"删除组织"
)
@GetMapping
(
value
=
"/delOrg"
)
@GetMapping
(
value
=
"/delOrg"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"组织id"
,
required
=
true
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"组织id"
,
required
=
true
)
public
JsonResult
delOrgById
(
@RequestParam
long
id
,
HttpServletRequest
httpRequest
)
{
public
JsonResult
delOrgById
(
@RequestParam
long
id
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
JsonResult
jsonResult
=
new
JsonResult
();
try
{
try
{
...
@@ -91,10 +91,10 @@ public class DmpOrgMangeController {
...
@@ -91,10 +91,10 @@ public class DmpOrgMangeController {
@PostMapping
(
value
=
"/addOrg"
)
@PostMapping
(
value
=
"/addOrg"
)
public
JsonResult
addOrg
(
@RequestBody
@Validated
OrganizationManageAddReq
req
,
HttpServletRequest
httpRequest
)
{
public
JsonResult
addOrg
(
@RequestBody
@Validated
OrganizationManageAddReq
req
,
HttpServletRequest
httpRequest
)
{
if
(
StringUtils
.
isEmpty
(
req
.
getOrgName
()))
{
if
(
StringUtils
.
isEmpty
(
req
.
getOrgName
()))
{
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"组织名称不能为空!"
);
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"组织名称不能为空!"
);
}
}
if
(
StringUtils
.
isEmpty
(
req
.
getOrgType
()))
{
if
(
StringUtils
.
isEmpty
(
req
.
getOrgType
()))
{
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"组织类型不能为空!"
);
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"组织类型不能为空!"
);
}
}
JsonResult
jsonResult
=
new
JsonResult
();
JsonResult
jsonResult
=
new
JsonResult
();
try
{
try
{
...
@@ -127,4 +127,28 @@ public class DmpOrgMangeController {
...
@@ -127,4 +127,28 @@ public class DmpOrgMangeController {
}
}
return
jsonResult
;
return
jsonResult
;
}
}
/**
* 根据组织id获取组织详情
*
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation
(
value
=
"根据组织id获取组织详情"
,
notes
=
"根据组织id获取组织详情"
)
@PostMapping
(
value
=
"/orgInfo"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"组织id"
,
required
=
true
)
public
JsonResult
getOrgInfoByOrgId
(
@RequestParam
String
id
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
if
(
StringUtils
.
isEmpty
(
id
))
{
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"组织id不能为空!"
);
}
try
{
jsonResult
=
dmpOrgMangeService
.
getOrgInfoByOrgId
(
id
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
}
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/controller/dataService/bean/ApiInterfaceInfoListReq.java
0 → 100644
View file @
0b6d8222
package
com
.
jz
.
dmp
.
modules
.
controller
.
dataService
.
bean
;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @ClassName: ApiInterfaceInfoListReq
* @Description: 发布的API-APi列表请求对象
* @Author: Bellamy
* @Date 2021/1/18
* @Version 1.0
*/
@Data
@ApiModel
(
"发布的API-APi列表请求对象"
)
public
class
ApiInterfaceInfoListReq
extends
BasePageBean
implements
Serializable
{
@ApiModelProperty
(
value
=
"状态:SUCCEED 请求成功, FAIL 请求失败"
)
private
String
status
;
@ApiModelProperty
(
value
=
"ApiKey"
)
private
String
apiKey
;
}
src/main/java/com/jz/dmp/modules/controller/dataService/bean/AuthListInfoReq.java
0 → 100644
View file @
0b6d8222
package
com
.
jz
.
dmp
.
modules
.
controller
.
dataService
.
bean
;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @ClassName: AuthListInfoReq
* @Description: 授权认证信息列表请求对象
* @Author: Bellamy
* @Date 2021/1/18
* @Version 1.0
*/
@Data
@ApiModel
(
"授权认证信息列表请求对象"
)
public
class
AuthListInfoReq
extends
BasePageBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
6807722745717042029L
;
@ApiModelProperty
(
value
=
"apiKey api唯一标识"
,
required
=
false
)
private
String
apiKey
;
@ApiModelProperty
(
value
=
"授权码"
,
required
=
false
)
private
String
authCode
;
@ApiModelProperty
(
value
=
"API名称"
,
required
=
false
)
private
String
apiName
;
}
src/main/java/com/jz/dmp/modules/controller/dataService/bean/OrganizationManageDetailQueryReq.java
0 → 100644
View file @
0b6d8222
package
com
.
jz
.
dmp
.
modules
.
controller
.
dataService
.
bean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: OrganizationManageListQueryReq
* @DATE: 2020-12-24/10:34
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel
(
"组织管理详情请求体"
)
public
class
OrganizationManageDetailQueryReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"组织id"
,
required
=
true
)
@NotNull
(
message
=
"组织id不能为空"
)
private
Long
id
;
}
src/main/java/com/jz/dmp/modules/service/DmpApiMangeService.java
0 → 100644
View file @
0b6d8222
package
com
.
jz
.
dmp
.
modules
.
service
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.dmp.modules.controller.dataService.bean.*
;
/**
* @ClassName: DmpApiMangeService
* @Description: 数据服务Api管理
* @Author: Bellamy
* @Date 2021/1/18
* @Version 1.0
*/
public
interface
DmpApiMangeService
{
/**
* 授权给他人的API-列表分页查询
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult
queryApiAuthListPage
(
AuthListInfoReq
req
)
throws
Exception
;
/**
* 取消授权
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult
cancelApiAuth
(
String
id
)
throws
Exception
;
/**
* 发布的API-API列表分页查询
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult
queryApiListPage
(
ApiInterfaceInfoListReq
req
)
throws
Exception
;
/**
* 删除api
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult
delApiInfo
(
String
apiKey
,
String
type
)
throws
Exception
;
}
src/main/java/com/jz/dmp/modules/service/DmpOrgMangeService.java
View file @
0b6d8222
...
@@ -49,4 +49,12 @@ public interface DmpOrgMangeService {
...
@@ -49,4 +49,12 @@ public interface DmpOrgMangeService {
* @since 2021-01-16
* @since 2021-01-16
*/
*/
JsonResult
updateOrg
(
OrganizationManageUpdateReq
req
)
throws
Exception
;
JsonResult
updateOrg
(
OrganizationManageUpdateReq
req
)
throws
Exception
;
/**
* 根据组织id获取组织详情
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult
getOrgInfoByOrgId
(
String
id
)
throws
Exception
;
}
}
src/main/java/com/jz/dmp/modules/service/impl/DmpApiMangeServiceImpl.java
0 → 100644
View file @
0b6d8222
package
com
.
jz
.
dmp
.
modules
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.utils.web.HttpClientUtils
;
import
com.jz.dmp.modules.controller.dataService.bean.*
;
import
com.jz.dmp.modules.service.DmpApiMangeService
;
import
com.jz.dmp.modules.service.DmpOrgMangeService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @ClassName: DmpOrgMangeServiceImpl
* @Description: 数据服务组织管理
* @Author: Bellamy
* @Date 2021/1/15
* @Version 1.0
*/
@Service
(
"dmpApiMangeService"
)
public
class
DmpApiMangeServiceImpl
implements
DmpApiMangeService
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DmpApiMangeServiceImpl
.
class
);
//授权给他人的API-列表分页查询url
private
static
final
String
apiAuthListPage
=
"/api/auth/auth-list"
;
//取消授权url
private
static
final
String
cancelApiAuth
=
"/api/auth/update-auth-info"
;
//发布的API-API列表分页查询url
private
static
final
String
apiListPage
=
"/api/interface/listApiInterface"
;
//删除APIurl
private
static
final
String
delApi
=
"/api/interface/delDMPApiInterface"
;
@Value
(
"${spring.gateway-url}"
)
private
String
gatewayUrl
;
/**
* 授权给他人的API-列表分页查询
*
* @author Bellamy
* @since 2021-01-18
*/
@Override
public
JsonResult
queryApiAuthListPage
(
AuthListInfoReq
req
)
throws
Exception
{
String
url
=
gatewayUrl
+
apiAuthListPage
;
String
resultData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
req
));
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"查询失败!"
);
}
logger
.
info
(
"#################响应结果数据{}"
+
resultData
);
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
StringUtils
.
isNotEmpty
(
jsonObject
.
get
(
"code"
).
toString
()))
{
if
(
"200"
.
equals
(
jsonObject
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
jsonObject
.
get
(
"data"
));
}
}
if
(
StringUtils
.
isNotEmpty
(
jsonObject
.
get
(
"message"
).
toString
()))
{
logger
.
info
(
jsonObject
.
get
(
"message"
).
toString
());
}
return
JsonResult
.
error
(
jsonObject
.
get
(
"message"
).
toString
());
}
/**
* 取消授权
*
* @author Bellamy
* @since 2021-01-18
*/
@Override
public
JsonResult
cancelApiAuth
(
String
id
)
throws
Exception
{
String
url
=
gatewayUrl
+
cancelApiAuth
;
Map
params
=
new
HashMap
();
params
.
put
(
"id"
,
id
);
String
resultData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
params
));
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"失败!"
);
}
logger
.
info
(
"#################响应结果数据{}"
+
resultData
);
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
"200"
.
equals
(
jsonObject
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
jsonObject
.
get
(
"data"
));
}
if
(
StringUtils
.
isNotEmpty
(
jsonObject
.
get
(
"message"
).
toString
()))
{
logger
.
info
(
jsonObject
.
get
(
"message"
).
toString
());
}
return
JsonResult
.
error
(
jsonObject
.
get
(
"message"
).
toString
());
}
/**
* 发布的API-API列表分页查询
*
* @author Bellamy
* @since 2021-01-18
*/
@Override
public
JsonResult
queryApiListPage
(
ApiInterfaceInfoListReq
req
)
throws
Exception
{
String
url
=
gatewayUrl
+
apiListPage
;
String
resultData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
req
));
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"查询失败!"
);
}
logger
.
info
(
"#################响应结果数据{}"
+
resultData
);
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
"200"
.
equals
(
jsonObject
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
jsonObject
.
get
(
"data"
));
}
if
(
StringUtils
.
isNotEmpty
(
jsonObject
.
get
(
"message"
).
toString
()))
{
logger
.
info
(
jsonObject
.
get
(
"message"
).
toString
());
}
return
JsonResult
.
error
(
jsonObject
.
get
(
"message"
).
toString
());
}
/**
* 删除api
*
* @author Bellamy
* @since 2021-01-18
*/
@Override
public
JsonResult
delApiInfo
(
String
apiKey
,
String
type
)
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
String
url
=
gatewayUrl
+
delApi
;
Map
params
=
new
HashMap
();
params
.
put
(
"apiKey"
,
apiKey
);
params
.
put
(
"type"
,
type
);
String
returnData
=
HttpClientUtils
.
getJsonForParam
(
url
,
params
);
if
(
StringUtils
.
isEmpty
(
returnData
))
{
throw
new
RuntimeException
(
"删除失败!"
);
}
logger
.
info
(
"#################响应结果{}"
+
returnData
);
Map
map
=
JSONObject
.
parseObject
(
returnData
);
if
(
"200"
.
equals
(
map
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
();
}
if
(
StringUtils
.
isNotEmpty
(
map
.
get
(
"message"
).
toString
()))
{
logger
.
info
(
map
.
get
(
"message"
).
toString
());
result
.
setMessage
(
map
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
}
return
result
;
}
}
src/main/java/com/jz/dmp/modules/service/impl/DmpOrgMangeServiceImpl.java
View file @
0b6d8222
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.utils.web.HttpClientUtils
;
import
com.jz.common.utils.web.HttpClientUtils
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageDetailQueryReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq
;
import
com.jz.dmp.modules.service.DmpOrgMangeService
;
import
com.jz.dmp.modules.service.DmpOrgMangeService
;
...
@@ -14,7 +15,6 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -14,7 +15,6 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -41,6 +41,9 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
...
@@ -41,6 +41,9 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
//编辑组织url
//编辑组织url
private
static
final
String
updateOrg
=
"/api/organization/update"
;
private
static
final
String
updateOrg
=
"/api/organization/update"
;
//根据组织id获取组织详情url
private
static
final
String
orgDetail
=
"/api/organization/getOrgDetail"
;
@Value
(
"${spring.gateway-url}"
)
@Value
(
"${spring.gateway-url}"
)
private
String
gatewayUrl
;
private
String
gatewayUrl
;
...
@@ -142,4 +145,28 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
...
@@ -142,4 +145,28 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
logger
.
info
(
map
.
get
(
"message"
).
toString
());
logger
.
info
(
map
.
get
(
"message"
).
toString
());
return
JsonResult
.
error
(
map
.
get
(
"message"
).
toString
());
return
JsonResult
.
error
(
map
.
get
(
"message"
).
toString
());
}
}
/**
* 根据组织id获取组织详情
*
* @author Bellamy
* @since 2021-01-18
*/
@Override
public
JsonResult
getOrgInfoByOrgId
(
String
id
)
throws
Exception
{
String
url
=
gatewayUrl
+
orgDetail
;
OrganizationManageDetailQueryReq
req
=
new
OrganizationManageDetailQueryReq
();
req
.
setId
(
Long
.
valueOf
(
id
));
String
returnData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
req
));
if
(
StringUtils
.
isEmpty
(
returnData
))
{
throw
new
RuntimeException
(
"查询失败!"
);
}
logger
.
info
(
"#################响应结果{}"
+
returnData
);
Map
map
=
JSONObject
.
parseObject
(
returnData
);
if
(
"200"
.
equals
(
map
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
map
.
get
(
"data"
));
}
logger
.
info
(
map
.
get
(
"message"
).
toString
());
return
JsonResult
.
error
(
map
.
get
(
"message"
).
toString
());
}
}
}
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