|
@@ -80,7 +80,6 @@ class WebService implements WebServiceInterface
|
|
|
*/
|
|
*/
|
|
|
public function getWebsiteModelCategory(array $data): array
|
|
public function getWebsiteModelCategory(array $data): array
|
|
|
{
|
|
{
|
|
|
- // return Result::success($data);
|
|
|
|
|
$website_id = [
|
|
$website_id = [
|
|
|
'website_id' => $data['website_id'],
|
|
'website_id' => $data['website_id'],
|
|
|
];
|
|
];
|
|
@@ -88,8 +87,7 @@ class WebService implements WebServiceInterface
|
|
|
if (empty($website_column_arr)) {
|
|
if (empty($website_column_arr)) {
|
|
|
return Result::error("未查询到此网站所属网系!", 0);
|
|
return Result::error("未查询到此网站所属网系!", 0);
|
|
|
}
|
|
}
|
|
|
- $website_column_arr = json_decode($website_column_arr, true);
|
|
|
|
|
- // return Result::success(!in_array(3,$website_column_arr) && $data['pid'] == 0);
|
|
|
|
|
|
|
+ $website_column = json_decode($website_column_arr, true);
|
|
|
// 初始化 $pid 数组
|
|
// 初始化 $pid 数组
|
|
|
// $pid = [];
|
|
// $pid = [];
|
|
|
// 以下注释掉的代码是之前的逻辑,用于获取非顶级分类的 pid
|
|
// 以下注释掉的代码是之前的逻辑,用于获取非顶级分类的 pid
|
|
@@ -101,11 +99,12 @@ class WebService implements WebServiceInterface
|
|
|
$pid = $pidQuery->pluck('pid');
|
|
$pid = $pidQuery->pluck('pid');
|
|
|
$pid = array_values(array_unique($pid->toArray()));
|
|
$pid = array_values(array_unique($pid->toArray()));
|
|
|
// 构建查询语句
|
|
// 构建查询语句
|
|
|
|
|
+ $guanwang_intersect = $this->processWebColumn($website_column);
|
|
|
$query = WebsiteCategory::where($website_id)
|
|
$query = WebsiteCategory::where($website_id)
|
|
|
- ->when(!in_array(3, $website_column_arr) && $data['pid'] == 0, function ($query) use ($website_column_arr) {
|
|
|
|
|
|
|
+ ->when($guanwang_intersect == 0 && $data['pid'] == 0, function ($query) use ($guanwang_intersect) {
|
|
|
$query->where('is_show', 1);
|
|
$query->where('is_show', 1);
|
|
|
})
|
|
})
|
|
|
- ->when(in_array(3, $website_column_arr) || $data['pid'] != 0, function ($query) use ($data) {
|
|
|
|
|
|
|
+ ->when($guanwang_intersect > 0 || $data['pid'] != 0, function ($query) use ($data,$guanwang_intersect) {
|
|
|
$query->where('pid', $data['pid']);
|
|
$query->where('pid', $data['pid']);
|
|
|
})
|
|
})
|
|
|
->where('type','!=',8)
|
|
->where('type','!=',8)
|
|
@@ -420,6 +419,9 @@ class WebService implements WebServiceInterface
|
|
|
*/
|
|
*/
|
|
|
public function selectWebsiteArticle(array $data): array
|
|
public function selectWebsiteArticle(array $data): array
|
|
|
{
|
|
{
|
|
|
|
|
+ if (!isset($data['website_id']) || empty($data['website_id'])) {
|
|
|
|
|
+ return Result::error("网址必填", 0);
|
|
|
|
|
+ }
|
|
|
$website = Website::where('id', $data['website_id'])->first();
|
|
$website = Website::where('id', $data['website_id'])->first();
|
|
|
if (empty($website)) {
|
|
if (empty($website)) {
|
|
|
return Result::error("网站不存在", 0);
|
|
return Result::error("网站不存在", 0);
|
|
@@ -431,10 +433,9 @@ class WebService implements WebServiceInterface
|
|
|
$website_id = $data['website_id'];
|
|
$website_id = $data['website_id'];
|
|
|
$categorys = $this->processArticlePro($website_id);
|
|
$categorys = $this->processArticlePro($website_id);
|
|
|
$diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
$diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
|
-
|
|
|
|
|
- // return Result::success($diff_pid_categoryIds);
|
|
|
|
|
- if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
|
|
- return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
|
|
|
|
+ $guanwang_intersect = $this->processWebColumn($website_column);
|
|
|
|
|
+ if ($guanwang_intersect > 0 && !empty($diff_pid_categoryIds)) {
|
|
|
|
|
+ return Result::error("此为官网,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
}
|
|
}
|
|
|
// return Result::success(reset($diff_pid_categoryIds) == 0);
|
|
// return Result::success(reset($diff_pid_categoryIds) == 0);
|
|
|
// $cat_1st_arr = $categorys['cat_1st_arr'];
|
|
// $cat_1st_arr = $categorys['cat_1st_arr'];
|
|
@@ -535,7 +536,8 @@ class WebService implements WebServiceInterface
|
|
|
}
|
|
}
|
|
|
$diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
$diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
|
// return Result::success($diff_pid_categoryIds);
|
|
// return Result::success($diff_pid_categoryIds);
|
|
|
- if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
|
|
|
|
+ $guanwang_intersect = $this->processWebColumn($website_column);
|
|
|
|
|
+ if ($guanwang_intersect > 0 && !empty($diff_pid_categoryIds)) {
|
|
|
return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -732,7 +734,8 @@ class WebService implements WebServiceInterface
|
|
|
|
|
|
|
|
// return Result::success($catiall);
|
|
// return Result::success($catiall);
|
|
|
$diff_pid_categoryIds = $categorys['diff_pid_categoryIds'];
|
|
$diff_pid_categoryIds = $categorys['diff_pid_categoryIds'];
|
|
|
- if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
|
|
|
|
+ $guanwang_intersect = $this->processWebColumn($website_column);
|
|
|
|
|
+ if ($guanwang_intersect > 0 && !empty($diff_pid_categoryIds)) {
|
|
|
return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
}
|
|
}
|
|
|
$websiteInfoIndexed = $categorys['websiteInfoIndexed'];
|
|
$websiteInfoIndexed = $categorys['websiteInfoIndexed'];
|
|
@@ -966,7 +969,8 @@ class WebService implements WebServiceInterface
|
|
|
if (!empty($parent_category) && is_array($parent_category)) {
|
|
if (!empty($parent_category) && is_array($parent_category)) {
|
|
|
$categorys = $this->processArticlePro($website_id);
|
|
$categorys = $this->processArticlePro($website_id);
|
|
|
$diff_pid_categoryIds = $categorys['diff_pid_categoryIds'];
|
|
$diff_pid_categoryIds = $categorys['diff_pid_categoryIds'];
|
|
|
- if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
|
|
|
|
+ $guanwang_intersect = $this->processWebColumn($website_column);
|
|
|
|
|
+ if ($guanwang_intersect > 0 && !empty($diff_pid_categoryIds)) {
|
|
|
return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
}
|
|
}
|
|
|
$catiall = $categorys['catiall'];
|
|
$catiall = $categorys['catiall'];
|
|
@@ -1104,7 +1108,8 @@ class WebService implements WebServiceInterface
|
|
|
$catiall = $categorys['catiall'];
|
|
$catiall = $categorys['catiall'];
|
|
|
$diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
$diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
|
// return Result::success($diff_pid_categoryIds);
|
|
// return Result::success($diff_pid_categoryIds);
|
|
|
- if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
|
|
|
|
+ $guanwang_intersect = $this->processWebColumn($website_column);
|
|
|
|
|
+ if ($guanwang_intersect > 0 && !empty($diff_pid_categoryIds)) {
|
|
|
return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
}
|
|
}
|
|
|
if (isset($data['catid']) && !empty($data['catid'])) {
|
|
if (isset($data['catid']) && !empty($data['catid'])) {
|
|
@@ -1601,7 +1606,7 @@ class WebService implements WebServiceInterface
|
|
|
return Result::error("参数错误", 0);
|
|
return Result::error("参数错误", 0);
|
|
|
}
|
|
}
|
|
|
$website_head = Website::where('id', $data['website_id'])
|
|
$website_head = Website::where('id', $data['website_id'])
|
|
|
- ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description', 'suffix', 'website_url')->first();
|
|
|
|
|
|
|
+ ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description', 'suffix', 'website_url','website_column_id')->first();
|
|
|
$website_foot = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
$website_foot = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
if (empty($website_foot)) {
|
|
if (empty($website_foot)) {
|
|
|
return Result::error("暂无底部基础信息", 0);
|
|
return Result::error("暂无底部基础信息", 0);
|
|
@@ -3919,25 +3924,60 @@ class WebService implements WebServiceInterface
|
|
|
}
|
|
}
|
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
|
}
|
|
}
|
|
|
- public function processWebColumn(): array
|
|
|
|
|
|
|
+ public function processWebColumn($website_column)
|
|
|
{
|
|
{
|
|
|
- $pidQuery = WebsiteColumn::where('column_name','==','官网')
|
|
|
|
|
- ->where('pid', '!=', 0)
|
|
|
|
|
- ->where('type','!=',8)
|
|
|
|
|
- ->orderBy('sort')
|
|
|
|
|
- ->select('pid', 'category_id', 'alias', 'aLIas_pinyin');
|
|
|
|
|
- $pid = $pidQuery->pluck('pid');
|
|
|
|
|
- $query = WebsiteCategory::where($website_id)
|
|
|
|
|
- ->where('type','!=',8)
|
|
|
|
|
- ->where('pid', $pid)
|
|
|
|
|
- ->offset($data['placeid'])
|
|
|
|
|
- ->limit($data['num'])
|
|
|
|
|
- ->orderBy('sort')
|
|
|
|
|
- ->orderBy('updated_at', 'desc');
|
|
|
|
|
- $result = $query->get()->all();
|
|
|
|
|
- if (empty($result)) {
|
|
|
|
|
- return Result::error("暂无相关分类信息", 0);
|
|
|
|
|
|
|
+ $guanwang_column = WebsiteColumn::where('column_name', '官网')
|
|
|
|
|
+ ->pluck('id')
|
|
|
|
|
+ ->all();
|
|
|
|
|
+ $guanwang_intersect = count(array_intersect($website_column, $guanwang_column));
|
|
|
|
|
+ return $guanwang_intersect;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param array $data
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getWebsiteApplyJoin(array $data): array
|
|
|
|
|
+ {
|
|
|
|
|
+ $web = Website::where('id',$data['website_id'])->first();
|
|
|
|
|
+ if (empty($web)) {
|
|
|
|
|
+ return Result::error("暂无相关网站信息", 0);
|
|
|
}
|
|
}
|
|
|
- return Result::success($result);
|
|
|
|
|
|
|
+ $category = WebsiteCategory::where('category_id',$data['category_id'])->first();
|
|
|
|
|
+ if (empty($category)) {
|
|
|
|
|
+ return Result::error("暂无相关栏目信息", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ $child_cate = WebsiteCategory::where('website_category.pid',$category['category_id'])
|
|
|
|
|
+ ->with(['cate_article' => function ($query) use ($data) {
|
|
|
|
|
+ $query->where('article.status',1)
|
|
|
|
|
+ ->leftJoinSub(function ($query) use ($data) {
|
|
|
|
|
+ $query->from('article_ignore')
|
|
|
|
|
+ ->where('website_id',$data['website_id']);
|
|
|
|
|
+ }, 'article_ignore', function ($join) {
|
|
|
|
|
+ $join->on('article_ignore.article_id', '=', 'article.id');
|
|
|
|
|
+ })
|
|
|
|
|
+ ->where(function ($query) {
|
|
|
|
|
+ $query->whereNull('article_ignore.article_id')
|
|
|
|
|
+ ->orWhere(function ($subQuery) {
|
|
|
|
|
+ $subQuery->whereNotNull('article_ignore.article_id')
|
|
|
|
|
+ ->where('article_ignore.is_ignore', 0)
|
|
|
|
|
+ ->where(function ($subSubQuery) {
|
|
|
|
|
+ $subSubQuery->where('article_ignore.c_show_time', '<=', date('Y-m-d H:i:s'))
|
|
|
|
|
+ ->orWhereNull('article_ignore.c_show_time');
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ ->orderBy('article.updated_at', 'desc')
|
|
|
|
|
+ ->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');
|
|
|
|
|
+ });
|
|
|
|
|
+ }])
|
|
|
|
|
+ ->select('website_category.alias','website_category.path','website_category.category_id')
|
|
|
|
|
+ ->orderBy('website_category.sort','asc')
|
|
|
|
|
+ ->get()->all();
|
|
|
|
|
+ if (empty($child_cate)) {
|
|
|
|
|
+ return Result::error("暂无相关子栏目信息", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result::success($child_cate);
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+
|
|
|
|
|
+}
|