|
@@ -3065,6 +3065,66 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * c端 - 验证路由
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function checkWebsiteRoute(array $data): array
|
|
|
+ {
|
|
|
+ $web = Website::where('id', $data['website_id'])->first(['id','website_name']);
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error("该网站不存在", 0);
|
|
|
+ }
|
|
|
+ // 验证栏目路由
|
|
|
+ if(isset($data['id']) && !empty($data['id'])){
|
|
|
+ // `status` int DEFAULT '1' COMMENT '状态: 2:已拒绝 ;1:已发布,0待发布 草稿箱 404删除(移除)
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ // return Result::success($article);
|
|
|
+ $catid = json_decode($article['cat_arr_id'], true);
|
|
|
+ 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('/');
|
|
|
+ }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'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(empty($pinyin) || $pinyin!=$data['all_route']){
|
|
|
+ return Result::error('非法路径!');
|
|
|
+ }else{
|
|
|
+ return Result::success($pinyin);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 验证导航名称是否重复
|
|
|
* @return void
|