zhangyuewww il y a 2 ans
Parent
commit
edcc690f1e

+ 8 - 1
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/card/ICertificateManagementInfoService.java

@@ -8,6 +8,7 @@ import com.iotechn.unimall.core.annotation.HttpParam;
 import com.iotechn.unimall.core.annotation.HttpParamType;
 import com.iotechn.unimall.core.annotation.param.NotNull;
 import com.iotechn.unimall.core.exception.ServiceException;
+import com.iotechn.unimall.data.dto.DistinguishView;
 import com.iotechn.unimall.data.model.Page;
 import java.util.Date;
 
@@ -42,7 +43,13 @@ public interface ICertificateManagementInfoService{
 
 	@HttpMethod(description = "查询",  permissionName = "证件管理管理")
 	public CertificateManagementInfo get(@NotNull @HttpParam(name = "id", type = HttpParamType.COMMON, description = "")Long id)throws ServiceException;
-	
+
+	@HttpMethod(description = "识别身份证",  permissionName = "证件管理管理")
+	public DistinguishView personShibie(@HttpParam(name = "certificateImage", type = HttpParamType.COMMON, description = "证件图") String certificateImage)throws ServiceException;
+
+	@HttpMethod(description = "识别银行卡",  permissionName = "证件管理管理")
+	public DistinguishView bankShibie(@HttpParam(name = "certificateImage", type = HttpParamType.COMMON, description = "证件图") String certificateImage)throws ServiceException;
+
 	@HttpMethod(description = "导出excl表", permissionName = "证件管理管理")
 	public String export(
 								@HttpParam(name = "commonId", type = HttpParamType.COMMON, description = "个人id") Long commonId,

+ 239 - 93
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/card/impl/CertificateManagementInfoServiceImpl.java

@@ -1,7 +1,20 @@
 package com.iotechn.unimall.admin.api.card.impl;
 
-import java.util.List;
+import java.util.*;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.iotechn.unimall.data.dto.DistinguishView;
+import com.iotechn.unimall.data.util.HttpUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
 import org.apache.ibatis.session.RowBounds;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -15,9 +28,7 @@ import com.iotechn.unimall.data.mapper.CertificateManagementInfoMapper;
 import com.iotechn.unimall.data.domain.CertificateManagementInfo;
 import com.iotechn.unimall.admin.api.card.ICertificateManagementInfoService;
 import com.iotechn.unimall.data.model.Page;
-
 import java.util.Date;
-
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -28,94 +39,229 @@ import org.springframework.transaction.annotation.Transactional;
  */
 @Service
 public class CertificateManagementInfoServiceImpl implements ICertificateManagementInfoService {
-    @Autowired
-    private CertificateManagementInfoMapper certificateManagementInfoMapper;
-
-    @Override
-    public Boolean add(CertificateManagementInfo certificateManagementInfo) throws ServiceException {
-        Date now = new Date();
-        certificateManagementInfo.setGmtCreate(now);
-        certificateManagementInfo.setGmtUpdate(now);
-        return certificateManagementInfoMapper.insert(certificateManagementInfo) > 0;
-    }
-
-    @Override
-    public Page<CertificateManagementInfo> list(Long commonId, String certificateName, String certificateImage, Date gmtCreate, Date gmtUpdate, Long deleteFlag, Integer page, Integer limit) throws ServiceException {
-        Wrapper<CertificateManagementInfo> wrapper = new EntityWrapper<CertificateManagementInfo>();
-        if (!StringUtils.isEmpty(commonId)) {
-            wrapper.eq("common_id", commonId);
-        }
-        if (!StringUtils.isEmpty(certificateName)) {
-            wrapper.eq("certificate_name", certificateName);
-        }
-        if (!StringUtils.isEmpty(certificateImage)) {
-            wrapper.eq("certificate_image", certificateImage);
-        }
-        if (!StringUtils.isEmpty(gmtCreate)) {
-            wrapper.eq("gmt_create", gmtCreate);
-        }
-        if (!StringUtils.isEmpty(gmtUpdate)) {
-            wrapper.eq("gmt_update", gmtUpdate);
-        }
-        if (!StringUtils.isEmpty(deleteFlag)) {
-            wrapper.eq("delete_flag", deleteFlag);
-        }
-        wrapper.eq("delete_flag", 0);
-        List<CertificateManagementInfo> list = certificateManagementInfoMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
-        Integer count = certificateManagementInfoMapper.selectCount(wrapper);
-        return new Page<CertificateManagementInfo>(list, page, limit, count);
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Boolean delete(String id) {
-        String[] ids = String.valueOf(id).split(",");
-        for (String tt : ids) {
-            CertificateManagementInfo tmp = certificateManagementInfoMapper.selectById(Long.parseLong(tt));
-            if (tmp != null) {
-                tmp.setDeleteFlag(1l);
-                tmp.setGmtUpdate(new Date());
-                certificateManagementInfoMapper.updateById(tmp);
-            }
-        }
-        return true;
-    }
-
-    @Override
-    public Boolean update(CertificateManagementInfo certificateManagementInfo) throws ServiceException {
-        Date now = new Date();
-        certificateManagementInfo.setGmtUpdate(now);
-        return certificateManagementInfoMapper.updateById(certificateManagementInfo) > 0;
-    }
-
-    @Override
-    public CertificateManagementInfo get(Long id) throws ServiceException {
-        return certificateManagementInfoMapper.selectById(id);
-    }
-
-    @Override
-    public String export(Long commonId, String certificateName, String certificateImage, Date gmtCreate, Date gmtUpdate, Long deleteFlag, Integer page, Integer limit) throws ServiceException {
-        Wrapper<CertificateManagementInfo> wrapper = new EntityWrapper<CertificateManagementInfo>();
-        if (!StringUtils.isEmpty(commonId)) {
-            wrapper.eq("common_id", commonId);
-        }
-        if (!StringUtils.isEmpty(certificateName)) {
-            wrapper.eq("certificate_name", certificateName);
-        }
-        if (!StringUtils.isEmpty(certificateImage)) {
-            wrapper.eq("certificate_image", certificateImage);
-        }
-        if (!StringUtils.isEmpty(gmtCreate)) {
-            wrapper.eq("gmt_create", gmtCreate);
-        }
-        if (!StringUtils.isEmpty(gmtUpdate)) {
-            wrapper.eq("gmt_update", gmtUpdate);
-        }
-        if (!StringUtils.isEmpty(deleteFlag)) {
-            wrapper.eq("delete_flag", deleteFlag);
-        }
-        List<CertificateManagementInfo> list = certificateManagementInfoMapper.selectList(wrapper);
-        ExcelUtil<CertificateManagementInfo> util = new ExcelUtil<CertificateManagementInfo>(CertificateManagementInfo.class);
-        return util.exportExcel(list, "操作日志");
-    }
+	@Autowired
+	private CertificateManagementInfoMapper certificateManagementInfoMapper;
+
+	@Override
+	public Boolean add(CertificateManagementInfo certificateManagementInfo) throws ServiceException {
+		Date now = new Date();
+		certificateManagementInfo.setGmtCreate(now);
+		certificateManagementInfo.setGmtUpdate(now);
+		return certificateManagementInfoMapper.insert(certificateManagementInfo) > 0;
+	}
+
+	@Override
+	public Page<CertificateManagementInfo> list(Long commonId, String certificateName, String certificateImage, Date gmtCreate, Date gmtUpdate, Long deleteFlag, Integer page, Integer limit) throws ServiceException {
+		Wrapper<CertificateManagementInfo> wrapper = new EntityWrapper<CertificateManagementInfo>();
+		if (!StringUtils.isEmpty(commonId)) {
+			wrapper.eq("common_id", commonId);
+		}
+		if (!StringUtils.isEmpty(certificateName)) {
+			wrapper.eq("certificate_name", certificateName);
+		}
+		if (!StringUtils.isEmpty(certificateImage)) {
+			wrapper.eq("certificate_image", certificateImage);
+		}
+		if (!StringUtils.isEmpty(gmtCreate)) {
+			wrapper.eq("gmt_create", gmtCreate);
+		}
+		if (!StringUtils.isEmpty(gmtUpdate)) {
+			wrapper.eq("gmt_update", gmtUpdate);
+		}
+		if (!StringUtils.isEmpty(deleteFlag)) {
+			wrapper.eq("delete_flag", deleteFlag);
+		}
+		wrapper.eq("delete_flag", 0);
+		List<CertificateManagementInfo> list = certificateManagementInfoMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
+		Integer count = certificateManagementInfoMapper.selectCount(wrapper);
+		return new Page<CertificateManagementInfo>(list, page, limit, count);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public Boolean delete(String id) {
+		String[] ids = String.valueOf(id).split(",");
+		for (String tt : ids) {
+			CertificateManagementInfo tmp = certificateManagementInfoMapper.selectById(Long.parseLong(tt));
+			if (tmp != null) {
+				tmp.setDeleteFlag(1l);
+				tmp.setGmtUpdate(new Date());
+				certificateManagementInfoMapper.updateById(tmp);
+			}
+		}
+		return true;
+	}
+
+	@Override
+	public Boolean update(CertificateManagementInfo certificateManagementInfo) throws ServiceException {
+		Date now = new Date();
+		certificateManagementInfo.setGmtUpdate(now);
+		return certificateManagementInfoMapper.updateById(certificateManagementInfo) > 0;
+	}
+
+	@Override
+	public CertificateManagementInfo get(Long id) throws ServiceException {
+		return certificateManagementInfoMapper.selectById(id);
+	}
+
+	@Override
+	public String export(Long commonId, String certificateName, String certificateImage, Date gmtCreate, Date gmtUpdate, Long deleteFlag, Integer page, Integer limit) throws ServiceException {
+		Wrapper<CertificateManagementInfo> wrapper = new EntityWrapper<CertificateManagementInfo>();
+		if (!StringUtils.isEmpty(commonId)) {
+			wrapper.eq("common_id", commonId);
+		}
+		if (!StringUtils.isEmpty(certificateName)) {
+			wrapper.eq("certificate_name", certificateName);
+		}
+		if (!StringUtils.isEmpty(certificateImage)) {
+			wrapper.eq("certificate_image", certificateImage);
+		}
+		if (!StringUtils.isEmpty(gmtCreate)) {
+			wrapper.eq("gmt_create", gmtCreate);
+		}
+		if (!StringUtils.isEmpty(gmtUpdate)) {
+			wrapper.eq("gmt_update", gmtUpdate);
+		}
+		if (!StringUtils.isEmpty(deleteFlag)) {
+			wrapper.eq("delete_flag", deleteFlag);
+		}
+		List<CertificateManagementInfo> list = certificateManagementInfoMapper.selectList(wrapper);
+		ExcelUtil<CertificateManagementInfo> util = new ExcelUtil<CertificateManagementInfo>(CertificateManagementInfo.class);
+		return util.exportExcel(list, "操作日志");
+	}
+
+	@Override
+	public DistinguishView personShibie(String certificateImage) throws ServiceException {
+		String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
+		//API产品路径
+		String requestUrl = "https://personcard.market.alicloudapi.com/ai_market/ai_ocr_universal/shen_fen_zheng/ch/v1";
+		//阿里云APPCODE
+		DistinguishView distinguishView = new DistinguishView();
+		CloseableHttpClient httpClient = null;
+		try {
+			httpClient = HttpClients.createDefault();
+			List<NameValuePair> params = new ArrayList<NameValuePair>();
+			//启用URL方式进行识别
+			//内容数据类型是图像文件URL链接
+			params.add(new BasicNameValuePair("IMAGE", certificateImage));
+			params.add(new BasicNameValuePair("IMAGE_TYPE", "1"));
+
+			// 创建一个HttpPost实例
+			HttpPost httpPost = new HttpPost(requestUrl);
+			httpPost.addHeader("Authorization", "APPCODE " + appcode);
+			httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+
+			// 设置请求参数
+			httpPost.setEntity(new UrlEncodedFormEntity(params, "utf-8"));
+
+			// 发送POST请求
+			HttpResponse execute = httpClient.execute(httpPost);
+
+			// 获取状态码
+			int statusCode = execute.getStatusLine().getStatusCode();
+			System.out.println(statusCode);
+
+			// 获取结果
+			HttpEntity entity = execute.getEntity();
+			String body = EntityUtils.toString(entity);
+			System.out.println(body);
+			JSONObject jsonObject = JSONObject.parseObject(body);
+			distinguishView.setRecPersonNo(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("身份证号"));
+			return distinguishView;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	@Override
+	public DistinguishView bankShibie(String certificateImage) throws ServiceException {
+		String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
+		String host = "https://api06.aliyun.venuscn.com";
+		String path = "/ocr/bank-card";
+		String method = "POST";
+		Map<String, String> headers = new HashMap<String, String>();
+		//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
+		headers.put("Authorization", "APPCODE " + appcode);
+		//根据API的要求,定义相对应的Content-Type
+		headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+		Map<String, String> querys = new HashMap<String, String>();
+		Map<String, String> bodys = new HashMap<String, String>();
+		bodys.put("pic", certificateImage);
+		try {
+			HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
+			String body = EntityUtils.toString(response.getEntity());
+			System.out.println(body);
+			JSONObject jsonObject = JSONObject.parseObject(body);
+			if ("200".equals(jsonObject.getString("ret"))) {
+				JSONObject data = JSONObject.parseObject(jsonObject.getString("data"));
+				DistinguishView distinguishView = new DistinguishView();
+				distinguishView.setBankNo(data.getString("number"));
+
+				host = "https://yhkgsd.market.alicloudapi.com";
+				path = "/bankcard/region";
+				method = "GET";
+				headers = new HashMap<String, String>();
+				//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
+				headers.put("Authorization", "APPCODE " + appcode);
+				querys = new HashMap<String, String>();
+				querys.put("bankcard", distinguishView.getBankNo());
+				try {
+					response = HttpUtils.doGet(host, path, method, headers, querys);
+					body = EntityUtils.toString(response.getEntity());
+					System.out.println(body);
+					jsonObject = JSONObject.parseObject(body);
+					if ("0".equals(jsonObject.getString("code"))) {
+						data = JSONObject.parseObject(jsonObject.getString("data"));
+						JSONObject detail = JSONObject.parseObject(data.getString("detail"));
+						String[] area = detail.getString("area").split(" - ");
+						String province = "";
+						String city = "";
+						if (area.length > 1) {
+							province = area[0];
+							city = area[1];
+						}
+
+						host = "https://cnaps.market.alicloudapi.com";
+						path = "/lianzhuo/querybankaps";
+						method = "GET";
+						headers = new HashMap<String, String>();
+						//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
+						headers.put("Authorization", "APPCODE " + appcode);
+						querys = new HashMap<String, String>();
+						querys.put("card", distinguishView.getBankNo());
+						querys.put("province", province);
+						querys.put("city", city);
+						try {
+							response = HttpUtils.doGet(host, path, method, headers, querys);
+							System.out.println(response.toString());
+							body = EntityUtils.toString(response.getEntity());
+							System.out.println(body);
+							jsonObject = JSONObject.parseObject(body);
+							JSONObject jsonData = jsonObject.getJSONObject("data");
+							JSONObject res = jsonObject.getJSONObject("resp");
+							if ("200".equals(res.get("RespCode"))) {
+								JSONArray jsonArray = jsonData.getJSONArray("record");
+								List<String> bankList = new ArrayList<>();
+								for (int i = 0; i < jsonArray.size(); i++) {
+									bankList.add(jsonArray.getJSONObject(i).get("lName").toString());
+								}
+							}
+						} catch (Exception e) {
+							e.printStackTrace();
+						}
+					}
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+				return distinguishView;
+			} else {
+				System.out.println(jsonObject.getString("msg"));
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
 }
+

+ 12 - 0
unimall-data/src/main/java/com/iotechn/unimall/data/dto/DistinguishView.java

@@ -0,0 +1,12 @@
+package com.iotechn.unimall.data.dto;
+
+import com.baomidou.mybatisplus.annotations.TableField;
+import lombok.Data;
+
+@Data
+public class DistinguishView extends SuperDTO{
+
+    private String recPersonNo;
+
+    private String bankNo;
+}

+ 314 - 0
unimall-data/src/main/java/com/iotechn/unimall/data/util/HttpUtils.java

@@ -0,0 +1,314 @@
+package com.iotechn.unimall.data.util;
+
+import com.iotechn.unimall.core.util.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.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpUtils {
+
+    /**
+     * get
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doGet(String host, String path, String method,
+                                     Map<String, String> headers,
+                                     Map<String, String> querys)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpGet request = new HttpGet(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * post form
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param bodys
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path, String method,
+                                      Map<String, String> headers,
+                                      Map<String, String> querys,
+                                      Map<String, String> bodys)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (bodys != null) {
+            List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
+
+            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);
+    }
+
+    /**
+     * Post String
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path, String method,
+                                      Map<String, String> headers,
+                                      Map<String, String> querys,
+                                      String body)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (StringUtils.isNotBlank(body)) {
+            request.setEntity(new StringEntity(body, "utf-8"));
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Post stream
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path, String method,
+                                      Map<String, String> headers,
+                                      Map<String, String> querys,
+                                      byte[] body)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (body != null) {
+            request.setEntity(new ByteArrayEntity(body));
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Put String
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPut(String host, String path, String method,
+                                     Map<String, String> headers,
+                                     Map<String, String> querys,
+                                     String body)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPut request = new HttpPut(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (StringUtils.isNotBlank(body)) {
+            request.setEntity(new StringEntity(body, "utf-8"));
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Put stream
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPut(String host, String path, String method,
+                                     Map<String, String> headers,
+                                     Map<String, String> querys,
+                                     byte[] body)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPut request = new HttpPut(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (body != null) {
+            request.setEntity(new ByteArrayEntity(body));
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Delete
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doDelete(String host, String path, String method,
+                                        Map<String, String> headers,
+                                        Map<String, String> querys)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        return httpClient.execute(request);
+    }
+
+    private static String buildUrl(String host, String path, Map<String, String> 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<String, String> query : querys.entrySet()) {
+                if (0 < sbQuery.length()) {
+                    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(), "utf-8"));
+                    }
+                }
+            }
+            if (0 < sbQuery.length()) {
+                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() {
+                @Override
+                public X509Certificate[] getAcceptedIssuers() {
+                    return null;
+                }
+                @Override
+                public void checkClientTrusted(X509Certificate[] xcs, String str) {
+
+                }
+                @Override
+                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 (KeyManagementException ex) {
+            throw new RuntimeException(ex);
+        } catch (NoSuchAlgorithmException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+}