|
@@ -5889,205 +5889,6 @@ class NewsService implements NewsServiceInterface
|
|
|
->toArray();
|
|
|
return Result::success($articlesList);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 模块新闻加强plus版
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function getWebsiteAllArticle(array $data): array
|
|
|
- {
|
|
|
- $time1 = microtime(true);
|
|
|
- $data = json_decode($data['id'], true);
|
|
|
- $wetbsite_id = $data['website_id'] ?? 2;
|
|
|
- $categorys = $this->processArticlePro($wetbsite_id);
|
|
|
- $cat_1st_arr = $categorys['cat_1st_arr'];
|
|
|
- $catiall = $categorys['catiall'];
|
|
|
- $websiteInfoIndexed = $categorys['websiteInfoIndexed'];
|
|
|
- $parent_category = array_column($data, 'parent');
|
|
|
- $parent_cat = [];
|
|
|
- $child_category = array_column($data,'child');
|
|
|
- if(!empty($parent_category)){
|
|
|
- foreach($parent_category as $key => $value){
|
|
|
- $arr = array_map('intval', explode(',', $value));
|
|
|
- $parent_cat[$key] = $arr[0] ?? 0;
|
|
|
- $parent_category = $arr[0] ?? 0;
|
|
|
- $article_imgnum = $arr[1] ?? 0;
|
|
|
- $article_textnum = $arr[2] ?? 0;
|
|
|
- if($parent_category != 0){
|
|
|
- $category_arr = array_merge([$parent_category], $cat_1st_arr[$parent_category]);
|
|
|
- if($article_imgnum != 0){
|
|
|
- $img_article = Article::whereIn('catid', $category_arr)
|
|
|
- ->where('status',1)
|
|
|
- ->where('imgurl','!=', '')
|
|
|
- ->leftJoinSub(function ($query) use ($wetbsite_id) {
|
|
|
- $query->from('article_ignore')
|
|
|
- ->where('website_id', $wetbsite_id);
|
|
|
- }, 'article_ignore', function ($join) {
|
|
|
- $join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
- })
|
|
|
- ->where(function ($query) use ($wetbsite_id) {
|
|
|
- $query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
|
|
|
- })
|
|
|
- ->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')
|
|
|
- ->limit($article_imgnum)
|
|
|
- ->get()->all();
|
|
|
- foreach ($img_article as $k => $v) {
|
|
|
- $img_article[$k]->category_name = $catiall[$v->catid]['alias'];
|
|
|
- $img_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
-
|
|
|
- }
|
|
|
- }else{
|
|
|
- $img_article = [];
|
|
|
- }
|
|
|
- if($article_textnum != 0){
|
|
|
- $text_article = Article::whereIn('catid', $category_arr)
|
|
|
- ->where('status',1)
|
|
|
- ->leftJoinSub(function ($query) use ($wetbsite_id) {
|
|
|
- $query->from('article_ignore')
|
|
|
- ->where('website_id', $wetbsite_id);
|
|
|
- }, 'article_ignore', function ($join) {
|
|
|
- $join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
- })
|
|
|
- ->where(function ($query) use ($wetbsite_id) {
|
|
|
- $query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
|
|
|
- })
|
|
|
- ->select('id','title','author','updated_at','introduce','islink','linkurl','copyfrom','cat_arr_id','catid')
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
- ->limit($article_textnum)
|
|
|
- ->get()->all();
|
|
|
- foreach ($text_article as $k => $v) {
|
|
|
- $text_article[$k]->category_name = $catiall[$v->catid]['alias'];
|
|
|
- $text_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
- // $text_article[$k]->alias = $catiall[$v->catid]['alias'];
|
|
|
- }
|
|
|
- }else{
|
|
|
- $text_article = [];
|
|
|
- }
|
|
|
- $catiall[$parent_category]['imgnum'] = $img_article;
|
|
|
- $catiall[$parent_category]['textnum'] = $text_article;
|
|
|
- $parent[$key] = $catiall[$parent_category];
|
|
|
- }else{
|
|
|
- $parent[$key] = '';
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(!empty($child_category)){
|
|
|
- foreach($child_category as $key => $value){
|
|
|
- $arr = array_map('intval', explode(',', $value));
|
|
|
- $parent_category = $parent_cat[$key];
|
|
|
- $child_category = $arr[0] ?? 0;
|
|
|
- $article_imgnum = $arr[1] ?? 0;
|
|
|
- $article_textnum = $arr[2] ?? 0;
|
|
|
-
|
|
|
- if($child_category != 0){
|
|
|
- $all_childcat = $cat_1st_arr[$parent_category];
|
|
|
- $processedChildCat = array_map(function ($v) use ($websiteInfoIndexed) {
|
|
|
- // 从 $websiteInfoIndexed 中获取对应的数据
|
|
|
- $info = $websiteInfoIndexed[$v];
|
|
|
- // 返回一个包含所需信息的数组
|
|
|
- return [
|
|
|
- 'alias' => $info->alias,
|
|
|
- 'category_id' => $info->category_id,
|
|
|
- 'aLIas_pinyin' => $info->aLIas_pinyin,
|
|
|
- 'pid' => $info->pid,
|
|
|
- 'type' => $info->type,
|
|
|
- 'cat_arr_id' => $info->category_arr_id ?? ['出错'],
|
|
|
- 'pinyin' => $info->pinyin,
|
|
|
- ];
|
|
|
- }, $all_childcat);
|
|
|
- if($article_imgnum != 0){
|
|
|
- $img_article = Article::where('catid', $child_category)
|
|
|
- ->where('status',1)
|
|
|
- ->where('imgurl','!=', '')
|
|
|
- ->leftJoinSub(function ($query) use ($wetbsite_id) {
|
|
|
- $query->from('article_ignore')
|
|
|
- ->where('website_id', $wetbsite_id);
|
|
|
- }, 'article_ignore', function ($join) {
|
|
|
- $join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
- })
|
|
|
- ->where(function ($query) use ($wetbsite_id) {
|
|
|
- $query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
|
|
|
- })
|
|
|
- ->select('id','title','imgurl','author','updated_at','introduce','islink','linkurl','copyfrom','cat_arr_id','catid')
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
- ->limit($article_imgnum)
|
|
|
- ->get()->all();
|
|
|
- foreach ($img_article as $k => $v) {
|
|
|
- // var_dump($v);
|
|
|
- // var_dump($k);
|
|
|
- $img_article[$k]->category_name = $catiall[$v->catid]['alias'];
|
|
|
- $img_article[$k]->alias = $catiall[$v->catid]['alias'];
|
|
|
- }
|
|
|
- }else{
|
|
|
- $img_article = [];
|
|
|
- }
|
|
|
- if($article_textnum != 0){
|
|
|
- $text_article = Article::where('catid', $child_category)
|
|
|
- ->where('status',1)
|
|
|
- ->leftJoinSub(function ($query) use ($wetbsite_id) {
|
|
|
- $query->from('article_ignore')
|
|
|
- ->where('website_id', $wetbsite_id);
|
|
|
- }, 'article_ignore', function ($join) {
|
|
|
- $join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
- })
|
|
|
- ->where(function ($query) use ($wetbsite_id) {
|
|
|
- $query->whereNull('article_ignore.article_id')
|
|
|
- ->orWhere('article_ignore.website_id', '!=', $wetbsite_id);
|
|
|
- })
|
|
|
- ->select('id','title','author','updated_at','introduce','islink','linkurl','copyfrom','cat_arr_id','catid')
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
- ->limit($article_textnum)
|
|
|
- ->get()->all();
|
|
|
- foreach ($text_article as $k => $v) {
|
|
|
- // var_dump($v);
|
|
|
- // var_dump($k);
|
|
|
- $text_article[$k]->category_name = $catiall[$v->catid]['alias'];
|
|
|
- // $text_article[$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
- $text_article[$k]->alias = $catiall[$v->catid]['alias'];
|
|
|
- }
|
|
|
- }else{
|
|
|
- $text_article = [];
|
|
|
- }
|
|
|
- $catiall[$child_category]['all_childcat'] = $processedChildCat;
|
|
|
- $catiall[$child_category]['imgnum'] = $img_article;
|
|
|
- $catiall[$child_category]['textnum'] = $text_article;
|
|
|
- $child[$key] = $catiall[$child_category];
|
|
|
- // var_dump($pids);
|
|
|
- }else{
|
|
|
- $child[$key] = '';
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- foreach($parent as $key => $value){
|
|
|
- $result[$key] = $value;
|
|
|
- if(!empty($child[$key])){
|
|
|
- // var_dump($child[$key]);
|
|
|
-
|
|
|
- $result[$key]['child'] = $child[$key];
|
|
|
- // $value[$key]['child'] = $child[$key];
|
|
|
- }else{
|
|
|
- $result[$key]['child'] = [
|
|
|
- "alias" => null,
|
|
|
- "category_id" => null,
|
|
|
- "type" => null,
|
|
|
- "pinyin" => null,
|
|
|
- "all_childcat" => [],
|
|
|
- "imgnum" => [],
|
|
|
- "textnum" => []
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- $time2 = microtime(true);
|
|
|
- $time_ = ($time2 - $time1);
|
|
|
- var_dump($time2, $time1, $time_, '接口需要多少时间');
|
|
|
- return Result::success($result);
|
|
|
-
|
|
|
-}
|
|
|
/**
|
|
|
* 企业管理
|
|
|
* @param array $data
|