Update MediaService.php

This commit is contained in:
邹景立 2021-09-15 23:41:24 +08:00
parent 3f50646503
commit bf8a55e53b

View File

@ -41,16 +41,15 @@ class MediaService extends Service
public function news($id, array $map = []): array
{
// 文章主体数据
$where = ['id' => $id, 'is_deleted' => 0];
$data = WechatNews::mk()->where($where)->where($map)->find();
$map1 = ['id' => $id, 'is_deleted' => 0];
$data = WechatNews::mk()->where($map1)->where($map)->find();
if (empty($data)) return [];
// 文章内容编号
$data['articles'] = [];
$data['articleids'] = str2arr($data['article_id']);
if (empty($data['articleids'])) return $data;
$aids = $data['articleids'] = str2arr($data['article_id']);
if (empty($data['articleids'])) return $data->toArray();
// 文章内容集合
$query = WechatNewsArticle::mk();
$query->whereIn('id', $data['articleids'])->orderField('id', $data['articleids']);
$query = WechatNewsArticle::mk()->whereIn('id', $aids)->orderField('id', $aids);
$data['articles'] = $query->withoutField('create_by,create_at')->select()->toArray();
return $data->toArray();
}