文章接口开发
parent
f100e1d7a6
commit
92b7d27d59
|
|
@ -13,6 +13,7 @@ namespace app\api\controller;
|
|||
use app\service\ApiService;
|
||||
use app\service\SystemBaseService;
|
||||
use app\service\ArticleService;
|
||||
use app\service\ResourcesService;
|
||||
|
||||
/**
|
||||
* 文章
|
||||
|
|
@ -130,10 +131,16 @@ class Article extends Common
|
|||
// 访问统计
|
||||
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],
|
||||
'category_list' => $article_category['data'],
|
||||
'data' => $data['data'][0],
|
||||
'last_next' => $last_next_data,
|
||||
];
|
||||
$ret = SystemBaseService::DataReturn($result);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -598,7 +598,7 @@ class ArticleService
|
|||
];
|
||||
$last = self::DataHandle(Db::name('Article')->where($where)->field($field)->order('id desc')->limit(1)->select()->toArray());
|
||||
|
||||
// 上一条数据
|
||||
// 下一条数据
|
||||
$where = [
|
||||
['is_enable', '=', 1],
|
||||
['id', '>', $article_id],
|
||||
|
|
@ -606,8 +606,8 @@ class ArticleService
|
|||
$next = self::DataHandle(Db::name('Article')->where($where)->field($field)->order('id asc')->limit(1)->select()->toArray());
|
||||
|
||||
return [
|
||||
'last' => empty($last) ? [] : $last[0],
|
||||
'next' => empty($next) ? [] : $next[0],
|
||||
'last' => empty($last) ? null : $last[0],
|
||||
'next' => empty($next) ? null : $next[0],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue