|
@@ -5,6 +5,7 @@ use App\Model\Article;
|
|
|
|
|
|
use App\Model\Ad;
|
|
|
use App\Model\Category;
|
|
|
+
|
|
|
use App\Model\AdPlace;
|
|
|
use App\Model\Department;
|
|
|
use App\Model\District;
|
|
@@ -61,6 +62,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
->leftJoin("district", "district.id", "website.city_id")->count();
|
|
|
|
|
|
$result = $resultWwhere->select("website.*", "website_column.column_name", "district.name as city_name")
|
|
|
+
|
|
|
->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])->orderBy("website.id", "desc")->get();
|
|
|
|
|
|
if (empty($result)) {
|
|
@@ -473,10 +475,24 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$where = [
|
|
|
'website_id'=>$data['website_id']
|
|
|
];
|
|
|
- $result = WebsiteCategory::where($where)->orderBy('sort', 'asc')->get();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("查询站点栏目失败", 0);
|
|
|
- } else {
|
|
|
+ // 使用递归查询构建树状结构
|
|
|
+ $category = WebsiteCategory::where($where)
|
|
|
+ ->with([
|
|
|
+ 'children' => function ($query) {
|
|
|
+ $query->orderBy('sort', 'asc');
|
|
|
+ }
|
|
|
+ ])
|
|
|
+ ->orderBy('sort', 'asc')
|
|
|
+ ->where('pid', 0) // 仅查询顶级节点
|
|
|
+ ->get()->all();
|
|
|
+ if(empty($category)){
|
|
|
+ return Result::error("查询站点栏目失败",0);
|
|
|
+ }else{
|
|
|
+ $count = WebsiteCategory::where($where)->count();
|
|
|
+ $result = [
|
|
|
+ 'rep' => $category,
|
|
|
+ 'count' => $count
|
|
|
+ ];
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
@@ -493,7 +509,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
'ad_place.status' => 1,
|
|
|
// 'ad.status' => 1,
|
|
|
];
|
|
|
- if(isset($data['ad_tag']) && !empty($data['ad_tag'])){
|
|
|
+ if (isset($data['ad_tag']) && !empty($data['ad_tag'])) {
|
|
|
$now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
|
|
|
$where[] = ['ad_place.ad_tag','like','%'.$data['ad_tag'].'%'];
|
|
|
$result = AdPlace::where($where)
|
|
@@ -608,44 +624,44 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
public function getWebsiteModelCategory(array $data): array
|
|
|
{
|
|
|
- $website_id=[
|
|
|
- 'website_category.website_id' => $data['website_id']
|
|
|
+ $website_id = [
|
|
|
+ 'website_category.website_id' => $data['website_id'],
|
|
|
];
|
|
|
- $placeid=$data['placeid']-1;
|
|
|
- $pid=[
|
|
|
- 'website_category.pid' => $data['pid'],
|
|
|
+ $placeid = $data['placeid'] - 1;
|
|
|
+ $pid = [
|
|
|
+ 'website_category.pid' => $data['pid'],
|
|
|
];
|
|
|
- var_dump( "=======",$pid);
|
|
|
+ var_dump("=======", $pid);
|
|
|
$num = $data['num'];
|
|
|
// return Result::success($data);
|
|
|
- $result=WebsiteCategory::where($website_id)
|
|
|
- ->leftJoin("category",'website_category.category_id','category.id')
|
|
|
- ->select('website_category.*','category.is_url','category.web_url')
|
|
|
- ->where($pid)
|
|
|
+ $result = WebsiteCategory::where($website_id)
|
|
|
+ ->leftJoin("category", 'website_category.category_id', 'category.id')
|
|
|
+ ->select('website_category.*', 'category.is_url', 'category.web_url')
|
|
|
+ ->where($pid)
|
|
|
// ->with(['children' => function ($query) use ($data) {
|
|
|
// $query->where('website_category.website_id', $data['website_id']);
|
|
|
// }])
|
|
|
- ->orderBy('website_category.sort')
|
|
|
-
|
|
|
- ->offset($placeid)
|
|
|
- ->limit($num)
|
|
|
- ->get();
|
|
|
- foreach($result as $k=>$v){
|
|
|
- $child[$k]['children_countent']=WebsiteCategory::where($website_id)
|
|
|
- ->where('website_category.pid',$v['category_id'])
|
|
|
- ->count();
|
|
|
- if(!empty($child[$k]['children_countent'])){
|
|
|
- $result[$k]['children_count']=$child[$k]['children_countent'];
|
|
|
- }else{
|
|
|
- $result[$k]['children_count']=0;
|
|
|
+ ->orderBy('website_category.sort')
|
|
|
+
|
|
|
+ ->offset($placeid)
|
|
|
+ ->limit($num)
|
|
|
+ ->get();
|
|
|
+ foreach ($result as $k => $v) {
|
|
|
+ $child[$k]['children_countent'] = WebsiteCategory::where($website_id)
|
|
|
+ ->where('website_category.pid', $v['category_id'])
|
|
|
+ ->count();
|
|
|
+ if (!empty($child[$k]['children_countent'])) {
|
|
|
+ $result[$k]['children_count'] = $child[$k]['children_countent'];
|
|
|
+ } else {
|
|
|
+ $result[$k]['children_count'] = 0;
|
|
|
}
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
- if(!empty($result)){
|
|
|
- return Result::success($result);
|
|
|
- }else{
|
|
|
- return Result::error("本网站暂无栏目",0);
|
|
|
- }
|
|
|
+ if (!empty($result)) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error("本网站暂无栏目", 0);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1280,7 +1296,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
return Result::success($websiteInfo->toArray());
|
|
|
}
|
|
|
-// 自助建站--fr-------------------
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取网站底部基础信息
|
|
@@ -1408,7 +1424,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$category = WebsiteCategory::where('website_id',$data['website_id'])->pluck('category_id')->all();
|
|
|
// return Result::success($category);
|
|
|
if (empty($category)) {
|
|
|
- return Result::error("暂无此导航",0);
|
|
|
+ return Result::error("暂无此导航",0);
|
|
|
}
|
|
|
$query = Category::whereIn('id', $category);
|
|
|
if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
@@ -1419,7 +1435,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$city_category = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->pluck('id');
|
|
|
// $where[] = ['JSON_CONTAINS(city_arr_id, ?)', $data['cityid']];
|
|
|
if (empty($city_category)) {
|
|
|
- return Result::error("暂无此城市下的导航", 0);
|
|
|
+ return Result::error("暂无此城市下的导航", 0);
|
|
|
}
|
|
|
$result['catid'] = $city_category;
|
|
|
$city = 1;
|
|
@@ -1440,8 +1456,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$department = 1;
|
|
|
}
|
|
|
}
|
|
|
- if(!empty($city) && !empty($department)){
|
|
|
- // var_dump("城市和职能部门----------------------",$result);
|
|
|
+ if (!empty($city) && !empty($department)) {
|
|
|
+ // var_dump("城市和职能部门----------------------",$result);
|
|
|
$sel_category = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->pluck('id');
|
|
|
if (empty($sel_category)) {
|
|
|
return Result::error("暂无此城市和职能部门下的导航", 0);
|
|
@@ -1449,9 +1465,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$result['catid'] = $sel_category;
|
|
|
}
|
|
|
if (empty($result)) {
|
|
|
- return Result::error("暂无导航",0);
|
|
|
- }
|
|
|
-
|
|
|
+ return Result::error("暂无导航", 0);
|
|
|
+ }
|
|
|
// department_id
|
|
|
} else {
|
|
|
return Result::error("参数错误", 0);
|
|
@@ -1465,9 +1480,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteCategoryHead(array $data): array
|
|
|
{
|
|
|
- $where = [];
|
|
|
+
|
|
|
if (isset($data['website_id']) && !empty($data['website_id'])) {
|
|
|
- array_push($where, ['website_id', '=', $data['website_id']]);
|
|
|
+ $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("找不到网站", 0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Result::error("参数错误", 0);
|
|
|
}
|
|
|
if (isset($data['catid']) && !empty($data['catid'])) {
|
|
|
$fcatid = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->first();
|
|
@@ -1481,7 +1501,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
- /*
|
|
|
+
|
|
|
+ /*
|
|
|
* 获取某个栏目
|
|
|
* @param array $data
|
|
|
* @return array
|
|
@@ -1493,7 +1514,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (empty($website)) {
|
|
|
return Result::error("暂无该网站", 0);
|
|
|
}
|
|
|
- $result = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['category_id'])->select('category_id', 'name')->first();
|
|
|
+ $result = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['category_id'])->select('category_id','alias')->first();
|
|
|
// return Result::success($category);
|
|
|
if (empty($result)) {
|
|
|
return Result::error("暂无此导航", 0);
|
|
@@ -1508,7 +1529,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
//20250212 网站标识
|
|
|
public function addWebsiteGroup(array $data): array
|
|
|
{
|
|
|
-
|
|
|
//判斷name是不是重复
|
|
|
$websiteGroupInfo = WebsiteGroup::query()->where('name', $data['name'])->first();
|
|
|
if (!empty($websiteGroupInfo)) {
|
|
@@ -2379,4 +2399,5 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
|
|
|
// 自传建站---------------liu------------
|
|
|
+
|
|
|
}
|