'desc', ]; public function __construct(App $app) { parent::__construct($app); $this->model = new SystemMcpLog(); // 密钥下拉(搜索用);SystemMcpKey 软删自动排除 $this->assign('select_list_mcp_key', SystemMcpKey::select(), true); } /** * @NodeAnotation(title="列表") */ public function index() { if ($this->request->isAjax()) { if (input('selectFields')) { return $this->selectList(); } list($page, $limit, $where) = $this->buildTableParames(); $count = $this->model ->withJoin('mcpKey', 'LEFT') ->where($where) ->count(); $list = $this->model ->withJoin('mcpKey', 'LEFT') ->where($where) ->page($page, $limit) ->order($this->sort) ->select(); $data = [ 'code' => 0, 'msg' => '', 'count' => $count, 'data' => $list, ]; return json($data); } return $this->fetch(); } /** * @NodeAnotation(title="删除") */ public function delete($id) { $this->checkPostRequest(); $row = $this->model->whereIn('id', $id)->select(); $row->isEmpty() && $this->error('数据不存在'); try { // 仅删除日志记录,不级联影响密钥表 $save = $row->delete(); } catch (\Exception $e) { $this->error('删除失败:' . $e->getMessage()); } $save ? $this->success('删除成功') : $this->error('删除失败'); } }