// +---------------------------------------------------------------------- declare(strict_types=1); namespace addon\iot\controller\backend; use think\facade\View; use ywxapp\controller\BackendBase; use addon\iot\model\Message; /** * 消息日志控制器 */ class Messages extends BackendBase { /** * 消息日志页(layui.table 前端拉取) */ public function messages() { return View::fetch('admin/messages'); } /** * 消息列表(layui.table 分页 JSON,支持主题过滤) */ public function messagesTable() { $topic = trim((string) input('get.topic', '')); $page = max(1, (int) input('get.page', 1)); $limit = (int) input('get.limit', 20); if ($limit < 1 || $limit > 100) { $limit = 20; } $q = Message::order('id', 'desc'); if ($topic !== '') { $q->where('topic', 'like', "%{$topic}%"); } $count = (int) (clone $q)->count(); $rows = $q->page($page, $limit)->select()->toArray(); $this->result->success(['list' => $rows, 'count' => $count]); } }