Prechádzať zdrojové kódy

合并获取三农资讯网站相关的接口

15313670163 2 mesiacov pred
rodič
commit
d3cd7c9198

+ 177 - 38
app/Controller/WebController.php

@@ -6,13 +6,12 @@ use App\JsonRpc\NewsServiceInterface;
 use App\JsonRpc\WebsiteServiceInterface;
 use App\Tools\PublicData;
 use Hyperf\Di\Annotation\Inject;
+use Hyperf\HttpServer\Annotation\AutoController;
 use App\Tools\Result;
 use Hyperf\Validation\Contract\ValidatorFactoryInterface;
 use App\Constants\ErrorCode;
-use App\Controller\PublicController;
 use Hyperf\Context\Context;
-use Hyperf\HttpServer\Contract\RequestInterface;
-use Hyperf\HttpServer\Contract\ResponseInterface;
+
 /**
  * Class WebController
  * @package App\Controller
@@ -22,7 +21,7 @@ class WebController extends AbstractController
 
     #[Inject]
     protected ValidatorFactoryInterface $validationFactory;
-    private $publicServiceClient;
+
     /**
      * @var NewsServiceInterface
      */
@@ -37,7 +36,6 @@ class WebController extends AbstractController
 
 
     private $PublicController;
-
     public function __construct(PublicController $PublicController)
     {
         $this->PublicController = $PublicController;
@@ -66,10 +64,9 @@ class WebController extends AbstractController
         }
 
         $data = [
-            'website_id'=>Context::get("SiteId"),
-            'pageSize'=>$requireData['pageSize']
+            'website_id'=>Context::get("SiteId")
         ];
-        // var_dump("网站id:",Context::get("SiteId"));
+        var_dump("网站id:",Context::get("SiteId"));
         $result = $this->websiteServiceClient->getWebsiteCategory($data);
         if ($result['code'] != ErrorCode::SUCCESS) {
             return Result::error($result['message'],0,[]);
@@ -153,7 +150,6 @@ class WebController extends AbstractController
         return Result::success($result['data']);
     }
 
-
     /**
      *各省市查询 
      */
@@ -375,7 +371,7 @@ class WebController extends AbstractController
     /**
      * 获取文章列表
      */
-    public function getWebsiteArticlesList()
+    public function getWebsiteArticleList()
     {
        
         $requireData = $this->request->all();
@@ -391,34 +387,8 @@ class WebController extends AbstractController
             ]
             );
             $data['catid'] =  $requireData['catid']; 
-        }elseif(isset($requireData['keyword'])){
-            $validator = $this->validationFactory->make(
-                $requireData,
-                [
-                    'keyword' => 'required'
-                ],
-                [
-                    'keyword.required' => '搜索词不能为空'
-    
-                ]
-            );
-            $data['keyword'] =  $requireData['keyword']; 
-        }else{
-            $validator = $this->validationFactory->make(
-                $requireData,
-                [
-                    'catid' => 'required',
-                    'keyword' => 'required'
-                ],
-                [
-                    'catid.required' => '栏目id不能为空',
-                    'keyword.required' => '搜索词不能为空'
-    
-                ]
-            );
-            $data['catid'] =  $requireData['catid']; 
-            $data['keyword'] =  $requireData['keyword']; 
         }
