diff --git a/common/common-utils/pom.xml b/common/common-utils/pom.xml
index d8dcd25..40082a6 100644
--- a/common/common-utils/pom.xml
+++ b/common/common-utils/pom.xml
@@ -1,4 +1,4 @@
-
4.0.0
@@ -19,10 +19,9 @@
- junit
- junit
- 3.8.1
- test
+ org.apache.httpcomponents
+ httpclient
+ 4.5.14
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/constant/ExceptionConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/ExceptionConstant.java
similarity index 94%
rename from common/service-utils/src/main/java/cn/bunny/common/service/constant/ExceptionConstant.java
rename to common/common-utils/src/main/java/cn/bunny/common/constant/ExceptionConstant.java
index 37b4cc2..64e0094 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/constant/ExceptionConstant.java
+++ b/common/common-utils/src/main/java/cn/bunny/common/constant/ExceptionConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.service.constant;
+package cn.bunny.common.constant;
import lombok.Data;
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/constant/LocalDateTimeConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/LocalDateTimeConstant.java
similarity index 89%
rename from common/service-utils/src/main/java/cn/bunny/common/service/constant/LocalDateTimeConstant.java
rename to common/common-utils/src/main/java/cn/bunny/common/constant/LocalDateTimeConstant.java
index d137e64..1494b3c 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/constant/LocalDateTimeConstant.java
+++ b/common/common-utils/src/main/java/cn/bunny/common/constant/LocalDateTimeConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.service.constant;
+package cn.bunny.common.constant;
import lombok.Data;
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/constant/MessageConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/MessageConstant.java
similarity index 98%
rename from common/service-utils/src/main/java/cn/bunny/common/service/constant/MessageConstant.java
rename to common/common-utils/src/main/java/cn/bunny/common/constant/MessageConstant.java
index 4292a28..1e6f631 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/constant/MessageConstant.java
+++ b/common/common-utils/src/main/java/cn/bunny/common/constant/MessageConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.service.constant;
+package cn.bunny.common.constant;
import lombok.Data;
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/constant/PasswordConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/PasswordConstant.java
similarity index 92%
rename from common/service-utils/src/main/java/cn/bunny/common/service/constant/PasswordConstant.java
rename to common/common-utils/src/main/java/cn/bunny/common/constant/PasswordConstant.java
index cb15e4f..0633ea0 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/constant/PasswordConstant.java
+++ b/common/common-utils/src/main/java/cn/bunny/common/constant/PasswordConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.service.constant;
+package cn.bunny.common.constant;
import lombok.Data;
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/constant/RedisUserConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/RedisUserConstant.java
similarity index 78%
rename from common/service-utils/src/main/java/cn/bunny/common/service/constant/RedisUserConstant.java
rename to common/common-utils/src/main/java/cn/bunny/common/constant/RedisUserConstant.java
index 835cf7b..ca4b151 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/constant/RedisUserConstant.java
+++ b/common/common-utils/src/main/java/cn/bunny/common/constant/RedisUserConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.service.constant;
+package cn.bunny.common.constant;
import lombok.Data;
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/constant/StatusConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/StatusConstant.java
similarity index 84%
rename from common/service-utils/src/main/java/cn/bunny/common/service/constant/StatusConstant.java
rename to common/common-utils/src/main/java/cn/bunny/common/constant/StatusConstant.java
index 8006096..d91412f 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/constant/StatusConstant.java
+++ b/common/common-utils/src/main/java/cn/bunny/common/constant/StatusConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.service.constant;
+package cn.bunny.common.constant;
import lombok.Data;
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/constant/UserConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/UserConstant.java
similarity index 85%
rename from common/service-utils/src/main/java/cn/bunny/common/service/constant/UserConstant.java
rename to common/common-utils/src/main/java/cn/bunny/common/constant/UserConstant.java
index 9d914aa..8d2ee23 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/constant/UserConstant.java
+++ b/common/common-utils/src/main/java/cn/bunny/common/constant/UserConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.service.constant;
+package cn.bunny.common.constant;
import lombok.Data;
diff --git a/common/common-utils/src/main/java/cn/bunny/common/utils/HttpUtils.java b/common/common-utils/src/main/java/cn/bunny/common/utils/HttpUtils.java
new file mode 100644
index 0000000..42ce443
--- /dev/null
+++ b/common/common-utils/src/main/java/cn/bunny/common/utils/HttpUtils.java
@@ -0,0 +1,206 @@
+package cn.bunny.common.utils;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpUtils {
+ public static HttpResponse doGet(String host, String path, String method, Map headers, Map querys) throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpGet request = new HttpGet(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ return httpClient.execute(request);
+ }
+
+ public static HttpResponse doPost(String host, String path, String method, Map headers, Map querys, Map bodys) throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (bodys != null) {
+ List nameValuePairList = new ArrayList();
+
+ for (String key : bodys.keySet()) {
+ nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
+ }
+ UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
+ formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
+ request.setEntity(formEntity);
+ }
+
+ return httpClient.execute(request);
+ }
+
+
+ public static HttpResponse doPost(String host, String path, String method, Map headers, Map querys, String body) throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (StringUtils.isNotBlank(body)) {
+ request.setEntity(new StringEntity(body, "utf-8"));
+ }
+
+ return httpClient.execute(request);
+ }
+
+
+ public static HttpResponse doPost(String host, String path, String method, Map headers, Map querys, byte[] body) throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPost request = new HttpPost(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (body != null) {
+ request.setEntity(new ByteArrayEntity(body));
+ }
+
+ return httpClient.execute(request);
+ }
+
+
+ public static HttpResponse doPut(String host, String path, String method, Map headers, Map querys, String body) throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPut request = new HttpPut(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (StringUtils.isNotBlank(body)) {
+ request.setEntity(new StringEntity(body, "utf-8"));
+ }
+
+ return httpClient.execute(request);
+ }
+
+
+ public static HttpResponse doPut(String host, String path, String method, Map headers, Map querys, byte[] body) throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpPut request = new HttpPut(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ if (body != null) {
+ request.setEntity(new ByteArrayEntity(body));
+ }
+
+ return httpClient.execute(request);
+ }
+
+
+ public static HttpResponse doDelete(String host, String path, String method, Map headers, Map querys) throws Exception {
+ HttpClient httpClient = wrapClient(host);
+
+ HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
+ for (Map.Entry e : headers.entrySet()) {
+ request.addHeader(e.getKey(), e.getValue());
+ }
+
+ return httpClient.execute(request);
+ }
+
+ private static String buildUrl(String host, String path, Map querys) throws UnsupportedEncodingException {
+ StringBuilder sbUrl = new StringBuilder();
+ sbUrl.append(host);
+ if (!StringUtils.isBlank(path)) {
+ sbUrl.append(path);
+ }
+ if (null != querys) {
+ StringBuilder sbQuery = new StringBuilder();
+ for (Map.Entry query : querys.entrySet()) {
+ if (!sbQuery.isEmpty()) {
+ sbQuery.append("&");
+ }
+ if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
+ sbQuery.append(query.getValue());
+ }
+ if (!StringUtils.isBlank(query.getKey())) {
+ sbQuery.append(query.getKey());
+ if (!StringUtils.isBlank(query.getValue())) {
+ sbQuery.append("=");
+ sbQuery.append(URLEncoder.encode(query.getValue(), StandardCharsets.UTF_8));
+ }
+ }
+ }
+ if (!sbQuery.isEmpty()) {
+ sbUrl.append("?").append(sbQuery);
+ }
+ }
+
+ return sbUrl.toString();
+ }
+
+ private static HttpClient wrapClient(String host) {
+ HttpClient httpClient = new DefaultHttpClient();
+ if (host.startsWith("https://")) {
+ sslClient(httpClient);
+ }
+
+ return httpClient;
+ }
+
+ private static void sslClient(HttpClient httpClient) {
+ try {
+ SSLContext ctx = SSLContext.getInstance("TLS");
+ X509TrustManager tm = new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(X509Certificate[] xcs, String str) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] xcs, String str) {
+ }
+ };
+ ctx.init(null, new TrustManager[]{tm}, null);
+ SSLSocketFactory ssf = new SSLSocketFactory(ctx);
+ ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ ClientConnectionManager ccm = httpClient.getConnectionManager();
+ SchemeRegistry registry = ccm.getSchemeRegistry();
+ registry.register(new Scheme("https", 443, ssf));
+ } catch (Exception ex) {
+ throw new RuntimeException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/common/pom.xml b/common/pom.xml
index 50dc225..b51cdb2 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -18,10 +18,10 @@
-
- io.minio
- minio
+ cn.bunny
+ model
+ 0.0.1-SNAPSHOT
diff --git a/common/service-utils/pom.xml b/common/service-utils/pom.xml
index e0f29c5..75261f2 100644
--- a/common/service-utils/pom.xml
+++ b/common/service-utils/pom.xml
@@ -19,9 +19,14 @@
cn.bunny
- model
+ common-utils
0.0.1-SNAPSHOT
+
+
+ io.minio
+ minio
+
org.springframework.boot
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java b/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
index 1a7ea08..44f8128 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
@@ -1,6 +1,6 @@
package cn.bunny.common.service.exception;
-import cn.bunny.common.service.constant.MessageConstant;
+import cn.bunny.common.constant.MessageConstant;
import cn.bunny.common.service.result.Result;
import cn.bunny.enums.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
diff --git a/service/src/main/java/cn/bunny/service/service/impl/SysUserServiceImpl.java b/service/src/main/java/cn/bunny/service/service/impl/SysUserServiceImpl.java
index e00c156..87be3a6 100644
--- a/service/src/main/java/cn/bunny/service/service/impl/SysUserServiceImpl.java
+++ b/service/src/main/java/cn/bunny/service/service/impl/SysUserServiceImpl.java
@@ -1,7 +1,7 @@
package cn.bunny.service.service.impl;
-import cn.bunny.common.service.constant.MessageConstant;
+import cn.bunny.common.constant.MessageConstant;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.entity.system.Login;
import cn.bunny.entity.system.SysUser;