|
@@ -319,8 +319,8 @@ class NewsService implements NewsServiceInterface
|
|
|
];
|
|
];
|
|
|
// $website_id = $data['website_id'];
|
|
// $website_id = $data['website_id'];
|
|
|
$month = date("Y-m-d H:i:s", strtotime("-30 day"));
|
|
$month = date("Y-m-d H:i:s", strtotime("-30 day"));
|
|
|
- //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
|
|
|
|
|
- // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
|
|
|
|
|
|
|
+ //如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
|
|
|
|
|
+ // 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
|
|
|
switch($data['level']){
|
|
switch($data['level']){
|
|
|
case 1:
|
|
case 1:
|
|
|
case 2:
|
|
case 2:
|
|
@@ -401,7 +401,7 @@ class NewsService implements NewsServiceInterface
|
|
|
->limit($data['textnum'])
|
|
->limit($data['textnum'])
|
|
|
->get()->all();
|
|
->get()->all();
|
|
|
foreach ($result['text'] as $k => $v) {
|
|
foreach ($result['text'] as $k => $v) {
|
|
|
- $result['text'][$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
|
|
|
|
+ $result['text'][$k]->pinyin = $catiall[$v->catid];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if($data['imgnum'] > 0){
|
|
if($data['imgnum'] > 0){
|
|
@@ -416,7 +416,7 @@ class NewsService implements NewsServiceInterface
|
|
|
->limit($data['imgnum'])
|
|
->limit($data['imgnum'])
|
|
|
->get()->all();
|
|
->get()->all();
|
|
|
foreach ($result['img'] as $k => $v) {
|
|
foreach ($result['img'] as $k => $v) {
|
|
|
- $result['img'][$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
|
|
|
|
+ $result['img'][$k]->pinyin = $catiall[$v->catid];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -909,12 +909,17 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
*/
|
|
|
public function selectWebsiteArticle(array $data): array
|
|
public function selectWebsiteArticle(array $data): array
|
|
|
{
|
|
{
|
|
|
- $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
|
|
|
|
|
- $website_id = $data['website_id'];
|
|
|
|
|
- $categorys = $this->processArticlePro($website_id);
|
|
|
|
|
- $catiall = $categorys['catiall'];
|
|
|
|
|
|
|
+ $category = WebsiteCategory::where('website_id', $data['website_id'])->get()->all();
|
|
|
|
|
+ $website_id = $data['website_id'];
|
|
|
|
|
+ // $categorys = $this->processArticlePro($website_id);
|
|
|
|
|
+ $categoryIds = array_column($category, 'category_id');
|
|
|
|
|
+ $aliasPinyins = array_column($category, 'path');
|
|
|
|
|
+ $alias = array_column($category, 'alias');
|
|
|
|
|
+ $cat_arr = array_combine($categoryIds, $aliasPinyins);
|
|
|
|
|
+ $cat_alias_arr = array_combine($categoryIds, $alias);
|
|
|
|
|
+ // return Result::success($cat_arr['205']);
|
|
|
$query = Article::where('status', 1)
|
|
$query = Article::where('status', 1)
|
|
|
- ->whereIn('catid', $category)
|
|
|
|
|
|
|
+ ->whereIn('catid', $categoryIds)
|
|
|
->leftJoinSub(function ($query) use ($website_id) {
|
|
->leftJoinSub(function ($query) use ($website_id) {
|
|
|
$query->from('article_ignore')
|
|
$query->from('article_ignore')
|
|
|
->where('website_id', $website_id);
|
|
->where('website_id', $website_id);
|
|
@@ -925,7 +930,8 @@ class NewsService implements NewsServiceInterface
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
|
});
|
|
});
|
|
|
- // return Result::success($all_articles);
|
|
|
|
|
|
|
+ // ->get()->all();
|
|
|
|
|
+ // return Result::success($query);
|
|
|
if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
|
$query->whereRaw("JSON_CONTAINS(city_arr_id, '" . intval($data['cityid']) . "')");
|
|
$query->whereRaw("JSON_CONTAINS(city_arr_id, '" . intval($data['cityid']) . "')");
|
|
|
}
|
|
}
|
|
@@ -957,10 +963,10 @@ class NewsService implements NewsServiceInterface
|
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
->limit($data['pageSize'])
|
|
->limit($data['pageSize'])
|
|
|
->get();
|
|
->get();
|
|
|
-
|
|
|
|
|
|
|
+ // return Result::success($articles);
|
|
|
foreach ($articles as $k => $v) {
|
|
foreach ($articles as $k => $v) {
|
|
|
- $articles[$k]->category_name = $catiall[$v->catid]['alias'];
|
|
|
|
|
- $articles[$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
|
|
|
|
+ $articles[$k]->category_name = $cat_alias_arr[$v->catid];
|
|
|
|
|
+ $articles[$k]->pinyin = $cat_arr[$v->catid];
|
|
|
}
|
|
}
|
|
|
if (empty($articles)) {
|
|
if (empty($articles)) {
|
|
|
return Result::error("没有符合条件的资讯数据");
|
|
return Result::error("没有符合条件的资讯数据");
|
|
@@ -1075,6 +1081,7 @@ class NewsService implements NewsServiceInterface
|
|
|
$categorys = $this->processArticlePro($wetbsite_id);
|
|
$categorys = $this->processArticlePro($wetbsite_id);
|
|
|
$cat_1st_arr = $categorys['cat_1st_arr'];
|
|
$cat_1st_arr = $categorys['cat_1st_arr'];
|
|
|
$catiall = $categorys['catiall'];
|
|
$catiall = $categorys['catiall'];
|
|
|
|
|
+
|
|
|
$websiteInfoIndexed = $categorys['websiteInfoIndexed'];
|
|
$websiteInfoIndexed = $categorys['websiteInfoIndexed'];
|
|
|
$parent_category = array_column($data, 'parent');
|
|
$parent_category = array_column($data, 'parent');
|
|
|
$parent_cat = [];
|
|
$parent_cat = [];
|
|
@@ -1684,37 +1691,22 @@ private function fetchArticles($catId, $website, $limit, $isImageArticle = false
|
|
|
*/
|
|
*/
|
|
|
function processArticlePro($website_id){
|
|
function processArticlePro($website_id){
|
|
|
$categorys = WebsiteCategory::where('website_id', $website_id)->get()->all();
|
|
$categorys = WebsiteCategory::where('website_id', $website_id)->get()->all();
|
|
|
- $websiteInfoIndexed = array_column($categorys, null, 'category_id');
|
|
|
|
|
|
|
+ // $websiteInfoIndexed = array_column($categorys, null, 'category_id');
|
|
|
// 取出category_id 对应的aLIas_pinyin
|
|
// 取出category_id 对应的aLIas_pinyin
|
|
|
$categoryIds = array_column($categorys, 'category_id');
|
|
$categoryIds = array_column($categorys, 'category_id');
|
|
|
$categoryPIds = array_column($categorys, 'pid');
|
|
$categoryPIds = array_column($categorys, 'pid');
|
|
|
- $aliasPinyins = array_column($categorys, 'aLIas_pinyin');
|
|
|
|
|
|
|
+ $aliasPinyins = array_column($categorys, 'path');
|
|
|
|
|
+ $alias = array_column($categorys, 'alias');
|
|
|
$cat_arr = array_combine($categoryIds, $aliasPinyins);
|
|
$cat_arr = array_combine($categoryIds, $aliasPinyins);
|
|
|
- // return Result::success($categorys);
|
|
|
|
|
- $catiall = [];
|
|
|
|
|
|
|
+ $cat_alias_arr = array_combine($categoryIds, $categoryPIds);
|
|
|
|
|
+ // return Result::success($cat_arr);
|
|
|
|
|
+ // $catiall = [];
|
|
|
//一级所有子级的记录
|
|
//一级所有子级的记录
|
|
|
- $cat_1st_arr = [];
|
|
|
|
|
- foreach ($categorys as $key => $value) {
|
|
|
|
|
- $category_arr_id = json_decode($value->category_arr_id);
|
|
|
|
|
- $pinyin_str = '';
|
|
|
|
|
- // 算出一级 并且算出子级
|
|
|
|
|
- if ($value->pid != 0) {
|
|
|
|
|
- $cat_1st_arr[$value->pid][] = $value->category_id;
|
|
|
|
|
- }
|
|
|
|
|
- foreach ($category_arr_id as $k => $v) {
|
|
|
|
|
- $pinyin_str .= $cat_arr[$v] . '/';
|
|
|
|
|
- }
|
|
|
|
|
- $pinyin_str = rtrim($pinyin_str, '/');
|
|
|
|
|
- $catiall[$value->category_id]['alias'] = $value->alias;
|
|
|
|
|
- $catiall[$value->category_id]['category_id'] = $value->category_id;
|
|
|
|
|
- $catiall[$value->category_id]['type'] = $value->type;
|
|
|
|
|
- $catiall[$value->category_id]['pinyin'] = $pinyin_str;
|
|
|
|
|
- $websiteInfoIndexed[$value->category_id]->pinyin = $pinyin_str;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $cat_alias_arr = array_combine($categoryIds, $alias);
|
|
|
return [
|
|
return [
|
|
|
- 'cat_1st_arr' => $cat_1st_arr,
|
|
|
|
|
- 'catiall' => $catiall,
|
|
|
|
|
- 'websiteInfoIndexed' => $websiteInfoIndexed,
|
|
|
|
|
|
|
+ 'cat_1st_arr' => $cat_alias_arr,
|
|
|
|
|
+ 'catiall' => $cat_arr,
|
|
|
|
|
+ // 'websiteInfoIndexed' => $websiteInfoIndexed,
|
|
|
'categoryIds' => $categoryIds,
|
|
'categoryIds' => $categoryIds,
|
|
|
];
|
|
];
|
|
|
|
|
|