$article_category['data'], ]; return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result)); } /** * 分类文章列表 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-11-08 * @desc description */ public function DataList() { // 参数 $params = $this->data_request; // 条件 $where = ArticleService::ArticleWhere($params); // 获取总数 $total = ArticleService::ArticleTotal($where); $page_total = ceil($total/$this->page_size); $start = intval(($this->page-1)*$this->page_size); // 获取列表 $data_params = array_merge($params, [ 'm' => $start, 'n' => $this->page_size, 'where' => $where, ]); $data = ArticleService::ArticleList($data_params); // 返回数据 $result = [ 'total' => $total, 'page_total' => $page_total, 'data' => $data['data'], ]; return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result)); } /** * 文章详情 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-11-08 * @desc description */ public function Detail() { // 获取文章 if(!empty($this->data_request['id'])) { // 获取数据 $id = intval($this->data_request['id']); $params = [ 'where' => [ ['is_enable', '=', 1], ['id', '=', $id], ], 'm' => 0, 'n' => 1, ]; $data = ArticleService::ArticleList($params); if(!empty($data['data'][0])) { // 访问统计 ArticleService::ArticleAccessCountInc(['id'=>$id]); // 标签处理,兼容小程序rich-text $data['data'][0]['content'] = ResourcesService::ApMiniRichTextContentHandle($data['data'][0]['content']); // 上一篇、下一篇 $last_next_data = ArticleService::ArticleLastNextData($id); // 返回数据 $result = [ 'data' => $data['data'][0], 'last_next' => $last_next_data, ]; $ret = SystemBaseService::DataReturn($result); } else { $ret = DataReturn(MyLang('article.article_no_data_tips'), -1); } } else { $ret = DataReturn(MyLang('article.article_id_params_tips'), -1); } return ApiService::ApiDataReturn($ret); } } ?>