|
|
@@ -393,7 +393,6 @@ class NewsService implements NewsServiceInterface
|
|
|
unset($data['type_id']);
|
|
|
$user_id = $data['user_id'];
|
|
|
unset($data['user_id']);
|
|
|
-
|
|
|
$where = [];
|
|
|
$status1 = [];
|
|
|
if (isset($data['id']) && $data['id']) {
|
|
|
@@ -439,7 +438,13 @@ class NewsService implements NewsServiceInterface
|
|
|
$join->on('article.web_site_id', '=', 'website_category.website_id')
|
|
|
->on('article.catid', '=', 'website_category.category_id');
|
|
|
})
|
|
|
- ->select("article.*", "category.name as category_name", "website_category.alias")
|
|
|
+ ->when($type_id != 10000 && !empty($data['website_id']), function ($query) use ($data) {
|
|
|
+ $query->leftJoin('article_ignore', function ($join) use ($data) {
|
|
|
+ $join->on('article.id', '=', 'article_ignore.article_id')
|
|
|
+ ->where('article_ignore.website_id', $data['website_id']);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->select("article.*", "category.name as category_name", "website_category.alias",'article_ignore.c_show_time')
|
|
|
->orderBy("article.updated_at", "desc")
|
|
|
->limit($data['pageSize'])
|
|
|
->offset(($data['page'] - 1) * $data['pageSize'])->get();
|
|
|
@@ -1263,15 +1268,23 @@ class NewsService implements NewsServiceInterface
|
|
|
$result['text'] = $query
|
|
|
->whereIn('catid', $categoryIds)
|
|
|
->leftJoinSub(function ($query) use ($website_id) {
|
|
|
- $query->from('article_ignore')
|
|
|
- ->where('website_id', $website_id);
|
|
|
+ $query->from('article_ignore')
|
|
|
+ ->where('website_id', $website_id);
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($website_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
+ // ->where(function ($query) use ($website_id) {
|
|
|
+ // $query->whereNull('article_ignore.article_id')
|
|
|
+ // ->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
|
+ // })
|
|
|
->select(
|
|
|
'article.id',
|
|
|
'article.title',
|
|
|
@@ -1283,7 +1296,9 @@ class NewsService implements NewsServiceInterface
|
|
|
'article.copyfrom',
|
|
|
'article.cat_arr_id',
|
|
|
'article.catid',
|
|
|
- 'article.level'
|
|
|
+ 'article.level',
|
|
|
+ // 'article_ignore.is_ignore',
|
|
|
+ // 'article_ignore.c_show_time',
|
|
|
)
|
|
|
->offset($data['placeid'])
|
|
|
->limit($data['textnum'])
|
|
|
@@ -1310,7 +1325,9 @@ class NewsService implements NewsServiceInterface
|
|
|
'article.copyfrom',
|
|
|
'article.cat_arr_id',
|
|
|
'article.catid',
|
|
|
- 'article.level'
|
|
|
+ 'article.level',
|
|
|
+ // 'article_ignore.is_ignore',
|
|
|
+ // 'article_ignore.c_show_time',
|
|
|
)
|
|
|
->offset($data['placeid'])
|
|
|
->limit($data['imgnum'])
|
|
|
@@ -1355,10 +1372,25 @@ class NewsService implements NewsServiceInterface
|
|
|
->orWhereNull("level")
|
|
|
->orWhereRaw("level = '[]'");
|
|
|
})
|
|
|
- ->where(function ($query) use ($data) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
- ->orWhereNull("ignore_ids");
|
|
|
+ ->leftJoinSub(function ($query) use ($data) {
|
|
|
+ $query->from('article_ignore')
|
|
|
+ ->where('website_id', $data['website_id']);
|
|
|
+ }, 'article_ignore', function ($join) {
|
|
|
+ $join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
+ })
|
|
|
+ ->where(function ($query) {
|
|
|
+ $query->whereNull('article_ignore.article_id')
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
+ // ->where(function ($query) use ($data) {
|
|
|
+ // $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
+ // ->orWhereNull("ignore_ids");
|
|
|
+ // })
|
|
|
+
|
|
|
->orderBy("updated_at", "desc")
|
|
|
->offset($placeid)
|
|
|
->limit($data['pagesize'])
|
|
|
@@ -1413,9 +1445,13 @@ class NewsService implements NewsServiceInterface
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($website_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
->select(
|
|
|
'article.id',
|
|
|
@@ -1851,20 +1887,24 @@ class NewsService implements NewsServiceInterface
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($website_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
});
|
|
|
- // ->get()->all();
|
|
|
+ // ->get()->all();
|
|
|
// return Result::success($query);
|
|
|
if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(city_arr_id, '" . intval($data['cityid']) . "')");
|
|
|
+ $query->whereRaw("JSON_CONTAINS(article.city_arr_id, '" . intval($data['cityid']) . "')");
|
|
|
}
|
|
|
if (isset($data['department_id']) && !empty($data['department_id'])) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(department_arr_id, '" . intval($data['department_id']) . "')");
|
|
|
+ $query->whereRaw("JSON_CONTAINS(article.department_arr_id, '" . intval($data['department_id']) . "')");
|
|
|
}
|
|
|
if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
|
- $query->where('title', 'like', '%' . $data['keyword'] . '%');
|
|
|
+ $query->where('article.title', 'like', '%' . $data['keyword'] . '%');
|
|
|
}
|
|
|
// 计算总数
|
|
|
$count = $query->count();
|
|
|
@@ -1885,6 +1925,8 @@ class NewsService implements NewsServiceInterface
|
|
|
'article.catid',
|
|
|
'article.department_arr_id',
|
|
|
'article.city_arr_id',
|
|
|
+ // 'article_ignore.c_show_time',
|
|
|
+ // 'article_ignore.is_ignore'
|
|
|
)
|
|
|
->orderBy("updated_at", "desc")
|
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
@@ -2048,9 +2090,13 @@ class NewsService implements NewsServiceInterface
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($wetbsite_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
->select('article.id', 'article.title', 'article.imgurl', 'article.author', 'article.updated_at', 'article.introduce', 'article.islink', 'article.linkurl', 'article.copyfrom', 'article.cat_arr_id', 'article.catid')
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
@@ -2072,9 +2118,13 @@ class NewsService implements NewsServiceInterface
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($wetbsite_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
->select('id', 'title', 'author', 'updated_at', 'introduce', 'islink', 'linkurl', 'copyfrom', 'cat_arr_id', 'catid')
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
@@ -2130,9 +2180,13 @@ class NewsService implements NewsServiceInterface
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($wetbsite_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
->select('id', 'title', 'imgurl', 'author', 'updated_at', 'introduce', 'islink', 'linkurl', 'copyfrom', 'cat_arr_id', 'catid')
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
@@ -2156,9 +2210,13 @@ class NewsService implements NewsServiceInterface
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($wetbsite_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
->select('id', 'title', 'author', 'updated_at', 'introduce', 'islink', 'linkurl', 'copyfrom', 'cat_arr_id', 'catid')
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
@@ -2287,31 +2345,35 @@ class NewsService implements NewsServiceInterface
|
|
|
$category_arr = array_merge([$parent_category], $cat_1st_arr[$parent_category] ?? [0]);
|
|
|
// return Result::success($category_arr);
|
|
|
if ($article_imgnum != 0) {
|
|
|
- $img_article = Article::whereIn('catid', $category_arr)
|
|
|
- ->where('status', 1)
|
|
|
- ->where('imgurl', '!=', '')
|
|
|
+ $img_article = Article::whereIn('article.catid', $category_arr)
|
|
|
+ ->where('article.status', 1)
|
|
|
+ ->where('article.imgurl', '!=', '')
|
|
|
->leftJoinSub(function ($query) use ($website_id) {
|
|
|
$query->from('article_ignore')
|
|
|
->where('website_id', $website_id);
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($website_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
->select(
|
|
|
- 'id',
|
|
|
- 'title',
|
|
|
- 'imgurl',
|
|
|
- 'author',
|
|
|
- 'updated_at',
|
|
|
- 'introduce',
|
|
|
- 'islink',
|
|
|
- 'linkurl',
|
|
|
- 'copyfrom',
|
|
|
- 'cat_arr_id',
|
|
|
- 'catid as category_id'
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ 'article.cat_arr_id',
|
|
|
+ 'article.catid as category_id'
|
|
|
)
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
->limit($article_imgnum)
|
|
|
@@ -2327,29 +2389,33 @@ class NewsService implements NewsServiceInterface
|
|
|
$img_article = [];
|
|
|
}
|
|
|
if ($article_textnum != 0) {
|
|
|
- $text_article = Article::whereIn('catid', $category_arr)
|
|
|
- ->where('status', 1)
|
|
|
+ $text_article = Article::whereIn('article.catid', $category_arr)
|
|
|
+ ->where('article.status', 1)
|
|
|
->leftJoinSub(function ($query) use ($website_id) {
|
|
|
$query->from('article_ignore')
|
|
|
->where('website_id', $website_id);
|
|
|
}, 'article_ignore', function ($join) {
|
|
|
$join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
})
|
|
|
- ->where(function ($query) use ($website_id) {
|
|
|
+ ->where(function ($query) {
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
+ ->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'));
|
|
|
+ });
|
|
|
})
|
|
|
->select(
|
|
|
- 'id',
|
|
|
- 'title',
|
|
|
- 'author',
|
|
|
- 'updated_at',
|
|
|
- 'introduce',
|
|
|
- 'islink',
|
|
|
- 'linkurl',
|
|
|
- 'copyfrom',
|
|
|
- 'cat_arr_id',
|
|
|
- 'catid as category_id'
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ 'article.cat_arr_id',
|
|
|
+ 'article.catid as category_id'
|
|
|
)
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
->limit($article_textnum)
|