+            
         $validator = $this->validationFactory->make(
                 $requireData,
                 [
@@ -435,10 +405,14 @@ class WebController extends AbstractController
                 $errorMessage = $validator->errors()->first();
                 return Result::error($errorMessage);
             }
+            // $data['catid'] =  $requireData['catid']; 
+            if(isset($requireData['keyword']) && !empty($requireData['keyword'])){
+                $data['keyword'] =  $requireData['keyword'];
+            }
             $data['website_id'] = Context::get("SiteId");
             $data['pageSize'] = $requireData['pageSize']; 
             $data['page'] = $requireData['page']; 
-        $result = $this->newsServiceClient->getArticleList($data);
+        $result = $this->newsServiceClient->getWebsiteArticleList($data);
         // var_dump($result);
         if ($result['code'] != ErrorCode::SUCCESS) {
             return Result::error($result['message'],0,[]);
@@ -480,4 +454,169 @@ class WebController extends AbstractController
         return Result::success($result['data']);
         
     }
+    /**
+     * 获取网站底部信息
+     * @return array
+     */
+    public function getWebsiteFootInfo()
+    {
+        $data = [
+            'website_id'=>Context::get("SiteId")
+        ];
+        $result = $this->websiteServiceClient->getWebsiteFootInfo($data);
+        if ($result['code'] != ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }
+        return Result::success($result['data']);
+    }
+    /**
+     * 获取网站底部导航
+     * @return array
+    */
+    public function getWebsiteFooterCategory()
+    {
+        $data = [
+            'website_id'=>Context::get("SiteId")
+        ];
+        $result = $this->websiteServiceClient->getWebsiteFooterCategory($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]); 
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+    /**
+     * 获取网站底部导航列表
+     * @return array
+    */
+    public function getWebsiteFooterCategoryList()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'fcat_id' =>'required|integer'
+            ],
+            [
+                'fcat_id.required' => '底部导航栏目id不能为空',
+                'fcat_id.integer' => '底部导航栏目id必须为整数'
+            ]
+        );
+        if ($validator->fails()){
+            $errorMessage = $validator->errors()->first(); 
+            return Result::error($errorMessage);
+        }
+        $data = [
+            'fcat_id'=>$requireData['fcat_id'],
+            'website_id'=>Context::get("SiteId")
+        ];
+        $result = $this->websiteServiceClient->getWebsiteFooterCategoryList($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]); 
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+    /**
+     * 获取网站底部导航内容
+     * @return array
+    */
+    public function getWebsiteFooterCategoryInfo()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'fcat_id' =>'required|integer',
+                'type' => 'nullable|in:0'
+            ],
+            [
+                'fcat_id.required' => 'id不能为空',
+                'fcat_id.integer' => 'id必须为整数',
+                'type.in' => '类型必须为0'
+            ]
+        );
+        if ($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage); 
+        }
+        $data = [
+            'fcat_id'=>$requireData['fcat_id'],
+            'website_id'=>Context::get("SiteId")
+        ];
+        if(isset($requireData['type'])){
+            $data['type'] = $requireData['type'];
+        }
+        $result = $this->websiteServiceClient->getWebsiteFooterCategoryInfo($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]); 
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+    /**
+     * 搜索二级导航
+     * @return array
+     */
+    public function selectWebsiteCategory()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'pid' =>'required|integer',
+                'cityid' => 'nullable|numeric',
+                'department_id' => 'nullable|numeric',
+            ], 
+            [
+                'pid.required' => 'id不能为空',
+                'pid.integer' => 'id必须为整数',
+                'cityid.numeric' => '城市id必须为数字',
+                'department_id.numeric' => '部门id必须为数字' 
+            ]
+        ) ;
+        if ($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        $data = $requireData;
+        $data['website_id'] = Context::get("SiteId");
+        $result = $this->websiteServiceClient->selectWebsiteCategory($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]); 
+        }else{
+            return Result::success($result['data']);
+        }
+
+    }
+    /**
+     * 搜索二级导航
+     * @return array
+     */
+    public function getWebsiteCategoryHead()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'catid' =>'required|integer'
+            ], 
+            [
+                'catid.required' => 'id不能为空'
+            ]
+        ) ;
+        if ($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        $data = $requireData;
+        $data['website_id'] = Context::get("SiteId");
+        $result = $this->websiteServiceClient->getWebsiteCategoryHead($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]); 
+        }else{
+            return Result::success($result['data']);
+         }
+
+    }
 }

+ 8 - 0
app/JsonRpc/NewsService.php

@@ -143,5 +143,13 @@ class NewsService extends AbstractServiceClient implements NewsServiceInterface
         return $this->__request(__FUNCTION__, $data);
     }
     
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteArticleList(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
 
 }

+ 6 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -71,4 +71,10 @@ interface NewsServiceInterface
      */
     public function upArticleStatus(array $data);
 
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteArticleList(array $data);
+
 }

+ 59 - 4
app/JsonRpc/WebsiteService.php

@@ -209,10 +209,12 @@ class WebsiteService extends AbstractServiceClient implements WebsiteServiceInte
     {
         return $this->__request(__FUNCTION__, $data);
     }
+
     /**
      * @param array $data
      * @return array|mixed
      */
