|
@@ -7,16 +7,18 @@ 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.entity.po.LogEntity;
|
|
|
import com.gis.common.base.exception.BaseRuntimeException;
|
|
|
+import com.gis.common.base.service.LogService;
|
|
|
+import com.gis.common.base.service.impl.IBaseService;
|
|
|
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 lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.Test;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Created by owen on 2022/5/16 0016 17:13
|
|
|
* 正圆相关接口
|
|
@@ -24,6 +26,7 @@ import java.util.HashMap;
|
|
|
* https://www.showdoc.com.cn/1946640511630445/8848832361067591
|
|
|
* 密码:password123123
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
public class ZhengYuanUtil {
|
|
|
|
|
|
static final String clientId = "868fb7e85eee499db3941195e350fccc";
|
|
@@ -44,11 +47,17 @@ public class ZhengYuanUtil {
|
|
|
static final String api_listHotel = "/api/sanitationEpidemicHotel/third/listHotel";
|
|
|
|
|
|
|
|
|
+// @Autowired
|
|
|
+// LogService logService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// IBaseService baseService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取授权 token
|
|
|
* @return
|
|
|
*/
|
|
|
- public static JSONObject getCertification(){
|
|
|
+ public static JSONObject getCertification() throws Exception {
|
|
|
String api = api_domain + api_getCertification;
|
|
|
long time = System.currentTimeMillis();
|
|
|
String sign = clientId+secureKey+time;
|
|
@@ -68,7 +77,7 @@ public class ZhengYuanUtil {
|
|
|
* 新增/修改酒店信息
|
|
|
* @return
|
|
|
*/
|
|
|
- public static JSONObject saveHotel(String token, HotelEntity param){
|
|
|
+ public static JSONObject saveHotel(String token, HotelEntity param) throws Exception {
|
|
|
String api = api_domain + api_saveHotel;
|
|
|
|
|
|
HashMap<String, String> header = new HashMap<>();
|
|
@@ -98,7 +107,7 @@ public class ZhengYuanUtil {
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public static JSONObject listHotel(String token, PageDto param){
|
|
|
+ public static JSONObject listHotel(String token, PageDto param) throws Exception {
|
|
|
HashMap<String, String> header = new HashMap<>();
|
|
|
header.put("Authorization", "Bearer " + token);
|
|
|
|
|
@@ -116,16 +125,26 @@ public class ZhengYuanUtil {
|
|
|
* @param str
|
|
|
* @return
|
|
|
*/
|
|
|
- private static JSONObject parseResData(String str){
|
|
|
+ private static JSONObject parseResData(String str) throws Exception{
|
|
|
ResData resData = JSONObject.parseObject(str, ResData.class);
|
|
|
- BaseRuntimeException.isTrue(resData.getCode()!=200, null, "正圆接口响应失败");
|
|
|
+ if (resData.getCode()!=200){
|
|
|
+ String errorMsg = "正圆返回值异常: " + resData.getMessage();
|
|
|
+ log.error(errorMsg);
|
|
|
+ throw new Exception(errorMsg);
|
|
|
+ }
|
|
|
JSONObject parse = JSON.parseObject(resData.getData());
|
|
|
return parse;
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void test1(){
|
|
|
- getCertification();
|
|
|
+ try {
|
|
|
+ getCertification();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|