|
@@ -473,25 +473,25 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function getWebsiteCategory(array $data): array
|
|
|
{
|
|
|
$where = [
|
|
|
- 'website_id'=>$data['website_id']
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
];
|
|
|
// 使用递归查询构建树状结构
|
|
|
$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{
|
|
|
+ if (empty($category)) {
|
|
|
+ return Result::error("查询站点栏目失败", 0);
|
|
|
+ } else {
|
|
|
$count = WebsiteCategory::where($where)->count();
|
|
|
$result = [
|
|
|
'rep' => $category,
|
|
|
- 'count' => $count
|
|
|
+ 'count' => $count,
|
|
|
];
|
|
|
return Result::success($result);
|
|
|
}
|
|
@@ -511,21 +511,21 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
];
|
|
|
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)
|
|
|
- ->leftJoin("ad", function ($join) use ($now) {
|
|
|
- $join->on("ad.pid", "=", "ad_place.id")
|
|
|
- ->where('ad.status', 1)
|
|
|
- ->where('ad.fromtime', '<=', $now)
|
|
|
- ->where('ad.totime', '>=', $now);
|
|
|
- })
|
|
|
- ->select("ad_place.*",'ad.*',"ad_place.id as ad_place_id","ad.name as ad_name")
|
|
|
- ->get()->all();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("此广告位不存在!",0);
|
|
|
- }
|
|
|
- }else{
|
|
|
- return Result::error("请选择广告位!",0);
|
|
|
+ $where[] = ['ad_place.ad_tag', 'like', '%' . $data['ad_tag'] . '%'];
|
|
|
+ $result = AdPlace::where($where)
|
|
|
+ ->leftJoin("ad", function ($join) use ($now) {
|
|
|
+ $join->on("ad.pid", "=", "ad_place.id")
|
|
|
+ ->where('ad.status', 1)
|
|
|
+ ->where('ad.fromtime', '<=', $now)
|
|
|
+ ->where('ad.totime', '>=', $now);
|
|
|
+ })
|
|
|
+ ->select("ad_place.*", 'ad.*', "ad_place.id as ad_place_id", "ad.name as ad_name")
|
|
|
+ ->get()->all();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("此广告位不存在!", 0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Result::error("请选择广告位!", 0);
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
|
|
@@ -676,14 +676,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$where = [
|
|
|
'website_id' => $data['website_id'],
|
|
|
'status' => 1,
|
|
|
- 'type' => $data['type']
|
|
|
- ];
|
|
|
- $num=$data['num'];
|
|
|
- $result=Link::where($where)->orderBy('sort')->limit($num)->get();
|
|
|
- if(!empty($result)){
|
|
|
- return Result::success($result);
|
|
|
- }else{
|
|
|
- return Result::error("本网站暂无此类型友情链接",0);
|
|
|
+ 'type' => $data['type'],
|
|
|
+ ];
|
|
|
+ $num = $data['num'];
|
|
|
+ $result = Link::where($where)->orderBy('sort')->limit($num)->get();
|
|
|
+ if (!empty($result)) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error("本网站暂无此类型友情链接", 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1512,7 +1512,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','alias')->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);
|
|
@@ -1634,5 +1634,48 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::success($list);
|
|
|
}
|
|
|
}
|
|
|
+ // 20250307 根据网站标识获和导航获取站点
|
|
|
+
|
|
|
+ public function getWebsiteNavPoolSite(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ if (isset($data['category_id']) && !empty($data['category_id'])) {
|
|
|
+ array_push($where, ['category_id', '=', $data['category_id']]);
|
|
|
+ }
|
|
|
+ $list = WebsiteCategory::query()->where($where)
|
|
|
+ ->leftJoin('website', 'website.id', '=', 'website_category.website_id')
|
|
|
+ ->select('website_category.*', 'website.website_name')
|
|
|
+ ->distinct()
|
|
|
+ ->get();
|
|
|
+ if (empty($list)) {
|
|
|
+ return Result::error("获取失败", 0);
|
|
|
+ } else {
|
|
|
+ return Result::success($list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function getWebsiteNavPool(array $data): array
|
|
|
+ {
|
|
|
+ // 初始化查询条件数组
|
|
|
+ $query = WebsiteCategory::query();
|
|
|
+
|
|
|
+ // 如果传入了 websiteids,则添加到查询条件中
|
|
|
+ if (isset($data['websiteids']) && !empty($data['websiteids'])) {
|
|
|
+ $query->whereIn('website_id', $data['websiteids']);
|
|
|
+ }
|
|
|
|
|
|
+ // 如果传入了 pid,则添加到查询条件中
|
|
|
+ if (isset($data['pid'])) {
|
|
|
+ $query->where('pid', '=', $data['pid']);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行查询 唯一性 id
|
|
|
+ $list = $query->distinct()->get();
|
|
|
+
|
|
|
+ // 根据查询结果返回相应的结果
|
|
|
+ if ($list->isEmpty()) {
|
|
|
+ return Result::error("获取失败", 0);
|
|
|
+ } else {
|
|
|
+ return Result::success($list->toArray());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|