|
@@ -3078,45 +3078,115 @@ class NewsService implements NewsServiceInterface
|
|
|
return Result::error("该网站不存在", 0);
|
|
|
}
|
|
|
|
|
|
+ $last_category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->where('aLIas_pinyin', $data['last_route'])
|
|
|
+ ->first();
|
|
|
+ if(empty($last_category)){
|
|
|
+ return Result::error("该栏目不存在", 0);
|
|
|
+ }
|
|
|
if(isset($data['id']) && !empty($data['id'])){
|
|
|
-
|
|
|
- $article = Article::where('status', 1)
|
|
|
- ->where('id', $data['id'])
|
|
|
- ->where(function ($query) use ($data) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
- ->orWhereNull("ignore_ids");
|
|
|
- })
|
|
|
- ->first(['cat_arr_id']);
|
|
|
- if(empty($article)){
|
|
|
- return Result::error("该文章不存在", 0);
|
|
|
+
|
|
|
+ switch ($last_category['type']) {
|
|
|
+ case 1:
|
|
|
+
|
|
|
+
|
|
|
+ $article = Article::where('status', 1)
|
|
|
+ ->where('id', $data['id'])
|
|
|
+ ->where(function ($query) use ($data) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
+ ->orWhereNull("ignore_ids");
|
|
|
+ })
|
|
|
+ ->first(['cat_arr_id']);
|
|
|
+ if(empty($article)){
|
|
|
+ return Result::error("该文章不存在", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+
|
|
|
+
|
|
|
+ $article = Good::where('website_id', $data['website_id'])
|
|
|
+ ->where('status', 2)
|
|
|
+ ->where('id', $data['id'])
|
|
|
+ ->first(['cat_arr_id']);
|
|
|
+ if(empty($article)){
|
|
|
+ return Result::error("该商品不存在", 0);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+
|
|
|
+
|
|
|
+ $article = Book::where('website_id', $data['website_id'])
|
|
|
+ ->where('status', 2)
|
|
|
+ ->where('id', $data['id'])
|
|
|
+ ->first(['id','cat_arr_id']);
|
|
|
+ if(empty($article)){
|
|
|
+ return Result::error("该书刊不存在", 0);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+
|
|
|
+
|
|
|
+ $article = JobRecruiting::where('website_id', $data['website_id'])
|
|
|
+ ->where('status', 1)
|
|
|
+ ->where('id', $data['id'])
|
|
|
+ ->first(['cat_arr_id']);
|
|
|
+ if(empty($article)){
|
|
|
+ return Result::error("该招聘不存在", 0);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+
|
|
|
+
|
|
|
+ $article = JobHunting::where('website_id', $data['website_id'])
|
|
|
+ ->where('status', 2)
|
|
|
+ ->where('id', $data['id'])
|
|
|
+ ->first(['cat_arr_id']);
|
|
|
+ if(empty($article)){
|
|
|
+ return Result::error("该求职不存在", 0);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+
|
|
|
+
|
|
|
+ $article = JobRecruiting::where('website_id', $data['website_id'])
|
|
|
+ ->where('status', 1)
|
|
|
+ ->where('id', $data['id'])
|
|
|
+ ->first(['cat_arr_id']);
|
|
|
+ if(empty($article)){
|
|
|
+ $article = JobHunting::where('website_id', $data['website_id'])
|
|
|
+ ->where('status', 2)
|
|
|
+ ->where('id', $data['id'])
|
|
|
+ ->first(['cat_arr_id']);
|
|
|
+ }
|
|
|
+ if(empty($article)){
|
|
|
+ return Result::error("该招工招聘不存在", 0);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return Result::error("该数据不存在", 0);
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
$catid = json_decode($article['cat_arr_id'], true);
|
|
|
if(empty($catid)){
|
|
|
- return Result::error("该文章不存在", 0);
|
|
|
+ return Result::error("该数据不存在", 0);
|
|
|
}
|
|
|
$pinyin = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
->orderByRaw('FIELD(category_id, '. implode(',', $catid). ')')
|
|
|
->whereIn('category_id', $catid)
|
|
|
->pluck('aLIas_pinyin')
|
|
|
->implode('/');
|
|
|
+
|
|
|
+ }
|
|
|
+ if($last_category['pid']!=0){
|
|
|
+ $cat_arr = json_decode($last_category['category_arr_id'], true);
|
|
|
+ $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->orderByRaw('FIELD(category_id, '. implode(',', $cat_arr). ')')
|
|
|
+ ->whereIn('category_id', $cat_arr)
|
|
|
+ ->pluck('aLIas_pinyin')
|
|
|
+ ->implode('/');
|
|
|
}else{
|
|
|
- $last_category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->where('aLIas_pinyin', $data['last_route'])
|
|
|
- ->first();
|
|
|
- if(empty($last_category)){
|
|
|
- return Result::error("该栏目不存在", 0);
|
|
|
- }
|
|
|
- if($last_category['pid']!=0){
|
|
|
- $cat_arr = json_decode($last_category['category_arr_id'], true);
|
|
|
- $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->orderByRaw('FIELD(category_id, '. implode(',', $cat_arr). ')')
|
|
|
- ->whereIn('category_id', $cat_arr)
|
|
|
- ->pluck('aLIas_pinyin')
|
|
|
- ->implode('/');
|
|
|
- }else{
|
|
|
- $pinyin = $last_category['aLIas_pinyin'];
|
|
|
- }
|
|
|
+ $pinyin = $last_category['aLIas_pinyin'];
|
|
|
}
|
|
|
if(empty($pinyin) || $pinyin!=$data['all_route']){
|
|
|
return Result::error('非法路径!');
|