q 1 anno fa
parent
commit
6964eaded9
1 ha cambiato i file con 14 aggiunte e 102 eliminazioni
  1. 14 102
      webmain/task/openapi/openmeetAction.php

+ 14 - 102
webmain/task/openapi/openmeetAction.php

@@ -17,10 +17,7 @@ class openmeetClassAction extends openapiAction
         $rawArr = $this->getpostarr();
 
         if (!isset($rawArr['device_id'])) {
-            return [
-                "code"=>-1,
-                "message"=>"参数错误!"
-            ];
+            $this->showreturn([], "参数错误", -1);
         }
 
         $rawData = m('meeting_room')->getone(" mac like '%{$rawArr['device_id']}%'", "id, room_name");
@@ -30,23 +27,17 @@ class openmeetClassAction extends openapiAction
         $now = date('Y年m月d日('.$this->getWeek().') H:i');
 
         if ($rawData['id'] ?? 0 > 0) {
-            return [
-                "code"=>200,
-                "message"=>"已绑定",
-                "data"=>[
-                    "room_id"=>$rawData['id'],
-                    "meetingRoomName"=>$rawData['room_name'],
-                    "meetingTime"=>$now,
-                    "stateText"=>isset($meetData['id']) ? "会议中" : "空闲中",
-                    "meetingState"=>isset($meetData['id']),
-                    "meetingId"=>$meetData['id'] ?? null,
-                ]
+            $data = [
+                "room_id"=>$rawData['id'],
+                "meetingRoomName"=>$rawData['room_name'],
+                "meetingTime"=>$now,
+                "stateText"=>isset($meetData['id']) ? "会议中" : "空闲中",
+                "meetingState"=>isset($meetData['id']),
+                "meetingId"=>$meetData['id'] ?? null,
             ];
+            $this->showreturn($data, "请求成功");
         } else {
-            return [
-                "code"=>0,
-                "message"=>"设备未绑定!"
-            ];
+            $this->showreturn([], "设备未绑定", 0);
         }
     }
 
@@ -55,25 +46,13 @@ class openmeetClassAction extends openapiAction
         $rawArr = $this->getpostarr();
 
         if (!isset($rawArr['room_id'])) {
-            return [
-                "code"=>-1,
-                "message"=>"参数错误!",
-                "data"=>[
-                    "meetingState"=>False
-                ]
-            ];
+            $this->showreturn([], "参数错误", 201);
         }
 
         $rawData = m('meeting_room')->getone(" id = '{$rawArr['room_id']}'");
 
         if (!isset($rawData['room_name'])) {
-            return [
-                "code"=>-1,
-                "message"=>"未找到会议室!",
-                "data"=>[
-                    "meetingState"=>False
-                ]
-            ];
+            $this->showreturn([], "未找到会议室", 202);
         }
 
         $sqlStr = /** @lang text */
@@ -84,14 +63,7 @@ class openmeetClassAction extends openapiAction
         $meetData = $this->db->getall($sqlStr);
 
         if (count($meetData) == 0) {
-            return [
-                "code"=>2,
-                "message"=>"暂无会议!",
-                "data"=>[
-                    "meetingState"=>False,
-                    "data" => $rawData['room_name']
-                ]
-            ];
+            $this->showreturn(["meeting_list"=>[],"basic_information"=>[],"meetingTopic"=>[],"participants"=>[]], "暂无会议", 203);
         }
 
 
@@ -177,50 +149,7 @@ class openmeetClassAction extends openapiAction
             $data['participants'] = [];
         }
 
-
-        return $data;
-
-//        $topicMeetingSql = /** @lang text */
-//            "SELECT id  FROM `xinhu_meeting_key` where meet_state = 1 and start_time REGEXP '".date("Y-m-d H:i:s")."' and meeting_room = '".$rawData['room_name']."'";
-
-//        $topicMeetingData = $this->db->getall($topicMeetingSql);
-
-//        $topics = $this->db->getall("select `id`, `topic_title`, `topic_attendee`, `topic_state` from `[Q]meeting_topics` where mid = {$topicMeetingSql['id']} order by sort");
-
-
-        // 将日期时间字符串转换为UNIX时间戳
-        $ts = strtotime($meetData['start_time']);
-        // 根据需要格式化日期
-        $meetStartDate = date("Y年m月d日", $ts);
-        $meetDate=$meetStartDate." (".$this->getWeek($meetStartDate).") ".date("H:i", strtotime($meetData['start_time']))."~".date("H:i", strtotime($meetData['end_time']));
-
-        $topicsList = [];
-
-        // 会议议题处理
-        for ($i = 0; $i < count($topics); $i++) {
-            $info = $topics[$i];
-            $topicsList[$i]['id'] = $info['id'];
-            $topicsList[$i]['text'] = $info['topic_title'];
-            $topicsList[$i]['tip'] = $this->topicState($info['topic_state']);
-            $topicsList[$i]['state'] = $info['topic_state'];
-            $topicsList[$i]['person'] = explode(',', $info['topic_attendee'] );
-        }
-
-        // 接口返回数据
-        $res=[
-            "code"=>200,
-            "message"=>"请求成功!",
-            "data"=>[
-                "meetingId"=>$rawData['id'],
-                "meetingRoomName"=>$rawData['room_name'],
-                "meetingName"=>$meetData['title'],
-                "meetingTime"=>$meetDate,
-                "meetingPerson"=>explode(",", $meetData['attendees']),
-                "meetingTopic"=>$topicsList ?? [],
-                "meetingState"=>!empty($rawData['mac'])
-            ]
-        ];
-        return $res;
+        $this->showreturn($data, "请求成功");
     }
 
     // 切换议题
@@ -230,23 +159,6 @@ class openmeetClassAction extends openapiAction
         $this->showreturn($rawArr,'请求成功!');
     }
 
-    protected function topicState($code): string
-    {
-        $info = '等待';
-        switch ($code) {
-            case 1:
-                $info = '待进行';
-                break;
-            case 2:
-                $info = '进行中';
-                break;
-            case 3:
-                $info = '已结束';
-                break;
-        }
-        return $info;
-    }
-
     protected function getWeek($date=null) {
         if (!isset($date)) {
             $date = date("Y-m-d H:i:s");