Przeglądaj źródła

修改c端:路由匹配、获取网站单页导航、获取网站单页列表、获取网站单页详情、获取网站栏目信息(c端)、获取网站栏目信息(b端自助建站)

FengR 1 miesiąc temu
rodzic
commit
6e05c8d7f5
2 zmienionych plików z 88 dodań i 28 usunięć
  1. 61 28
      app/JsonRpc/WebService.php
  2. 27 0
      app/Model/SinglePage.php

+ 61 - 28
app/JsonRpc/WebService.php

@@ -69,6 +69,7 @@ use Swoole\Coroutine;
 use App\Model\Message;
 use App\Model\ResearchTopic;
 use App\Model\RetopicUser;
+use App\Model\SinglePage;
 #[RpcService(name: "WebService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class WebService implements WebServiceInterface
 {
@@ -235,7 +236,7 @@ class WebService implements WebServiceInterface
                 ->first();
         }
         if (isset($data['foot_pinyin']) && !empty($data['foot_pinyin'])) {
-            $result = FooterCategory::where('website_id', $data['website_id'])->where('name_pinyin', $data['foot_pinyin'])->first(['id']);
+            $result = WebsiteCategory::where('website_id', $data['website_id'])->where('type',8)->where('path', $data['foot_pinyin'])->first(['id']);
         }
         if (!isset($result) || empty($result)) {
             return Result::error("暂无该导航", 0);
@@ -1476,14 +1477,18 @@ class WebService implements WebServiceInterface
     public function getWebsiteFooterCategory(array $data): array
     {
         if (isset($data['website_id']) && !empty($data['website_id'])) {
-            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
-            if (empty($website)) {
-                return Result::error("找不到网站", 0);
-            }
+          $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
+          if (empty($website)) {
+              return Result::error("找不到网站", 0);
+          }
         } else {
-            return Result::error("参数错误", 0);
+          return Result::error("参数错误", 0);
         }
-        $result = FooterCategory::where('website_id', $data['website_id'])->get();
+        $result = WebsiteCategory::where('website_id', $data['website_id'])
+        ->where('type',8)
+        ->where('alias','!=','本网招聘')
+        ->where('pid',0)
+        ->get();
         if (empty($result)) {
             return Result::error("暂无底部导航", 0);
         }
@@ -1504,20 +1509,29 @@ class WebService implements WebServiceInterface
         } else {
             return Result::error("参数错误", 0);
         }
-        $footercategory = FooterCategory::where('website_id', $data['website_id'])->where('id', $data['fcat_id'])->first();
-        // '底部导航类型   0:内容型;1:列表型;',
-        if (!isset($footercategory['type']) || $footercategory['type'] == 0) {
-            return Result::error("底部导航id错误", 0);
-        } else {
-            $query = FooterContent::where('fcat_id', $data['fcat_id']);
-            if ($query->count() == 0) {
-                return Result::error("暂无底部导航列表", 0);
-            } elseif ($query->count() == 1) {
-                $result = $query->first();
-            } else {
-                $result = $query->get();
-            }
+        $footercategory = WebsiteCategory::where('website_id', $data['website_id'])
+        ->where('category_id', $data['fcat_id'])
+        ->first();
+        if(empty($footercategory)){
+          return Result::error('此网站不存在此单页导航!');
         }
+        $child_footercate = WebsiteCategory::where('website_category.website_id', $data['website_id'])
+        ->where('website_category.pid', $data['fcat_id'])
+        ->get()->all();
+        if(!empty($child_footercate)){
+          foreach($child_footercate as $key => $value){
+            $child_footercate[$key]['article'] = SinglePage::where('catid',$value['category_id'])
+            ->where('status',1)
+            ->where('website_id',$data['website_id'])
+            ->get()
+            ->all();
+          }
+        }
+        // '底部导航类型   0:内容型;1:列表型;',
+        $result = [
+          'foot_cate' => $footercategory,
+          'child_cate' => $child_footercate
+        ];
         return Result::success($result);
     }
     /**
@@ -1535,14 +1549,33 @@ class WebService implements WebServiceInterface
         } else {
             return Result::error("参数错误", 0);
         }
-        if (isset($data['type']) && $data['type'] == 0) {
-            $fcatid = FooterCategory::where('website_id', $data['website_id'])->where('id', $data['fcat_id'])->first();
+       
+        // 类似本网概况
+        if (!isset($data['type'])) {
+            // 本网招聘的内容
+            $foot_content = SinglePage::where('id', $data['fcat_id'])
+            ->where('website_id',$data['website_id'])
+            ->where('status',1)
+            ->first();
+            if(empty($foot_content)){
+              return Result::error('此单页内容不存在!');
+            }
+            $commend_ids = json_decode($foot_content['commend_id'] ?? '[]',true);
+            if(!empty($commend_ids)){
+              $commend_art = SinglePage::whereIn('id', $commend_ids)
+            ->where('website_id',$data['website_id'])
+            ->where('status',1)
+            ->get()->all();
+            }
+            $result = [
+              'content' => $foot_content,
+              'commend_art' => $commend_art
+            ];
+        }else{
+            $result = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['fcat_id'])->first();
             if (empty($fcatid)) {
-                return Result::error("底部导航id错误", 0);
+                return Result::error("单页id错误", 0);
             }
-            $result = FooterContent::where('fcat_id', $data['fcat_id'])->first();
-        } else {
-            $result = FooterContent::where('id', $data['fcat_id'])->first();
         }
         if (empty($result)) {
             return Result::error("暂无底部导航内容", 0);
@@ -1596,7 +1629,7 @@ class WebService implements WebServiceInterface
             return Result::error("暂无该网站", 0);
         }
         // 1:图片 2:文字 3:底部
-        $result['foot_cate'] = FooterCategory::where('website_id', $data['website_id'])->get()->all();
+        $result['foot_cate'] = WebsiteCategory::where('website_id', $data['website_id'])->where('type',8)->where('pid',0)->get()->all();
         $result['link_img'] = Link::where('website_id', $data['website_id'])->where('type', 1)->where('status', 1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all();
         $result['link_text'] = Link::where('website_id', $data['website_id'])->where('type', 2)->where('status', 1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
         $result['link_foot'] = Link::where('website_id', $data['website_id'])->where('type', 3)->where('status', 1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
@@ -1650,7 +1683,7 @@ class WebService implements WebServiceInterface
 
         // return Result::success($result);
         // 1:图片 2:文字 3:底部
-        $result['website_foot']['foot_cate'] = FooterCategory::where('website_id', $data['website_id'])->get()->all();
+        $result['website_foot']['foot_cate'] = WebsiteCategory::where('website_id', $data['website_id'])->where('type',8)->get()->all();
         $result['website_foot']['link_img'] = Link::where('website_id', $data['website_id'])->where('type', 1)->where('status', 1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all();
         $result['website_foot']['link_text'] = Link::where('website_id', $data['website_id'])->where('type', 2)->where('status', 1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
         $result['website_foot']['link_foot'] = Link::where('website_id', $data['website_id'])->where('type', 3)->where('status', 1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();

+ 27 - 0
app/Model/SinglePage.php

@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class SinglePage extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'single_page';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = ['ad_tag'];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}