|
|
@@ -3470,10 +3470,18 @@ class NewsService implements NewsServiceInterface
|
|
|
// 验证栏目路由
|
|
|
$last_category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
->where('aLIas_pinyin', $data['last_route'])
|
|
|
- ->first();
|
|
|
- if (empty($last_category)) {
|
|
|
+ ->get()->all();
|
|
|
+ if (count($last_category) == 0) {
|
|
|
return Result::error("该栏目不存在", 0);
|
|
|
}
|
|
|
+ if(count($last_category) > 1){
|
|
|
+ return Result::error("该子级栏目存在多个,路由验证失败!", 0);
|
|
|
+ }
|
|
|
+ if(count($last_category) == 1){
|
|
|
+ $last_category = $last_category[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ // return Result::success($last_category);
|
|
|
if (isset($data['id']) && !empty($data['id'])) {
|
|
|
// `type` int unsigned DEFAULT '1' COMMENT '类型:1资讯(默认)2商品3书刊音像4招聘5求职类型:1资讯(默认)2商品3书刊音像4招聘5求职6招工招聘'
|
|
|
switch ($last_category['type']) {
|
|
|
@@ -3562,27 +3570,32 @@ class NewsService implements NewsServiceInterface
|
|
|
return Result::error("该数据不存在", 0);
|
|
|
break;
|
|
|
}
|
|
|
- $catid = json_decode($article['cat_arr_id'], true);
|
|
|
+ $catid =0 ;
|
|
|
+ $catidArray = json_decode($article['cat_arr_id'], true);
|
|
|
+ $catid = !empty($catidArray) ? end($catidArray) : null;
|
|
|
+ // return Result::success($article['cat_arr_id']);
|
|
|
if (empty($catid)) {
|
|
|
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 {
|
|
|
- $pinyin = $last_category['aLIas_pinyin'];
|
|
|
+ ->where('category_id',$catid)
|
|
|
+ ->select('path')
|
|
|
+ ->pluck('path');
|
|
|
+ }else{
|
|
|
+ if ($last_category['pid'] != 0) {
|
|
|
+ $cat_arr = json_decode($last_category['category_arr_id'], true);
|
|
|
+ $catid = !empty($cat_arr) ? end($cat_arr) : null;
|
|
|
+ $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->where('category_id',$catid)
|
|
|
+ ->where('path',$data['all_route'])
|
|
|
+ ->pluck('path');
|
|
|
+ } else {
|
|
|
+ $pinyin[0] = $last_category['aLIas_pinyin'];
|
|
|
+ }
|
|
|
}
|
|
|
- if (empty($pinyin) || $pinyin != $data['all_route']) {
|
|
|
+ // return Result::success($pinyin[0]);
|
|
|
+ if (empty($pinyin) || count($pinyin)>1 || $pinyin[0] != $data['all_route']) {
|
|
|
return Result::error('非法路径!');
|
|
|
} else {
|
|
|
return Result::success($pinyin);
|