|
@@ -4,6 +4,7 @@ namespace App\JsonRpc;
|
|
|
use App\Model\Article;
|
|
|
use App\Model\ArticleData;
|
|
|
use App\Model\Category;
|
|
|
+use App\Model\Website;
|
|
|
use App\Model\WebsiteCategory;
|
|
|
use Hyperf\DbConnection\Db;
|
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
@@ -264,23 +265,30 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
+ * 获取新闻详情
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
public function getArticleInfo(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- 'article.id'=>$data['id']
|
|
|
+ 'article.id'=>$data['id'],
|
|
|
+ 'article.status'=>1
|
|
|
];
|
|
|
$result = Article::where($where)->leftJoin("article_data","article.id","article_data.article_id")->first();
|
|
|
- if($result){
|
|
|
- return Result::success($result->toArray());
|
|
|
- }else{
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ $result['category_id'] = $category['category_id'];
|
|
|
+ $result['cat_name'] = $category['name'];
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
/**
|
|
|
- * 获取新闻
|
|
|
+ * 获取头条新闻
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|