+
     public function getWebsiteAdvertisement(array $data)
     {
         return $this->__request(__FUNCTION__, $data);
@@ -222,22 +224,27 @@ class WebsiteService extends AbstractServiceClient implements WebsiteServiceInte
      * @param array $data
      * @return array|mixed
      */
+
     public function selectWebsiteDepartment(array $data)
     {
         return $this->__request(__FUNCTION__, $data);
     }
+
     /**
      * @param array $data
      * @return mixed
      */
+
     public function selectWebsiteArea(array $data)
     {
         return $this->__request(__FUNCTION__, $data);
     }
+
     /**
      * @param array $data
      * @return mixed
      */
+
     public function getWebsiteModelCategory(array $data)
     {
         return $this->__request(__FUNCTION__, $data);
@@ -247,6 +254,7 @@ class WebsiteService extends AbstractServiceClient implements WebsiteServiceInte
      * @param array $data
      * @return mixed
      */
+
     public function selectWebsiteLinks(array $data)
     {
         return $this->__request(__FUNCTION__, $data);
@@ -255,10 +263,6 @@ class WebsiteService extends AbstractServiceClient implements WebsiteServiceInte
 
 
 
-
-
-
-
     /**
      * @param array $data
      * @return array|mixed
@@ -489,4 +493,55 @@ class WebsiteService extends AbstractServiceClient implements WebsiteServiceInte
         return $this->__request(__FUNCTION__, $data);
     }
     
+
+
+    
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteFootInfo(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteFooterCategory(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteFooterCategoryList(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteFooterCategoryInfo(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function selectWebsiteCategory(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteCategoryHead(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
 }

+ 43 - 6
app/JsonRpc/WebsiteServiceInterface.php

@@ -118,28 +118,30 @@ interface WebsiteServiceInterface
      */
     public function delWebsiteRoleUser(int $id);
 
+
     /**
      * @param array $data
      * @return mixed
      */
+
     public function getWebsiteId(array $data);
 
+
     /**
      * @param array $data
      * @return mixed
      *
      */
+
     public function getWebsiteCategory(array $data);
      
 
-
-
-
     /**
      * @param array $data
      * @return mixed
      *
      */
+
     public function getWebsiteAdvertisement(array $data);
 
     /**
@@ -147,18 +149,23 @@ interface WebsiteServiceInterface
      * @return mixed
      *
      */
+
     public function selectWebsiteDepartment(array $data);
+
     /**
      * @param array $data
      * @return mixed
      *
      */
+
     public function selectWebsiteArea(array $data);
+
     /**
      * @param array $data
      * @return mixed
      *
      */
+
     public function getWebsiteModelCategory(array $data);
 
     /**
@@ -166,10 +173,8 @@ interface WebsiteServiceInterface
      * @return mixed
      *
      */
-    public function selectWebsiteLinks(array $data);
-
-
 
+    public function selectWebsiteLinks(array $data);
 
 
 
@@ -337,4 +342,36 @@ interface WebsiteServiceInterface
     public function addWebsiteTemplateclassintel(array $data);
     
 
+
+
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteFootInfo(array $data);
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteFooterCategory(array $data);
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteFooterCategoryList(array $data);
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteFooterCategoryInfo(array $data);
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function selectWebsiteCategory(array $data);
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteCategoryHead(array $data);
 }

+ 2 - 0
config/api/news.php

@@ -31,6 +31,8 @@ Router::addGroup(
         Router::get('/getArticleInfo', [NewsController::class, 'getArticleInfo']);
         //获取导航池信息
         Router::get('/getCategoryInfo', [NewsController::class, 'getCategoryInfo']);
+         //前端-获取资讯列表
+         Router::get('/getWebsiteArticleList', [NewsController::class, 'getWebsiteArticleList']);
 
 },
     ['middleware' => [FooMiddleware::class]]

+ 13 - 1
config/api/web.php

@@ -15,10 +15,22 @@ Router::addGroup(
                 Router::get('/getWebsiteArticlett', [WebController::class, 'getWebsiteArticlett']);
                 Router::get('/getWebsiteModelArticles', [WebController::class, 'getWebsiteModelArticles']);
                 Router::get('/getWebsiteModelCategory', [WebController::class, 'getWebsiteModelCategory']);
-                Router::get('/getWebsiteArticlesList', [WebController::class, 'getWebsiteArticlesList']);
+                Router::get('/getWebsiteArticleList', [WebController::class, 'getWebsiteArticleList']);
                 Router::get('/selectWebsiteArticleInfo', [WebController::class, 'selectWebsiteArticleInfo']);
 
                 Router::get('/selectWebsiteLinks', [WebController::class, 'selectWebsiteLinks']);
+                // 获取网站底部基础信息
+                Router::get('/getWebsiteFootInfo', [WebController::class, 'getWebsiteFootInfo']);
+                // 获取网站底部导航
+                Router::get('/getWebsiteFooterCategory', [WebController::class, 'getWebsiteFooterCategory']);
+                // 获取网站底部导航列表
+                Router::get('/getWebsiteFooterCategoryList', [WebController::class, 'getWebsiteFooterCategoryList']);
+                // 获取网站底部导航内容
+                Router::get('/getWebsiteFooterCategoryInfo', [WebController::class, 'getWebsiteFooterCategoryInfo']);
+                // 搜索网站二级导航
+                Router::get('/selectWebsiteCategory', [WebController::class, 'selectWebsiteCategory']);
+                // 搜索网站二级导航-seo列表页
+                Router::get('/getWebsiteCategoryHead', [WebController::class, 'getWebsiteCategoryHead']);
             },
     ['middleware' => [WebMiddleware::class]]
 );