企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ /** * 列表(主键列表,条件数组,闭包查询) * * @param array $param 查询条件 * @return void */ public function doList(Request $request) { //返回订单列表 // $param = $request->param(); $page = $param['page']; $start = $param['start']; $limit = $param['limit']; $offset = ($page - 1) * $limit; //日志类型及查询日期 // $type = array_key_exists("type", $param) ? $param['type'] : null; $date = array_key_exists("date", $param) ? $param['date'] : null; // 匹配条件 // if ((!empty($type) || '0' == $type) && (!empty($date))) { $where = "DATEDIFF(`create_time`,'{$date}') = 0 AND `type` = '{$type}'"; } else if (!empty($type) || '0' == $type) { $where = "`type` = '{$type}'"; } else if (!empty($date)) { $where = "DATEDIFF(`create_time`,'{$date}') = 0"; } else { $date = date('Y-m-d'); //默认参数(当天)配合数据仓库字段加载 $where = "DATEDIFF(`create_time`,'{$date}') = 0"; } try { //查询数据 $result = self::all(function ($query) use ($offset, $limit, $where) { $query->where($where) ->limit($offset, $limit) ->order('create_time', 'desc'); }); $rows = []; foreach ($result as $data) { $item = $data->getData(); array_push($rows, $item); } //返回结果 // $res = array(); //查询数据总量 $total = self::where($where)->count(); if ($total > 0) { $res['rows'] = $rows; $res['total'] = $total; } else { $res['total'] = 0; $res['rows'] = array(); } //请求类型返回 return $res; } catch (\Exception $e) { throw new \think\Exception('异常消息:' . $e->getMessage()); } } ~~~