diff --git a/application/api/controller/Hikmessage.php b/application/api/controller/Hikmessage.php new file mode 100644 index 0000000..aed3100 --- /dev/null +++ b/application/api/controller/Hikmessage.php @@ -0,0 +1,64 @@ +isPost()) { + $receive = $request->post(); + + $page = input("get.page") ? input("get.page") : 1; + $page = intval($page); + $limit = input("get.limit") ? input("get.limit") : 10; + $limit = intval($limit); + $start = $limit * ($page - 1); + + $where = []; + + if (isset($receive['messageId']) && !empty($receive['messageId'])) { + $where['messageId'] = $receive['messageId']; + } + if (isset($receive['deviceId']) && !empty($receive['deviceId'])) { + $where['deviceId'] = $receive['deviceId']; + } + if (isset($receive['type']) && !empty($receive['type'])) { + $where['type'] = $receive['type']; + } + + $result = Db::table("hikmessage")->where($where)->order('messageTime desc')->limit($start, $limit)->select(); + $num = Db::table("hikmessage")->where($where)->count(); + + foreach ($result as &$item) { + if ($item['messageTime']) $item['messageTime'] = date("Y-m-d H:i:s", substr($item['messageTime'], 0, 10)); + $item['body'] = json_decode($item['body'], true); + unset($item['id']); + } + + $list["count"] = $num; + $list["list"] = $result; + + return $this->jsonSuccess('成功', $list); + } + + return $this->jsonError('请求失败,仅允许POST请求方式'); + } +} \ No newline at end of file