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
23e98c88
Commit
23e98c88
authored
Jan 16, 2021
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
7f78a584
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
999 additions
and
599 deletions
+999
-599
JsonResult.java
src/main/java/com/jz/common/constant/JsonResult.java
+7
-0
ServiceException.java
src/main/java/com/jz/common/exception/ServiceException.java
+2
-0
HttpClientUtils.java
src/main/java/com/jz/common/utils/web/HttpClientUtils.java
+585
-595
DmpOrgMangeController.java
...modules/controller/dataService/DmpOrgMangeController.java
+107
-4
OrganizationManageAddReq.java
...controller/dataService/bean/OrganizationManageAddReq.java
+51
-0
OrganizationManageListQueryReq.java
...ller/dataService/bean/OrganizationManageListQueryReq.java
+27
-0
OrganizationManageUpdateReq.java
...troller/dataService/bean/OrganizationManageUpdateReq.java
+51
-0
DmpOrgMangeService.java
...n/java/com/jz/dmp/modules/service/DmpOrgMangeService.java
+41
-0
DmpOrgMangeServiceImpl.java
...m/jz/dmp/modules/service/impl/DmpOrgMangeServiceImpl.java
+128
-0
No files found.
src/main/java/com/jz/common/constant/JsonResult.java
View file @
23e98c88
...
@@ -96,6 +96,13 @@ public class JsonResult<T> implements Serializable {
...
@@ -96,6 +96,13 @@ public class JsonResult<T> implements Serializable {
return
result
;
return
result
;
}
}
public
static
JsonResult
<
Object
>
error
(
String
message
)
{
JsonResult
<
Object
>
result
=
new
JsonResult
<>();
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
result
.
setMessage
(
message
);
return
result
;
}
public
static
JsonResult
<
Object
>
error
(
ResultCode
code
,
String
message
)
{
public
static
JsonResult
<
Object
>
error
(
ResultCode
code
,
String
message
)
{
JsonResult
<
Object
>
result
=
new
JsonResult
<>();
JsonResult
<
Object
>
result
=
new
JsonResult
<>();
result
.
setCode
(
code
);
result
.
setCode
(
code
);
...
...
src/main/java/com/jz/common/exception/ServiceException.java
View file @
23e98c88
package
com
.
jz
.
common
.
exception
;
package
com
.
jz
.
common
.
exception
;
import
com.jz.common.constant.ResultCode
;
public
class
ServiceException
extends
Exception
{
public
class
ServiceException
extends
Exception
{
private
static
final
long
serialVersionUID
=
1859731705152111160L
;
private
static
final
long
serialVersionUID
=
1859731705152111160L
;
...
...
src/main/java/com/jz/common/utils/web/HttpClientUtils.java
View file @
23e98c88
package
com
.
jz
.
common
.
utils
.
web
;
package
com
.
jz
.
common
.
utils
.
web
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.NameValuePair
;
...
@@ -39,11 +40,9 @@ import java.util.*;
...
@@ -39,11 +40,9 @@ import java.util.*;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
/**
/**
*
* @author hack2003
* @author hack2003
* @date 2016-10-18
* @version v1.0
* @version v1.0
*
*
@date 2016-10-18
*/
*/
public
class
HttpClientUtils
{
public
class
HttpClientUtils
{
...
@@ -78,7 +77,7 @@ public class HttpClientUtils {
...
@@ -78,7 +77,7 @@ public class HttpClientUtils {
// 只允许使用TLSv1协议
// 只允许使用TLSv1协议
SSLConnectionSocketFactory
sslsf
=
new
SSLConnectionSocketFactory
(
SSLConnectionSocketFactory
sslsf
=
new
SSLConnectionSocketFactory
(
sslcontext
,
sslcontext
,
new
String
[]
{
"TLSv1"
},
new
String
[]{
"TLSv1"
},
null
,
null
,
SSLConnectionSocketFactory
.
BROWSER_COMPATIBLE_HOSTNAME_VERIFIER
);
SSLConnectionSocketFactory
.
BROWSER_COMPATIBLE_HOSTNAME_VERIFIER
);
httpclient
=
HttpClients
.
custom
().
setSSLSocketFactory
(
sslsf
)
httpclient
=
HttpClients
.
custom
().
setSSLSocketFactory
(
sslsf
)
...
@@ -123,48 +122,44 @@ public class HttpClientUtils {
...
@@ -123,48 +122,44 @@ public class HttpClientUtils {
}
}
/**
/**
* @discription:
* @param url 访问地址
* @param url 访问地址
* @param token 请求头中存放token
* @param token 请求头中存放token
* @param json 请求数据体
* @param json 请求数据体
* @return
* @return
* @discription:
* @date: 2019年10月25日
* @date: 2019年10月25日
*/
*/
public
static
String
postJsonData
(
String
url
,
String
token
,
String
json
){
public
static
String
postJsonData
(
String
url
,
String
token
,
String
json
)
{
LOGGER
.
info
(
"===================postJsonData start======================="
);
LOGGER
.
info
(
"===================postJsonData start======================="
);
LOGGER
.
info
(
"url:"
+
url
);
LOGGER
.
info
(
"url:"
+
url
);
LOGGER
.
info
(
"token:"
+
token
);
LOGGER
.
info
(
"token:"
+
token
);
LOGGER
.
info
(
"json:"
+
json
);
LOGGER
.
info
(
"json:"
+
json
);
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
CloseableHttpClient
httpClient
=
null
;
CloseableHttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
String
result
=
null
;
try
try
{
{
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
httpPost
=
new
HttpPost
(
url
);
httpPost
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
50000
).
setConnectTimeout
(
50000
).
build
();
//设置请求和传输超时时间
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
50000
).
setConnectTimeout
(
50000
).
build
();
//设置请求和传输超时时间
httpPost
.
setConfig
(
requestConfig
);
httpPost
.
setConfig
(
requestConfig
);
httpPost
.
setHeader
(
"token"
,
token
);
httpPost
.
setHeader
(
"token"
,
token
);
StringEntity
se
=
new
StringEntity
(
json
,
"UTF-8"
);
StringEntity
se
=
new
StringEntity
(
json
,
"UTF-8"
);
se
.
setContentType
(
"application/json"
);
se
.
setContentType
(
"application/json"
);
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
httpPost
.
setEntity
(
se
);
httpPost
.
setEntity
(
se
);
LOGGER
.
info
(
"请求开始时间:"
+
System
.
currentTimeMillis
());
LOGGER
.
info
(
"请求开始时间:"
+
System
.
currentTimeMillis
());
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
LOGGER
.
info
(
"请求结束时间:"
+
System
.
currentTimeMillis
());
LOGGER
.
info
(
"请求结束时间:"
+
System
.
currentTimeMillis
());
if
(
response
!=
null
)
if
(
response
!=
null
)
{
{
HttpEntity
resEntity
=
response
.
getEntity
();
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
if
(
resEntity
!=
null
)
{
{
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
}
}
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
LOGGER
.
info
(
"异常捕捉请求结束时间:"
+
System
.
currentTimeMillis
());
LOGGER
.
info
(
"异常捕捉请求结束时间:"
+
System
.
currentTimeMillis
());
ex
.
printStackTrace
();
ex
.
printStackTrace
();
LOGGER
.
info
(
ex
.
getMessage
());
LOGGER
.
info
(
ex
.
getMessage
());
}
}
...
@@ -273,59 +268,57 @@ public class HttpClientUtils {
...
@@ -273,59 +268,57 @@ public class HttpClientUtils {
/**
/**
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
* @return
*
*
* @return
* @throws IOException
* @throws IOException
* @throws ClientProtocolException
* @throws ClientProtocolException
*/
*/
public
static
String
post
(
String
url
,
String
json
)
public
static
String
post
(
String
url
,
String
json
)
{
{
LOGGER
.
info
(
"===================POST request start======================="
);
String
charset
=
"UTF-8"
;
LOGGER
.
info
(
"url:"
+
url
);
LOGGER
.
info
(
"json:"
+
json
);
String
charset
=
"UTF-8"
;
CloseableHttpClient
httpClient
=
null
;
CloseableHttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
String
result
=
null
;
try
try
{
{
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
httpPost
=
new
HttpPost
(
url
);
httpPost
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
50000
).
setConnectTimeout
(
50000
).
build
();
//设置请求和传输超时时间
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
50000
).
setConnectTimeout
(
50000
).
build
();
//设置请求和传输超时时间
httpPost
.
setConfig
(
requestConfig
);
httpPost
.
setConfig
(
requestConfig
);
StringEntity
se
=
new
StringEntity
(
json
,
"UTF-8"
);
StringEntity
se
=
new
StringEntity
(
json
,
"UTF-8"
);
se
.
setContentType
(
"application/json"
);
se
.
setContentType
(
"application/json"
);
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
System
.
out
.
println
(
"-------------"
+
JSONObject
.
toJSONString
(
se
));
System
.
out
.
println
(
"-------------"
+
JSONObject
.
toJSONString
(
se
));
httpPost
.
setEntity
(
se
);
httpPost
.
setEntity
(
se
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
if
(
response
!=
null
)
if
(
response
!=
null
)
{
{
HttpEntity
resEntity
=
response
.
getEntity
();
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
if
(
resEntity
!=
null
)
{
{
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
}
}
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
LOGGER
.
info
(
"===================POST request end======================="
);
return
result
;
return
result
;
}
}
/**
/**
* 带参
* 带参
*
* @param url
* @param url
* @param paramName
* @param paramName
* @param json
* @param json
* @return
* @return
*/
*/
public
static
String
post
(
String
url
,
String
paramName
,
String
json
)
public
static
String
post
(
String
url
,
String
paramName
,
String
json
)
{
{
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
CloseableHttpClient
httpClient
=
null
;
CloseableHttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
String
result
=
null
;
try
try
{
{
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
httpPost
=
new
HttpPost
(
url
);
httpPost
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
3000
).
setConnectTimeout
(
3000
).
build
();
//设置请求和传输超时时间
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
3000
).
setConnectTimeout
(
3000
).
build
();
//设置请求和传输超时时间
...
@@ -342,16 +335,13 @@ public class HttpClientUtils {
...
@@ -342,16 +335,13 @@ public class HttpClientUtils {
// entityParam.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
// entityParam.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost
.
setEntity
(
entityParam
);
httpPost
.
setEntity
(
entityParam
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
if
(
response
!=
null
)
if
(
response
!=
null
)
{
{
HttpEntity
resEntity
=
response
.
getEntity
();
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
if
(
resEntity
!=
null
)
{
{
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
}
}
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
return
result
;
return
result
;
...
@@ -360,48 +350,44 @@ public class HttpClientUtils {
...
@@ -360,48 +350,44 @@ public class HttpClientUtils {
/**
/**
* 提交JSON参数
* 提交JSON参数
*
* @param url
* @param url
* @param paramName
* @param paramName
* @param json
* @param json
* @return
* @return
*/
*/
public
static
String
postJson
(
String
url
,
String
paramName
,
String
json
)
public
static
String
postJson
(
String
url
,
String
paramName
,
String
json
)
{
{
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
CloseableHttpClient
httpClient
=
null
;
CloseableHttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
String
result
=
null
;
try
try
{
{
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
httpPost
=
new
HttpPost
(
url
);
httpPost
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
3000
).
setConnectTimeout
(
3000
).
build
();
//设置请求和传输超时时间
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
3000
).
setConnectTimeout
(
3000
).
build
();
//设置请求和传输超时时间
httpPost
.
setConfig
(
requestConfig
);
httpPost
.
setConfig
(
requestConfig
);
StringEntity
se
=
new
StringEntity
(
json
,
"UTF-8"
);
StringEntity
se
=
new
StringEntity
(
json
,
"UTF-8"
);
se
.
setContentType
(
"application/json"
);
se
.
setContentType
(
"application/json"
);
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
httpPost
.
setEntity
(
se
);
httpPost
.
setEntity
(
se
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
if
(
response
!=
null
)
if
(
response
!=
null
)
{
{
HttpEntity
resEntity
=
response
.
getEntity
();
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
if
(
resEntity
!=
null
)
{
{
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
}
}
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
return
result
;
return
result
;
}
}
public
static
String
dopost
(
String
url
,
String
json
)
throws
ClientProtocolException
,
IOException
{
public
static
String
dopost
(
String
url
,
String
json
)
throws
ClientProtocolException
,
IOException
{
String
result
=
null
;
String
result
=
null
;
String
APPLICATION_JSON
=
"application/json"
;
String
APPLICATION_JSON
=
"application/json"
;
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
// 将JSON进行UTF-8编码,以便传输中文
// 将JSON进行UTF-8编码,以便传输中文
String
encoderJson
=
URLEncoder
.
encode
(
json
,
charset
);
String
encoderJson
=
URLEncoder
.
encode
(
json
,
charset
);
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
...
@@ -409,15 +395,15 @@ public class HttpClientUtils {
...
@@ -409,15 +395,15 @@ public class HttpClientUtils {
httppost
.
addHeader
(
HTTP
.
CONTENT_TYPE
,
APPLICATION_JSON
);
httppost
.
addHeader
(
HTTP
.
CONTENT_TYPE
,
APPLICATION_JSON
);
StringEntity
stringEntity
=
new
StringEntity
(
encoderJson
);
StringEntity
stringEntity
=
new
StringEntity
(
encoderJson
);
stringEntity
.
setContentType
(
"text/json"
);
stringEntity
.
setContentType
(
"text/json"
);
stringEntity
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
APPLICATION_JSON
));
stringEntity
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
APPLICATION_JSON
));
httppost
.
setEntity
(
stringEntity
);
httppost
.
setEntity
(
stringEntity
);
//System.out.println("executing request " + httppost.getURI());
//System.out.println("executing request " + httppost.getURI());
CloseableHttpResponse
response
=
httpclient
.
execute
(
httppost
);
CloseableHttpResponse
response
=
httpclient
.
execute
(
httppost
);
if
(
response
.
getStatusLine
().
getStatusCode
()
==
200
)
{
if
(
response
.
getStatusLine
().
getStatusCode
()
==
200
)
{
HttpEntity
httpEntity
=
response
.
getEntity
();
HttpEntity
httpEntity
=
response
.
getEntity
();
if
(
httpEntity
!=
null
)
{
if
(
httpEntity
!=
null
)
{
System
.
out
.
println
(
"Response content: "
+
EntityUtils
.
toString
(
httpEntity
,
charset
));
System
.
out
.
println
(
"Response content: "
+
EntityUtils
.
toString
(
httpEntity
,
charset
));
result
=
EntityUtils
.
toString
(
httpEntity
,
charset
);
result
=
EntityUtils
.
toString
(
httpEntity
,
charset
);
}
}
}
else
{
}
else
{
httppost
.
abort
();
httppost
.
abort
();
...
@@ -433,24 +419,26 @@ public class HttpClientUtils {
...
@@ -433,24 +419,26 @@ public class HttpClientUtils {
return
result
;
return
result
;
}
}
/**http请求资源,json不编码
/**
* http请求资源,json不编码
*
* @param url
* @param url
* @param json
* @param json
* @return
* @return
* @throws ClientProtocolException
* @throws ClientProtocolException
* @throws IOException
* @throws IOException
*/
*/
public
static
String
dopostNoEncode
(
String
url
,
String
json
)
throws
ClientProtocolException
,
IOException
{
public
static
String
dopostNoEncode
(
String
url
,
String
json
)
throws
ClientProtocolException
,
IOException
{
String
result
=
null
;
String
result
=
null
;
String
APPLICATION_JSON
=
"application/json"
;
String
APPLICATION_JSON
=
"application/json"
;
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
// 将JSON进行UTF-8编码,以便传输中文
// 将JSON进行UTF-8编码,以便传输中文
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
HttpPost
httppost
=
new
HttpPost
(
url
);
HttpPost
httppost
=
new
HttpPost
(
url
);
httppost
.
addHeader
(
HTTP
.
CONTENT_TYPE
,
APPLICATION_JSON
);
httppost
.
addHeader
(
HTTP
.
CONTENT_TYPE
,
APPLICATION_JSON
);
StringEntity
stringEntity
=
new
StringEntity
(
json
,
charset
);
StringEntity
stringEntity
=
new
StringEntity
(
json
,
charset
);
stringEntity
.
setContentType
(
"text/json"
);
stringEntity
.
setContentType
(
"text/json"
);
stringEntity
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
APPLICATION_JSON
));
stringEntity
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
APPLICATION_JSON
));
httppost
.
setEntity
(
stringEntity
);
httppost
.
setEntity
(
stringEntity
);
//System.out.println("executing request " + httppost.getURI());
//System.out.println("executing request " + httppost.getURI());
CloseableHttpResponse
response
=
httpclient
.
execute
(
httppost
);
CloseableHttpResponse
response
=
httpclient
.
execute
(
httppost
);
...
@@ -458,7 +446,7 @@ public class HttpClientUtils {
...
@@ -458,7 +446,7 @@ public class HttpClientUtils {
HttpEntity
httpEntity
=
response
.
getEntity
();
HttpEntity
httpEntity
=
response
.
getEntity
();
if
(
httpEntity
!=
null
)
{
if
(
httpEntity
!=
null
)
{
//System.out.println("Response content: "+ EntityUtils.toString(httpEntity, charset));
//System.out.println("Response content: "+ EntityUtils.toString(httpEntity, charset));
result
=
EntityUtils
.
toString
(
httpEntity
,
charset
);
result
=
EntityUtils
.
toString
(
httpEntity
,
charset
);
}
}
}
else
{
}
else
{
httppost
.
abort
();
httppost
.
abort
();
...
@@ -477,19 +465,17 @@ public class HttpClientUtils {
...
@@ -477,19 +465,17 @@ public class HttpClientUtils {
/**
/**
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
* @return
*
*
* @return
* @throws IOException
* @throws IOException
* @throws ClientProtocolException
* @throws ClientProtocolException
*/
*/
public
static
String
postJson
(
String
url
,
com
.
alibaba
.
fastjson
.
JSONObject
json
)
public
static
String
postJson
(
String
url
,
com
.
alibaba
.
fastjson
.
JSONObject
json
)
{
{
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
CloseableHttpClient
httpClient
=
null
;
CloseableHttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
String
result
=
null
;
try
try
{
{
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
httpPost
=
new
HttpPost
(
url
);
httpPost
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
10000
).
setConnectTimeout
(
10000
).
build
();
//设置请求和传输超时时间
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
10000
).
setConnectTimeout
(
10000
).
build
();
//设置请求和传输超时时间
...
@@ -499,23 +485,19 @@ public class HttpClientUtils {
...
@@ -499,23 +485,19 @@ public class HttpClientUtils {
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
httpPost
.
setEntity
(
se
);
httpPost
.
setEntity
(
se
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
if
(
response
!=
null
)
if
(
response
!=
null
)
{
{
HttpEntity
resEntity
=
response
.
getEntity
();
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
if
(
resEntity
!=
null
)
{
{
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
result
=
EntityUtils
.
toString
(
resEntity
,
charset
);
}
}
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
return
result
;
return
result
;
}
}
/**
/**
* get请求,返回字节数组
* get请求,返回字节数组
*
*
...
@@ -561,16 +543,16 @@ public class HttpClientUtils {
...
@@ -561,16 +543,16 @@ public class HttpClientUtils {
try
{
try
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpGet
);
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpGet
);
HttpEntity
resEntity
=
null
;
HttpEntity
resEntity
=
null
;
if
(
response
.
getStatusLine
().
getStatusCode
()
==
200
)
{
// 请求成功状态
if
(
response
.
getStatusLine
().
getStatusCode
()
==
200
)
{
// 请求成功状态
resEntity
=
response
.
getEntity
();
resEntity
=
response
.
getEntity
();
}
}
if
(
resEntity
!=
null
){
if
(
resEntity
!=
null
)
{
responseContent
=
EntityUtils
.
toByteArray
(
resEntity
);
responseContent
=
EntityUtils
.
toByteArray
(
resEntity
);
// result = EntityUtils.toString(resEntity,charset);
// result = EntityUtils.toString(resEntity,charset);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"异常捕捉请求结束时间:"
+
System
.
currentTimeMillis
());
LOGGER
.
info
(
"异常捕捉请求结束时间:"
+
System
.
currentTimeMillis
());
e
.
printStackTrace
();
e
.
printStackTrace
();
LOGGER
.
info
(
e
.
getMessage
());
LOGGER
.
info
(
e
.
getMessage
());
}
}
...
@@ -580,53 +562,52 @@ public class HttpClientUtils {
...
@@ -580,53 +562,52 @@ public class HttpClientUtils {
/**
/**
* @discription:
* @param url 访问地址
* @param url 访问地址
* @param token 请求头中存放token
* @param token 请求头中存放token
* @param json 请求数据体
* @param json 请求数据体
* @return
* @return
* @discription:
* @date: 2019年10月25日
* @date: 2019年10月25日
*/
*/
public
static
byte
[]
postJsonDataByByte
(
String
url
,
String
token
,
String
json
){
public
static
byte
[]
postJsonDataByByte
(
String
url
,
String
token
,
String
json
)
{
LOGGER
.
info
(
"===================postJsonDataByByte start======================="
);
LOGGER
.
info
(
"===================postJsonDataByByte start======================="
);
LOGGER
.
info
(
"url:"
+
url
);
LOGGER
.
info
(
"url:"
+
url
);
LOGGER
.
info
(
"token:"
+
token
);
LOGGER
.
info
(
"token:"
+
token
);
LOGGER
.
info
(
"json:"
+
json
);
LOGGER
.
info
(
"json:"
+
json
);
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
CloseableHttpClient
httpClient
=
null
;
CloseableHttpClient
httpClient
=
null
;
HttpPost
httpPost
=
null
;
HttpPost
httpPost
=
null
;
String
result
=
null
;
String
result
=
null
;
byte
[]
responseContent
=
null
;
byte
[]
responseContent
=
null
;
try
try
{
{
httpClient
=
HttpClients
.
createDefault
();
httpClient
=
HttpClients
.
createDefault
();
httpPost
=
new
HttpPost
(
url
);
httpPost
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
50000
).
setConnectTimeout
(
50000
).
build
();
//设置请求和传输超时时间
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
50000
).
setConnectTimeout
(
50000
).
build
();
//设置请求和传输超时时间
httpPost
.
setConfig
(
requestConfig
);
httpPost
.
setConfig
(
requestConfig
);
httpPost
.
setHeader
(
"token"
,
token
);
httpPost
.
setHeader
(
"token"
,
token
);
StringEntity
se
=
new
StringEntity
(
json
,
"UTF-8"
);
StringEntity
se
=
new
StringEntity
(
json
,
"UTF-8"
);
se
.
setContentType
(
"application/json"
);
se
.
setContentType
(
"application/json"
);
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
se
.
setContentEncoding
(
new
BasicHeader
(
HTTP
.
CONTENT_TYPE
,
"application/json"
));
httpPost
.
setEntity
(
se
);
httpPost
.
setEntity
(
se
);
LOGGER
.
info
(
"请求开始时间:"
+
System
.
currentTimeMillis
());
LOGGER
.
info
(
"请求开始时间:"
+
System
.
currentTimeMillis
());
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
LOGGER
.
info
(
"请求结束时间:"
+
System
.
currentTimeMillis
());
LOGGER
.
info
(
"请求结束时间:"
+
System
.
currentTimeMillis
());
if
(
response
!=
null
){
if
(
response
!=
null
)
{
HttpEntity
resEntity
=
response
.
getEntity
();
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
response
.
getStatusLine
().
getStatusCode
()
==
200
)
{
if
(
response
.
getStatusLine
().
getStatusCode
()
==
200
)
{
if
(
resEntity
!=
null
){
if
(
resEntity
!=
null
)
{
responseContent
=
EntityUtils
.
toByteArray
(
resEntity
);
responseContent
=
EntityUtils
.
toByteArray
(
resEntity
);
}
}
}
else
{
}
else
{
LOGGER
.
info
(
"请求失败:"
+
EntityUtils
.
toString
(
resEntity
,
charset
));
LOGGER
.
info
(
"请求失败:"
+
EntityUtils
.
toString
(
resEntity
,
charset
));
return
responseContent
;
return
responseContent
;
}
}
}
}
}
catch
(
Exception
ex
){
}
catch
(
Exception
ex
)
{
LOGGER
.
info
(
"异常捕捉请求结束时间:"
+
System
.
currentTimeMillis
());
LOGGER
.
info
(
"异常捕捉请求结束时间:"
+
System
.
currentTimeMillis
());
ex
.
printStackTrace
();
ex
.
printStackTrace
();
LOGGER
.
info
(
ex
.
getMessage
());
LOGGER
.
info
(
ex
.
getMessage
());
}
}
...
@@ -636,29 +617,39 @@ public class HttpClientUtils {
...
@@ -636,29 +617,39 @@ public class HttpClientUtils {
/**
/**
* 发送 getJsonForParam请求
* 发送 getJsonForParam请求
* @author Bellamy
*/
*/
public
static
String
getJsonForParam
(
String
url
,
Map
<
String
,
Object
>
paramMap
)
{
public
static
String
getJsonForParam
(
String
url
,
Map
<
String
,
Object
>
paramMap
)
{
LOGGER
.
info
(
"===================
getJsonForParam start======================="
);
LOGGER
.
info
(
"===================Get request
getJsonForParam start======================="
);
LOGGER
.
info
(
"url:"
+
url
);
LOGGER
.
info
(
"url:"
+
url
);
LOGGER
.
info
(
"json:"
+
paramMap
);
LOGGER
.
info
(
"json:"
+
paramMap
);
String
result
=
null
;
String
result
=
null
;
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
String
fh
=
""
;
if
(
paramMap
!=
null
)
{
if
(
url
.
indexOf
(
"?"
)
==
-
1
)
{
fh
=
"?"
;
}
for
(
Entry
<
String
,
Object
>
entry
:
paramMap
.
entrySet
())
{
for
(
Entry
<
String
,
Object
>
entry
:
paramMap
.
entrySet
())
{
sb
.
append
(
"&"
);
sb
.
append
(
"&"
);
sb
.
append
(
entry
.
getKey
());
sb
.
append
(
entry
.
getKey
());
sb
.
append
(
"="
);
sb
.
append
(
"="
);
sb
.
append
(
entry
.
getValue
());
sb
.
append
(
entry
.
getValue
());
}
}
}
if
(
StringUtils
.
isNotEmpty
(
sb
))
{
fh
+=
sb
.
toString
().
substring
(
1
);
}
String
requestUrl
=
url
+
sb
.
toString
()
;
String
requestUrl
=
url
+
fh
;
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
try
{
try
{
// 创建httpget.
// 创建httpget.
HttpGet
httpget
=
new
HttpGet
(
requestUrl
);
HttpGet
httpget
=
new
HttpGet
(
requestUrl
);
System
.
out
.
println
(
"
executing request "
+
httpget
.
getURI
());
System
.
out
.
println
(
"get
executing request "
+
httpget
.
getURI
());
// 执行get请求.
// 执行get请求.
CloseableHttpResponse
response
=
httpclient
.
execute
(
httpget
);
CloseableHttpResponse
response
=
httpclient
.
execute
(
httpget
);
// 获取响应实体
// 获取响应实体
...
@@ -685,7 +676,6 @@ public class HttpClientUtils {
...
@@ -685,7 +676,6 @@ public class HttpClientUtils {
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// 私钥
// 私钥
/*String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJzAfk55exxmvy3+pXsJINZEtmwUp6eBfDSl2YnT5bdJL3nzPnSjmaWsf8x9hR4QyGnvlV/Vo0sk36X7ATcqxfIn0+6W5f8IR4XtVDhxZsD/cK8nVThqFGQagmyNAwxP/wBnAXOy+fpwZrMOgqfosYmVsmImFWbHA87C4mx0bwoJAgMBAAECgYB4tlBOVIT3ITTW0cRT1HrCJxYoc1uMxk2FKbc1ycWceTKjgiu1nQtEp2ufaYYq2hfMZOEudRIUWygT5RFRj5HxLfL6Me3y6dtgyHvOVeMDNGAG+tsn8ObQCQjZ/hVKzFFgHlrHv5i4zX44im2IdvLqnV6cEUneduJfZAQT/XTGUQJBANAZbuTqlDRj/9ObGZEvaPe95FGAPNFEiNmRvLsCsRmruJA5h2ogwx8O4Yll5LylKV6C33Vws4pgAPBHvOzGTx0CQQDA1VYU4ihNyvMknFIAmMT2ojQmQ8ASX64hVFWY9ehf5JaJ+ZD1c1BvbrmubpIo7pPci50BmXnjq6EcxVML/VbdAkAwEH/FjczXYPV4yY0ZNIsZFZoDnQvvBdZZ8khWJWQEWt5RKYh2YcTPip9bHda8H6Wzd6TnOjWt00jENr2TLqadAkEAq0TQD/xOj8mR6xJsQtttFSE78EB8d9VDc5bT7+d5XLJKgoGGnnqtFkvh32uVpYVBDsFx0dneyLfHgSZBfISmgQJADZ71qrfCDvuoYNS4aOW52OL6LMC84Qi2EnZzl5OHkUuOv5jwBoOCRLEn0N999EMP6DBg8P5kg1llTq7bMG11ug==";
/*String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJzAfk55exxmvy3+pXsJINZEtmwUp6eBfDSl2YnT5bdJL3nzPnSjmaWsf8x9hR4QyGnvlV/Vo0sk36X7ATcqxfIn0+6W5f8IR4XtVDhxZsD/cK8nVThqFGQagmyNAwxP/wBnAXOy+fpwZrMOgqfosYmVsmImFWbHA87C4mx0bwoJAgMBAAECgYB4tlBOVIT3ITTW0cRT1HrCJxYoc1uMxk2FKbc1ycWceTKjgiu1nQtEp2ufaYYq2hfMZOEudRIUWygT5RFRj5HxLfL6Me3y6dtgyHvOVeMDNGAG+tsn8ObQCQjZ/hVKzFFgHlrHv5i4zX44im2IdvLqnV6cEUneduJfZAQT/XTGUQJBANAZbuTqlDRj/9ObGZEvaPe95FGAPNFEiNmRvLsCsRmruJA5h2ogwx8O4Yll5LylKV6C33Vws4pgAPBHvOzGTx0CQQDA1VYU4ihNyvMknFIAmMT2ojQmQ8ASX64hVFWY9ehf5JaJ+ZD1c1BvbrmubpIo7pPci50BmXnjq6EcxVML/VbdAkAwEH/FjczXYPV4yY0ZNIsZFZoDnQvvBdZZ8khWJWQEWt5RKYh2YcTPip9bHda8H6Wzd6TnOjWt00jENr2TLqadAkEAq0TQD/xOj8mR6xJsQtttFSE78EB8d9VDc5bT7+d5XLJKgoGGnnqtFkvh32uVpYVBDsFx0dneyLfHgSZBfISmgQJADZ71qrfCDvuoYNS4aOW52OL6LMC84Qi2EnZzl5OHkUuOv5jwBoOCRLEn0N999EMP6DBg8P5kg1llTq7bMG11ug==";
...
...
src/main/java/com/jz/dmp/modules/controller/dataService/DmpOrgMangeController.java
View file @
23e98c88
package
com
.
jz
.
dmp
.
modules
.
controller
.
dataService
;
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.dataOperation.bean.DataDevTaskListDto
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq
;
import
com.jz.dmp.modules.service.DmpOrgMangeService
;
import
com.jz.dmp.modules.service.DmpOrgMangeService
;
import
com.jz.dmp.modules.service.DvRuleTService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
/**
/**
* 数据服务组织管理
* 数据服务组织管理
--调用gateway 接口
*
*
* @author Bellamy
* @author Bellamy
* @since 2020-12-24 10:56:18
* @since 2020-12-24 10:56:18
...
@@ -17,11 +29,102 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -17,11 +29,102 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"/orgMange"
)
@RequestMapping
(
"/orgMange"
)
@Api
(
tags
=
"数据服务-组织管理"
)
@Api
(
tags
=
"数据服务-组织管理"
)
public
class
DmpOrgMangeController
{
public
class
DmpOrgMangeController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DmpOrgMangeController
.
class
);
/**
/**
* 服务对象
* 服务对象
*/
*/
@Autowired
@Autowired
private
DmpOrgMangeService
dmpOrgMangeService
;
private
DmpOrgMangeService
dmpOrgMangeService
;
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation
(
value
=
"列表分页查询"
,
notes
=
"列表分页查询"
)
@PostMapping
(
value
=
"/listPage"
)
public
JsonResult
getOrgListPage
(
@RequestBody
@Validated
OrganizationManageListQueryReq
req
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpOrgMangeService
.
queryOrgListPage
(
req
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation
(
value
=
"删除组织"
,
notes
=
"删除组织"
)
@GetMapping
(
value
=
"/delOrg"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"组织id"
,
required
=
true
)
public
JsonResult
delOrgById
(
@RequestParam
long
id
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpOrgMangeService
.
delOrgById
(
id
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation
(
value
=
"新增组织"
,
notes
=
"新增组织"
)
@PostMapping
(
value
=
"/addOrg"
)
public
JsonResult
addOrg
(
@RequestBody
@Validated
OrganizationManageAddReq
req
,
HttpServletRequest
httpRequest
)
{
if
(
StringUtils
.
isEmpty
(
req
.
getOrgName
()))
{
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"组织名称不能为空!"
);
}
if
(
StringUtils
.
isEmpty
(
req
.
getOrgType
()))
{
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"组织类型不能为空!"
);
}
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpOrgMangeService
.
addOrg
(
req
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation
(
value
=
"编辑组织"
,
notes
=
"编辑组织"
)
@PostMapping
(
value
=
"/updateOrg"
)
public
JsonResult
updateOrg
(
@RequestBody
@Validated
OrganizationManageUpdateReq
req
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpOrgMangeService
.
updateOrg
(
req
);
}
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/OrganizationManageAddReq.java
0 → 100644
View file @
23e98c88
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.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @ClassName: OrganizationManageAddReq
* @Description: 新增组织管理请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel
(
"新增组织管理详情请求体"
)
public
class
OrganizationManageAddReq
implements
Serializable
{
private
static
final
long
serialVersionUID
=
3131683881168540907L
;
@ApiModelProperty
(
value
=
"组织类型:INT 内部组织 OUT 外部组织"
,
required
=
true
)
@NotNull
(
message
=
"组织类型不能为空!"
)
@NotEmpty
(
message
=
"组织类型不能为空!"
)
private
String
orgType
;
@ApiModelProperty
(
value
=
"组织名称"
,
required
=
true
)
@NotNull
(
message
=
"组织名称不能为空"
)
@NotEmpty
(
message
=
"组织名称不能为空!"
)
private
String
orgName
;
@ApiModelProperty
(
value
=
"组织描述"
,
required
=
false
)
private
String
orgDesc
;
@ApiModelProperty
(
value
=
"组织英文名称"
,
required
=
false
)
private
String
orgCnName
;
@ApiModelProperty
(
value
=
"组织邮箱"
,
required
=
false
)
private
String
orgMail
;
@ApiModelProperty
(
value
=
"联系方式"
,
required
=
true
)
@NotEmpty
(
message
=
"联系方式不能为空!"
)
private
String
orgPhone
;
@ApiModelProperty
(
value
=
"状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)"
,
required
=
true
)
private
String
status
;
@ApiModelProperty
(
value
=
"联系人"
,
required
=
true
)
private
String
createUser
;
}
src/main/java/com/jz/dmp/modules/controller/dataService/bean/OrganizationManageListQueryReq.java
0 → 100644
View file @
23e98c88
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: DmpOrgMangeService
* @Description: 组织管理列表查询请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel
(
"组织管理列表查询请求体"
)
public
class
OrganizationManageListQueryReq
extends
BasePageBean
implements
Serializable
{
@ApiModelProperty
(
value
=
"组织名称"
)
private
String
orgName
;
@ApiModelProperty
(
value
=
"组织编码(组织唯一标识)"
)
private
String
orgCode
;
}
src/main/java/com/jz/dmp/modules/controller/dataService/bean/OrganizationManageUpdateReq.java
0 → 100644
View file @
23e98c88
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
;
/**
* @ClassName: OrganizationManageUpdateReq
* @Description: 更新组织管理请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel
(
"更新组织管理请求体"
)
public
class
OrganizationManageUpdateReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"组织id"
,
required
=
true
)
@NotNull
(
message
=
"组织id不能为空"
)
private
Long
id
;
/* @ApiModelProperty(value = "组织名称",required = true)
@NotNull(message = "组织名称不能为空")
private String orgName;*/
@ApiModelProperty
(
value
=
"组织描述"
,
required
=
false
)
private
String
orgDesc
;
@ApiModelProperty
(
value
=
"状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)"
,
required
=
false
)
private
String
status
;
@ApiModelProperty
(
value
=
"组织英文名称"
,
required
=
false
)
private
String
orgCnName
;
@ApiModelProperty
(
value
=
"组织邮箱"
,
required
=
false
)
private
String
orgMail
;
@ApiModelProperty
(
value
=
"组织电话"
,
required
=
false
)
private
String
orgPhone
;
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
private
String
updateUser
;
}
src/main/java/com/jz/dmp/modules/service/DmpOrgMangeService.java
View file @
23e98c88
package
com
.
jz
.
dmp
.
modules
.
service
;
package
com
.
jz
.
dmp
.
modules
.
service
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq
;
/**
/**
* @ClassName: DmpOrgMangeService
* @ClassName: DmpOrgMangeService
* @Description: 数据服务组织管理
* @Description: 数据服务组织管理
...
@@ -8,4 +13,40 @@ package com.jz.dmp.modules.service;
...
@@ -8,4 +13,40 @@ package com.jz.dmp.modules.service;
* @Version 1.0
* @Version 1.0
*/
*/
public
interface
DmpOrgMangeService
{
public
interface
DmpOrgMangeService
{
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult
queryOrgListPage
(
OrganizationManageListQueryReq
req
)
throws
Exception
;
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult
delOrgById
(
long
id
)
throws
Exception
;
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult
addOrg
(
OrganizationManageAddReq
req
)
throws
Exception
;
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult
updateOrg
(
OrganizationManageUpdateReq
req
)
throws
Exception
;
}
}
src/main/java/com/jz/dmp/modules/service/impl/DmpOrgMangeServiceImpl.java
View file @
23e98c88
package
com
.
jz
.
dmp
.
modules
.
service
.
impl
;
package
com
.
jz
.
dmp
.
modules
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.constant.JsonResult
;
import
com.jz.common.utils.web.HttpClientUtils
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq
;
import
com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq
;
import
com.jz.dmp.modules.service.DmpOrgMangeService
;
import
com.jz.dmp.modules.service.DmpOrgMangeService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @ClassName: DmpOrgMangeServiceImpl
* @ClassName: DmpOrgMangeServiceImpl
* @Description: 数据服务组织管理
* @Description: 数据服务组织管理
...
@@ -13,5 +27,119 @@ import org.springframework.stereotype.Service;
...
@@ -13,5 +27,119 @@ import org.springframework.stereotype.Service;
@Service
(
"dmpOrgMangeService"
)
@Service
(
"dmpOrgMangeService"
)
public
class
DmpOrgMangeServiceImpl
implements
DmpOrgMangeService
{
public
class
DmpOrgMangeServiceImpl
implements
DmpOrgMangeService
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DmpOrgMangeServiceImpl
.
class
);
//列表分页查询url
private
static
final
String
orgListPage
=
"/api/organization/listOrg"
;
//删除组织url
private
static
final
String
delOrg
=
"/api/organization/logoutOrg"
;
//新增组织url
private
static
final
String
addOrg
=
"/api/organization/add"
;
//编辑组织url
private
static
final
String
updateOrg
=
"/api/organization/update"
;
@Value
(
"${spring.gateway-url}"
)
private
String
gatewayUrl
;
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public
JsonResult
queryOrgListPage
(
OrganizationManageListQueryReq
req
)
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
String
url
=
gatewayUrl
+
orgListPage
;
if
(
StringUtils
.
isNotEmpty
(
req
.
getOrgName
()))
{
req
.
setOrgName
(
req
.
getOrgName
().
trim
());
}
String
resultData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
req
));
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"查询失败!"
);
}
logger
.
info
(
"#################组织管理列数据{}"
+
resultData
);
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
jsonObject
!=
null
)
{
result
.
setData
(
jsonObject
.
get
(
"data"
));
/*Map records = JSONObject.parseObject(jsonObject.get("data").toString());
List<Map> list = (List<Map>) records.get("records");*/
}
return
result
;
}
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public
JsonResult
delOrgById
(
long
id
)
throws
Exception
{
Map
params
=
new
HashMap
();
params
.
put
(
"id"
,
id
);
String
url
=
gatewayUrl
+
delOrg
;
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
();
}
return
JsonResult
.
error
(
"删除失败!"
);
}
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public
JsonResult
addOrg
(
OrganizationManageAddReq
req
)
throws
Exception
{
String
url
=
gatewayUrl
+
addOrg
;
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
();
}
logger
.
info
(
map
.
get
(
"message"
).
toString
());
return
JsonResult
.
error
(
map
.
get
(
"message"
).
toString
());
}
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public
JsonResult
updateOrg
(
OrganizationManageUpdateReq
req
)
throws
Exception
{
String
url
=
gatewayUrl
+
updateOrg
;
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
();
}
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