// +---------------------------------------------------------------------- declare(strict_types=1); namespace addon\iot\controller\backend; use think\facade\View; use ywxapp\controller\BackendBase; use addon\iot\model\Connection; /** * 客户端连接控制器 */ class Connections extends BackendBase { /** * 连接列表页(layui.table 前端拉取) */ public function connections() { return View::fetch('admin/connections'); } /** * 连接列表(layui.table 分页 JSON) */ public function connectionsTable() { $page = max(1, (int) input('get.page', 1)); $limit = (int) input('get.limit', 20); if ($limit < 1 || $limit > 100) { $limit = 20; } $q = Connection::order('id', 'desc'); $count = (int) (clone $q)->count(); $rows = $q->page($page, $limit)->select()->toArray(); $this->result->success(['list' => $rows, 'count' => $count]); } }