|
@@ -444,6 +444,7 @@ class NewsService implements NewsServiceInterface
|
|
*/
|
|
*/
|
|
public function getWebsiteArticleList(array $data): array
|
|
public function getWebsiteArticleList(array $data): array
|
|
{
|
|
{
|
|
|
|
+ // return Result::success($data);
|
|
$where[] = ['status', '=', 1];
|
|
$where[] = ['status', '=', 1];
|
|
if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
array_push($where,['article.title','like','%'.$data['keyword'].'%']);
|
|
array_push($where,['article.title','like','%'.$data['keyword'].'%']);
|
|
@@ -474,10 +475,34 @@ class NewsService implements NewsServiceInterface
|
|
$query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
|
|
$query->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0")
|
|
->orWhereNull("ignore_ids");
|
|
->orWhereNull("ignore_ids");
|
|
})
|
|
})
|
|
|
|
+ ->select(
|
|
|
|
+ 'article.id',
|
|
|
|
+ 'article.title',
|
|
|
|
+ 'article.imgurl',
|
|
|
|
+ 'article.author',
|
|
|
|
+ 'article.updated_at',
|
|
|
|
+ 'article.introduce',
|
|
|
|
+ 'article.islink',
|
|
|
|
+ 'article.linkurl',
|
|
|
|
+ 'article.copyfrom',
|
|
|
|
+ 'article.catid')
|
|
->orderBy("updated_at", "desc")
|
|
->orderBy("updated_at", "desc")
|
|
->limit($data['pageSize'])
|
|
->limit($data['pageSize'])
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
- ->get();
|
|
|
|
|
|
+ ->get()
|
|
|
|
+ // ;
|
|
|
|
+ ->map(function ($article ) use ($data) {
|
|
|
|
+ $catid = $article->catid ?? 0;
|
|
|
|
+ $pinyin = '';
|
|
|
|
+ $category = WebsiteCategory::where('category_id', $catid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
|
+ $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
|
+ if ($category->pid != 0 && !empty($category->aLIas_pinyin)) {
|
|
|
|
+ $childCategory = WebsiteCategory::where('category_id', $category->pid)->where('website_category.website_id', $data['website_id'])->first();
|
|
|
|
+ $pinyin = $childCategory->aLIas_pinyin ? $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
|
|
|
|
+ }
|
|
|
|
+ $article->pinyin = $pinyin;
|
|
|
|
+ return $article;
|
|
|
|
+ });
|
|
|
|
|
|
$count = Article::where(function ($query) use ($where) {
|
|
$count = Article::where(function ($query) use ($where) {
|
|
foreach ($where as $condition) {
|
|
foreach ($where as $condition) {
|