refactor: 修改文章导出接口
This commit is contained in:
@@ -187,13 +187,13 @@ class Article
|
||||
{
|
||||
$schema = [
|
||||
'id' => 'ID',
|
||||
'category_name' => '分类名称',
|
||||
'title' => '标题',
|
||||
'category_name' => '文章分类',
|
||||
'title' => '文章名称',
|
||||
'author' => '作者',
|
||||
'source' => '来源',
|
||||
'image' => '封面图片',
|
||||
'link' => '外链',
|
||||
'desc' => '描述',
|
||||
'link' => '跳转链接',
|
||||
'desc' => '文章描述',
|
||||
'content' => '内容详情',
|
||||
'recommend' => '是否推荐',
|
||||
'sort' => '排序值',
|
||||
@@ -223,7 +223,7 @@ class Article
|
||||
$param = request()->param(['title', 'category_id', 'created_at']);
|
||||
$data = ArticleModel::field([
|
||||
'*',
|
||||
'CONCAT("' . $image_host . '", `image`)' => 'image',
|
||||
'image',
|
||||
'CASE WHEN recommend = 1 THEN "是" ELSE "否" END' => 'recommend',
|
||||
'CASE WHEN enabled = 1 THEN "是" ELSE "否" END' => 'enabled',
|
||||
])
|
||||
@@ -243,7 +243,11 @@ class Article
|
||||
'category_id',
|
||||
'category',
|
||||
])
|
||||
->bindAttr('category', ['category_name' => 'name']);
|
||||
->bindAttr('category', ['category_name' => 'name'])
|
||||
->each(function ($item) use($image_host) {
|
||||
$item->image = !empty($item->image) ? $image_host . $item->image : '';
|
||||
return $item;
|
||||
});
|
||||
|
||||
return $data->toArray();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user