Browse Source

正圆接口已对接完成

wuweihao 3 years ago
parent
commit
63149a6e2e

+ 2 - 0
gis_admin/src/main/java/com/gis/admin/service/SysUserService.java

@@ -37,4 +37,6 @@ public interface SysUserService extends IService<SysUserEntity> {
 
     SysUserEntity mpFindById(Long id);
 
+    SysUserEntity cacheById(Long userId);
+
 }

+ 19 - 0
gis_admin/src/main/java/com/gis/admin/service/impl/SysUserServiceImpl.java

@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
 import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 
 /**
@@ -40,6 +41,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity
     @Autowired
     SysRoleService roleService;
 
+    @Autowired
+    RedisUtil redisUtil;
+
+    /**redis 用户名*/
+    final static String USER_KEY = "user:";
 
 
     @Override
@@ -48,6 +54,19 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity
     }
 
     @Override
+    public SysUserEntity cacheById(Long userId) {
+        SysUserEntity entity;
+        String userKey = USER_KEY + userId;
+        if (redisUtil.hasKey(userKey)){
+            entity =  redisUtil.getCacheObject(userKey);
+        } else {
+            entity = this.getById(userId);
+            redisUtil.setCacheObject(userKey, entity, 5, TimeUnit.MINUTES);
+        }
+        return entity;
+    }
+
+    @Override
     public Result saveEntity(UserDto param) {
         SysUserEntity entity ;
         Long id = param.getId();

+ 3 - 2
gis_admin/src/main/java/com/gis/admin/shiro/ShiroRealm.java

@@ -27,7 +27,7 @@ import java.util.List;
 /**
  * @Description: 用户登录鉴权和获取用户授权
  * @Author: owen
- * @Date: 2021-07-07
+ * @Date: 2022-05-17
  * @Version: 1.1
  */
 @Component
@@ -142,7 +142,8 @@ public class ShiroRealm extends AuthorizingRealm {
             throw new JwtAuthenticationException(5001, "token invalid");
         }
 
-        SysUserEntity userEntity = sysUserService.findByUserName(username);
+//        SysUserEntity userEntity = sysUserService.findByUserName(username);
+        SysUserEntity userEntity = sysUserService.cacheById(JwtUtil.getUserId(token));
         if (userEntity == null) {
             log.error("error token userEntity");
             throw new JwtAuthenticationException(5001, "User didn't existed!");

+ 21 - 1
gis_cms/src/main/java/com/gis/cms/controller/ApiController.java

@@ -1,10 +1,14 @@
 package com.gis.cms.controller;
 
+import cn.hutool.crypto.SecureUtil;
+import cn.hutool.crypto.digest.MD5;
 import com.gis.cms.entity.vo.HotelVo;
 import com.gis.cms.service.HotelService;
 import com.gis.common.util.Result;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
+import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -25,9 +29,25 @@ public class ApiController {
     @Autowired
     HotelService hotelService;
 
-    @ApiOperation(value = "列表")
+
+    @ApiOperation(value = "酒店列表", notes = "请求头需要携带appId")
     @PostMapping("/list")
     public Result<List<HotelVo>> apiList() {
         return hotelService.apiList();
     }
+
+
+    @Test
+    public void test1(){
+        long time = System.currentTimeMillis();
+        String clientId = "868fb7e85eee499db3941195e350fccc";
+
+        String secureKey = "34ea4d6697c84154a9df15749a229444";
+        String sign = clientId+secureKey+time;
+        String md5 = SecureUtil.md5(sign);
+        System.out.println("X-Client-Id : " + clientId);
+        System.out.println("X-Sign :" + md5);
+        System.out.println("X-TimeStamp :" + time);
+
+    }
 }

+ 5 - 0
gis_cms/src/main/java/com/gis/cms/service/impl/HotelServiceImpl.java

@@ -14,6 +14,7 @@ import com.gis.cms.entity.po.HotelEntity;
 import com.gis.cms.entity.vo.HotelVo;
 import com.gis.cms.mapper.HotelMapper;
 import com.gis.cms.service.HotelService;
+import com.gis.cms.zhengyuan.ZhengYuanService;
 import com.gis.common.base.exception.BaseRuntimeException;
 import com.gis.common.base.service.impl.IBaseService;
 import com.gis.common.constant.ErrorEnum;
@@ -42,6 +43,9 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
     @Autowired
     SysRoleService roleService;
 
+    @Autowired
+    ZhengYuanService zhengYuanService;
+
 
 
     @Override
@@ -145,6 +149,7 @@ public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> impl
         BeanUtils.copyProperties(param, entity);
         this.updateById(entity);
         // todo 2022-5-16 主动更新合作商数据
+        zhengYuanService.updateHotel(entity);
         return Result.success();
     }
 

+ 24 - 0
gis_cms/src/main/java/com/gis/cms/zhengyuan/ResData.java

@@ -0,0 +1,24 @@
+package com.gis.cms.zhengyuan;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Created by owen on 2022/5/16 0016 17:53
+ */
+@Data
+public class ResData {
+
+    @ApiModelProperty(value = "处理状态:0: 成功, -1: 失败", name = "code")
+    private int code;
+    /**
+     * 消息
+     */
+    @ApiModelProperty(value = "消息", name = "msg")
+    private String message;
+    /**
+     * 返回数据
+     */
+    @ApiModelProperty(value = "返回数据", name = "data")
+    private String data;
+}

+ 71 - 0
gis_cms/src/main/java/com/gis/cms/zhengyuan/ZhengYuanHotelDto.java

@@ -0,0 +1,71 @@
+package com.gis.cms.zhengyuan;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 酒店-正圆科技
+ */
+@Data
+public class ZhengYuanHotelDto implements Serializable {
+
+
+    private static final long serialVersionUID = -5861435331195594708L;
+    @ApiModelProperty(value = "酒店ID")
+    private String thirdId;
+
+    @ApiModelProperty(value = "酒店名称")
+    private String hotelName;
+
+    @ApiModelProperty(value = "酒店地址")
+    private String hotelAddress;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "房间总数(房间数量)")
+    private Integer roomNumber;
+
+    @ApiModelProperty(value = "房间已使用")
+    private Integer useNumber;
+
+    @ApiModelProperty(value = "房间可用(空闲房数)")
+    private Integer freeNumber;
+
+    @ApiModelProperty(value = "预定房数")
+    private Integer reserveNumber;
+
+    @ApiModelProperty(value = "隔离房间数")
+    private Integer roomIsolation;
+
+    @ApiModelProperty(value = "密接人数")
+    private Integer closeContactNumber;
+
+    @ApiModelProperty(value = "次密接人数")
+    private Integer secondaryCloseContactNumber;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 50 - 0
gis_cms/src/main/java/com/gis/cms/zhengyuan/ZhengYuanService.java

@@ -0,0 +1,50 @@
+package com.gis.cms.zhengyuan;
+
+import com.alibaba.fastjson.JSONObject;
+import com.gis.cms.entity.po.HotelEntity;
+import com.gis.common.base.entity.dto.PageDto;
+import com.gis.common.util.RedisUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by owen on 2022/5/16 0016 18:07
+ */
+@Slf4j
+@Service
+public class ZhengYuanService {
+
+    static final String tokenKey = "zhengYuanToken";
+
+    @Autowired
+    RedisUtil redisUtil;
+
+    private String getToken(){
+        if (redisUtil.hasKey(tokenKey)){
+            return redisUtil.getCacheObject(tokenKey);
+        }
+
+        JSONObject res = ZhengYuanUtil.getCertification();
+        String accessToken = res.getString("accessToken");
+        Integer availableTime = res.getInteger("tokenAvailableTime");
+
+        redisUtil.setEx(tokenKey, accessToken, availableTime-300, TimeUnit.SECONDS);
+        return accessToken;
+
+    }
+
+
+    public void updateHotel(HotelEntity param){
+        ZhengYuanUtil.saveHotel(getToken(), param);
+        log.info("正圆酒店信息更新完成");
+//        PageDto dto = new PageDto();
+//        dto.setPageNum(1);
+//        dto.setPageSize(10);
+//        ZhengYuanUtil.listHotel(getToken(), dto);
+
+    }
+}

+ 123 - 0
gis_cms/src/main/java/com/gis/cms/zhengyuan/ZhengYuanUtil.java

@@ -0,0 +1,123 @@
+package com.gis.cms.zhengyuan;
+
+import cn.hutool.crypto.SecureUtil;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.gis.cms.entity.dto.HotelDto;
+import com.gis.cms.entity.po.HotelEntity;
+import com.gis.common.base.entity.dto.PageDto;
+import com.gis.common.base.exception.BaseRuntimeException;
+import com.gis.common.util.HttpUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
+import org.apache.shiro.crypto.hash.Hash;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+/**
+ * Created by owen on 2022/5/16 0016 17:13
+ * 正圆相关接口
+ * API文档:
+ * https://www.showdoc.com.cn/1946640511630445/8848832361067591
+ * 密码:password123123
+ */
+public class ZhengYuanUtil {
+
+    static final String clientId = "868fb7e85eee499db3941195e350fccc";
+
+    static final String secureKey = "34ea4d6697c84154a9df15749a229444";
+
+
+    /**域名*/
+    static final String api_domain = "https://zyhw.zh-zhengyuan.cn";
+
+    /**获取授权*/
+    static final String api_getCertification = "/api/getCertification";
+
+    /**新增/修改酒店信息*/
+    static final String api_saveHotel = "/api/sanitationEpidemicHotel/third/saveHotel";
+
+    /**酒店列表*/
+    static final String api_listHotel = "/api/sanitationEpidemicHotel/third/listHotel";
+
+
+    /**
+     * 获取授权 token
+     * @return
+     */
+    public static JSONObject getCertification(){
+        String api = api_domain + api_getCertification;
+        long time = System.currentTimeMillis();
+        String sign = clientId+secureKey+time;
+        String md5 = SecureUtil.md5(sign);
+
+        HashMap<String, String> header = new HashMap<>();
+        header.put("X-Client-Id", clientId);
+        header.put("X-Sign", md5);
+        header.put("X-TimeStamp", time+"");
+
+        String s = HttpUtils.doPost(api, header, null);
+        return  parseResData(s);
+
+    }
+
+    /**
+     * 新增/修改酒店信息
+     * @return
+     */
+    public static JSONObject saveHotel(String token, HotelEntity param){
+        String api = api_domain + api_saveHotel;
+
+        HashMap<String, String> header = new HashMap<>();
+        header.put("Authorization", "Bearer " + token);
+
+        ZhengYuanHotelDto req = new ZhengYuanHotelDto();
+        req.setThirdId(param.getId().toString());
+        req.setHotelName(param.getName());
+        req.setHotelAddress(param.getAddress());
+        req.setRemark(param.getRemark());
+        req.setRoomNumber(param.getTotal());
+        req.setUseNumber(param.getUsed());
+        req.setFreeNumber(param.getUsable());
+        req.setReserveNumber(param.getBook());
+
+        JSONObject reqBody = (JSONObject)JSON.toJSON(req);
+        String res = HttpUtils.doPost(api, header, reqBody);
+        return  parseResData(res);
+
+    }
+
+    public static JSONObject listHotel(String token, PageDto param){
+        HashMap<String, String> header = new HashMap<>();
+        header.put("Authorization", "Bearer " + token);
+
+        HashMap<String, String> querys = new HashMap<>();
+        querys.put("page", param.getPageNum().toString());
+        querys.put("size", param.getPageSize().toString());
+        String res = HttpUtils.doGet(api_domain, api_listHotel, header, querys);
+        return  parseResData(res);
+    }
+
+
+
+    /**
+     * 解析返回值
+     * @param str
+     * @return
+     */
+    private static JSONObject parseResData(String str){
+        ResData resData = JSONObject.parseObject(str, ResData.class);
+        BaseRuntimeException.isTrue(resData.getCode()!=200, null, "正圆接口响应失败");
+        JSONObject parse = JSON.parseObject(resData.getData());
+        return parse;
+    }
+
+    @Test
+    public void test1(){
+        getCertification();
+    }
+
+}

+ 9 - 3
gis_common/pom.xml

@@ -90,10 +90,16 @@
             <artifactId>pinyin4j</artifactId>
         </dependency>
 
-        <!-- 二维码 -->
+        <!--&lt;!&ndash; 二维码 &ndash;&gt;-->
+        <!--<dependency>-->
+            <!--<groupId>com.google.zxing</groupId>-->
+            <!--<artifactId>core</artifactId>-->
+        <!--</dependency>-->
+
+        <!--httpclient-->
         <dependency>
-            <groupId>com.google.zxing</groupId>
-            <artifactId>core</artifactId>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
         </dependency>
 
         <dependency>

+ 419 - 0
gis_common/src/main/java/com/gis/common/util/HttpUtils.java

@@ -0,0 +1,419 @@
+package com.gis.common.util;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+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 org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+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;
+
+@Slf4j
+public class HttpUtils {
+
+    protected static final Logger LOGGER = LoggerFactory.getLogger(HttpUtils.class);
+
+    /**
+     * get
+     *
+     * @param host
+     * @param path
+     * @param headers
+     * @param querys
+     * @return
+     * @throws Exception
+     */
+    public static String doGet(String host, String path,
+                                     Map<String, String> headers,
+                                     Map<String, String> querys) {
+        HttpClient httpClient = wrapClient(host);
+        log.info("url : " + host + path);
+        try {
+            HttpGet request = new HttpGet(buildUrl(host, path, querys));
+            for (Map.Entry<String, String> e : headers.entrySet()) {
+                request.addHeader(e.getKey(), e.getValue());
+            }
+            HttpResponse execute = httpClient.execute(request);
+            String str = EntityUtils.toString(execute.getEntity(), "UTF-8");
+            log.info("返回值:{}", str);
+            return str;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+
+    }
+
+    /**
+     * post form
+     *
+     * @param host
+     * @param path
+     * @param headers
+     * @param querys
+     * @param bodys
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path, 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);
+    }
+
+    /**
+     * 2021-02-23
+     * post 有请求头,有headers
+     *
+     * @param host
+     * @param path
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path, Map<String, String> headers, Map<String, String> querys, JSONObject 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) {
+            StringEntity stringEntity = new StringEntity(body.toJSONString(), "utf-8");
+            stringEntity.setContentType("application/json;charset=UTF-8");
+            request.setEntity(stringEntity);
+        }
+        return httpClient.execute(request);
+    }
+
+
+    /**
+     * 2022-05-16
+     * post 有请求头,有headers
+     *
+     * @param headers
+     * @param body
+     * @param api
+     * @return
+     * @throws Exception
+     */
+    public static String doPost(String api, Map<String, String> headers, JSONObject body) {
+        HttpClient httpClient = new DefaultHttpClient();
+        LOGGER.info("url : " + api);
+        HttpPost request = new HttpPost(api);
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        // 请求体
+        if (body != null) {
+            log.info("请求参数:{}", body);
+            StringEntity stringEntity = new StringEntity(body.toJSONString(), "utf-8");
+            stringEntity.setContentType("application/json;charset=UTF-8");
+            request.setEntity(stringEntity);
+        }
+
+        HttpResponse execute = null;
+        try {
+            execute = httpClient.execute(request);
+            String str = EntityUtils.toString(execute.getEntity(), "UTF-8");
+            log.info("返回值:{}", str);
+            return str;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+//    /**
+//     * 2022-05-17
+//     * post 有请求头,有headers
+//     *
+//     * @param headers
+//     * @param bodyJsonStr jsonString
+//     * @param api
+//     * @return
+//     * @throws Exception
+//     */
+//    public static String doPost(String api, Map<String, String> headers, String bodyJsonStr) {
+//        HttpClient httpClient = new DefaultHttpClient();
+//        LOGGER.info("url : " + api);
+//        HttpPost request = new HttpPost(api);
+//        for (Map.Entry<String, String> e : headers.entrySet()) {
+//            request.addHeader(e.getKey(), e.getValue());
+//        }
+//
+//        // 请求体
+//        if (bodyJsonStr != null) {
+//            log.info("请求参数:{}", bodyJsonStr);
+//            StringEntity stringEntity = new StringEntity(bodyJsonStr, "utf-8");
+//            stringEntity.setContentType("application/json;charset=UTF-8");
+//            request.setEntity(stringEntity);
+//        }
+//
+//        HttpResponse execute = null;
+//        try {
+//            execute = httpClient.execute(request);
+//            String str = EntityUtils.toString(execute.getEntity(), "UTF-8");
+//            log.info("返回值:{}", str);
+//            return str;
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//        return null;
+//    }
+
+
+    public static HttpResponse doPost(String host, String path, Map<String, String> headers, Map<String, String> querys)
+            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());
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Post stream
+     *
+     * @param host
+     * @param path
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path,
+                                      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);
+    }
+
+    public 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);
+        }
+        LOGGER.info("request api: " + sbUrl.toString());
+        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() {
+                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 (KeyManagementException ex) {
+            throw new RuntimeException(ex);
+        } catch (NoSuchAlgorithmException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+
+
+}