request->param('phase', ''); if (!$phase && !$this->request->param('type')) { $current = CycleService::current($this->auth->id); $phase = $current['phase'] ?: ''; } elseif (!$phase) { // 内容型模块默认按当前阶段优先 $current = CycleService::current($this->auth->id); $phase = $current['phase'] ?: ''; } $data = ContentService::lists($this->auth->id, [ 'type' => $this->request->param('type', ''), 'phase' => $phase, 'category_id' => (int)$this->request->param('category_id', 0), 'part' => $this->request->param('part', ''), 'page' => (int)$this->request->param('page', 1), 'limit' => (int)$this->request->param('limit', 10), ]); $data['category'] = $this->categoryList($this->request->param('type', '')); $this->success('', $data); } /** * 内容详情 */ public function detail() { $data = ContentService::detail($this->auth->id, $this->request->param('id', 0)); if (!$data) { $this->error('内容不存在'); } $this->success('', $data); } /** * 分类 */ public function categories() { $type = $this->request->param('type', ''); $query = Db::name('content_category')->where('status', 'normal'); if ($type) { $query->where('type', $type); } $this->success('', ['list' => $query->order('weigh', 'desc')->select()]); } protected function categoryList($type) { if (!$type) { return []; } return Db::name('content_category') ->where('type', $type) ->where('status', 'normal') ->order('weigh', 'desc') ->field('id,name') ->select(); } }