From cca504b84583f8f8289b34e794939b8590a16446 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 23 五月 2023 14:34:22 +0800
Subject: [PATCH] optimzie exit room

---
 java110-core/src/main/java/com/java110/core/factory/CallApiServiceFactory.java |   45 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/java110-core/src/main/java/com/java110/core/factory/CallApiServiceFactory.java b/java110-core/src/main/java/com/java110/core/factory/CallApiServiceFactory.java
index aa1f429..9808e05 100755
--- a/java110-core/src/main/java/com/java110/core/factory/CallApiServiceFactory.java
+++ b/java110-core/src/main/java/com/java110/core/factory/CallApiServiceFactory.java
@@ -63,6 +63,26 @@
      * @param <T>
      * @return
      */
+    public static <T> T getForApi(String appId, T param, String serviceCode, Class<T> t,String userId) {
+
+        IPageData pd = PageData.newInstance().builder(userId, "鏈煡", "", "", "", "", "", "", appId);
+
+        List<T> list = getForApis(pd, param, serviceCode, t);
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    /**
+     * 鏌ヨ
+     *
+     * @param param       浼犲叆瀵硅薄
+     * @param serviceCode 鏈嶅姟缂栫爜
+     * @param t           杩斿洖绫�
+     * @param <T>
+     * @return
+     */
     public static <T> T postForApi(String appId, T param, String serviceCode, Class<T> t, String userId) {
 
         IPageData pd = PageData.newInstance().builder(userId, "鏈煡", "", "", "", "", "", "", appId);
@@ -158,12 +178,17 @@
         }
 
         JSONObject resultVo = JSONObject.parseObject(responseEntity.getBody());
-
-        if (ResultVo.CODE_MACHINE_OK != resultVo.getInteger("code")) {
-            throw new SMOException(resultVo.getString("msg"));
+        Object bObj = null;
+        if(resultVo.containsKey("code")){
+            if (ResultVo.CODE_MACHINE_OK != resultVo.getInteger("code")) {
+                throw new SMOException(resultVo.getString("msg"));
+            }
+            bObj = resultVo.get("data");
+        }else{
+            bObj = resultVo;
         }
 
-        Object bObj = resultVo.get("data");
+
         JSONArray datas = null;
         if (bObj instanceof JSONObject) {
             datas = new JSONArray();
@@ -209,11 +234,15 @@
 
         JSONObject resultVo = JSONObject.parseObject(responseEntity.getBody());
 
-        if (!"0".equals(resultVo.getString("code"))) {
-            throw new SMOException(resultVo.getString("msg"));
+        Object bObj = null;
+        if(resultVo.containsKey("code")){
+            if (ResultVo.CODE_MACHINE_OK != resultVo.getInteger("code")) {
+                throw new SMOException(resultVo.getString("msg"));
+            }
+            bObj = resultVo.get("data");
+        }else{
+            bObj = resultVo;
         }
-
-        Object bObj = resultVo.get("data");
         JSONArray datas = null;
         if (bObj instanceof JSONObject) {
             datas = new JSONArray();

--
Gitblit v1.8.0