|
@@ -680,6 +680,7 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteArticlett(array $data): array
|
|
|
{
|
|
|
+ // return Result::success($data['website_id']);
|
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
|
|
|
$category = array_values(array_unique($category->toArray()));
|
|
|
$result = [];
|
|
@@ -710,17 +711,20 @@ class NewsService implements NewsServiceInterface
|
|
|
$catid = $article->catid;
|
|
|
$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)) {
|
|
|
+ if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
|
|
|
$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;
|
|
|
+ if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
|
|
|
+ $pinyin = $childCategory->aLIas_pinyin ? $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
}
|
|
|
$article->pinyin = $pinyin;
|
|
|
return $article;
|
|
|
});
|
|
|
- if (empty($result)) {
|
|
|
- return Result::success([]);
|
|
|
- }
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::success([]);
|
|
|
+ }
|
|
|
return Result::success($result);
|
|
|
} else {
|
|
|
return Result::error("参数错误level=7,id不能为空", 0);
|
|
@@ -759,17 +763,15 @@ class NewsService implements NewsServiceInterface
|
|
|
->map(function ($article) use ($data) {
|
|
|
$catid = $article->catid;
|
|
|
$pinyin = '';
|
|
|
- // $category = WebsiteCategory::whereIn('category_id', $catArrId)->where('website_category.website_id', $data['website_id'])->get()->all();
|
|
|
- // if ($catArrId) {
|
|
|
- // foreach ($catArrId as $categoryId) {
|
|
|
$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)) {
|
|
|
+ if (!empty($category->aLIas_pinyin) && $category->pid != 0) {
|
|
|
$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;
|
|
|
+ if ($childCategory && !empty($childCategory->aLIas_pinyin)) {
|
|
|
+ $pinyin = $childCategory->aLIas_pinyin ? $childCategory->aLIas_pinyin.'/'. $category->aLIas_pinyin : null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
}
|
|
|
- // }
|
|
|
- // }
|
|
|
$article->pinyin = $pinyin;
|
|
|
return $article;
|
|
|
});
|