多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
~~~ /** * 列表(主键列表,条件数组,闭包查询) * * @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()); } } ~~~