|
@@ -415,38 +415,30 @@ class NewsService implements NewsServiceInterface
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 获取新闻列表
|
|
* @param array $data
|
|
* @param array $data
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
public function getWebsiteArticleList(array $data): array
|
|
public function getWebsiteArticleList(array $data): array
|
|
{
|
|
{
|
|
$where= [];
|
|
$where= [];
|
|
-
|
|
|
|
- if(isset($data['title']) && $data['title']){
|
|
|
|
- array_push($where,['article.title','like','%'.$data['title'].'%']);
|
|
|
|
- }
|
|
|
|
- if(isset($data['category_name']) && $data['category_name']){
|
|
|
|
- array_push($where,['category.name','like','%'.$data['category_name'].'%']);
|
|
|
|
- }
|
|
|
|
- if(isset($data['author']) && $data['author']){
|
|
|
|
- array_push($where,['article.author','=',$data['author']]);
|
|
|
|
- }
|
|
|
|
- if(isset($data['islink']) && $data['islink']!==""){
|
|
|
|
- array_push($where,['article.islink','=',$data['islink']]);
|
|
|
|
- }
|
|
|
|
- if(isset($data['status']) && $data['status']!==""){
|
|
|
|
- array_push($where,['article.status','=',$data['status']]);
|
|
|
|
|
|
+
|
|
|
|
+ if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
|
+ array_push($where,['article.title','like','%'.$data['keyword'].'%']);
|
|
|
|
+ }
|
|
|
|
+ if(isset($data['catid']) && !empty($data['catid'])){
|
|
|
|
+ $category = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['catid'])->select('category_id')->first();
|
|
|
|
+ if(empty($category)){
|
|
|
|
+ return Result::error("此网站暂无此栏目",0);
|
|
|
|
+ }
|
|
|
|
+ array_push($where,['catid',$data['catid']]);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$rep = Article::where($where)
|
|
$rep = Article::where($where)
|
|
- ->whereNotIn('article.status',[404])
|
|
|
|
- ->leftJoin('category','article.catid','category.id')
|
|
|
|
- ->select("article.*","category.name as category_name")
|
|
|
|
- ->orderBy("article.id","desc")
|
|
|
|
|
|
+ ->orderBy("created_at","desc")
|
|
->limit($data['pageSize'])
|
|
->limit($data['pageSize'])
|
|
->offset(($data['page']-1)*$data['pageSize'])->get();
|
|
->offset(($data['page']-1)*$data['pageSize'])->get();
|
|
- $count = Article::where($where)->whereNotIn('article.status',[404])
|
|
|
|
- ->leftJoin('category','article.catid','category.id')->count();
|
|
|
|
|
|
+ $count = Article::where($where)->count();
|
|
$data = [
|
|
$data = [
|
|
'rows'=>$rep->toArray(),
|
|
'rows'=>$rep->toArray(),
|
|
'count'=>$count
|
|
'count'=>$count
|