|
@@ -548,24 +548,47 @@ class NewsService implements NewsServiceInterface
|
|
|
public function selectWebsiteArticleInfo(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- 'article.id'=>$data['id'],
|
|
|
- 'article.status'=>1
|
|
|
+ 'article.id' => $data['id'],
|
|
|
+ 'article.status' => 1,
|
|
|
];
|
|
|
- $result = Article::where($where)->leftJoin("article_data","article.id","article_data.article_id")
|
|
|
+
|
|
|
+ $result = Article::where($where)
|
|
|
+ ->leftJoin("article_data", "article.id", "article_data.article_id")
|
|
|
+ ->leftJoin("article_extend", "article_extend.article_id", "article.id")
|
|
|
->where(function ($query) use ($data) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
|
|
|
- ->orWhereNull("ignore_ids");
|
|
|
+ $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
+ ->orWhereNull("ignore_ids");
|
|
|
})
|
|
|
+ ->select('article.*','article_data.content','article_data.article_id',
|
|
|
+ 'article_extend.website_url','article_extend.email','article_extend.contacts',
|
|
|
+ 'article_extend.contacts_mobile','article_extend.contacts_address','article_extend.zip_code',
|
|
|
+ 'article_extend.enterprise_name'
|
|
|
+ )
|
|
|
->first();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("暂无此新闻!",0);
|
|
|
- }
|
|
|
- $category = WebsiteCategory::where('website_id',$data['website_id'])->where(['category_id'=>$result['catid']])->first();
|
|
|
- if(empty($category)){
|
|
|
- return Result::error("查询失败",0);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无此新闻!", 0);
|
|
|
}
|
|
|
+ $category = WebsiteCategory::leftJoin('website', 'website.id', '=', 'website_category.website_id')
|
|
|
+ ->select('website_category.*', 'website.website_name', 'website.suffix')
|
|
|
+ ->where('website_category.website_id', $data['website_id'])
|
|
|
+ ->where(['website_category.category_id' => $result['catid']])
|
|
|
+ ->first();
|
|
|
+ if (empty($category)) {
|
|
|
+ return Result::error("查询失败", 0);
|
|
|
+ }
|
|
|
+ //手动推荐文章
|
|
|
+ $commend_ids = $result['commend_id'] ? json_decode($result['commend_id']) : [];
|
|
|
+ $commendArticle = Article::whereIn('id', $commend_ids)
|
|
|
+ ->where('status', 1)
|
|
|
+ ->select('id', 'title', 'catid', 'imgurl', 'hits', 'created_at')
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit(5)
|
|
|
+ ->get();
|
|
|
$result['category_id'] = $category['category_id'];
|
|
|
$result['cat_name'] = $category['alias'];
|
|
|
+ $result['website_name'] = $category['website_name'] ?? "";
|
|
|
+ $result['suffix'] = $category['suffix'] ?? "";
|
|
|
+ $result['commendArticle'] = $commendArticle;
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
/**
|