15313670163 hace 4 meses
padre
commit
4eeea218cd

+ 409 - 0
app/Controller/FooterController.php

@@ -0,0 +1,409 @@
+<?php
+
+declare(strict_types=1);
+namespace App\Controller;
+
+use App\JsonRpc\FooterServiceInterface;
+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;
+/**
+ * Class FooterController
+ * @package App\Controller
+ */
+
+class FooterController extends AbstractController
+{
+    #[Inject]
+    protected ValidatorFactoryInterface $validationFactory;
+
+    /**
+     * @var FooterServiceInterface
+    */
+
+    #[Inject]
+    private $footerServiceClient;
+     /**
+     * 获取底部导航
+     * @return array
+     */
+    public function getFooterCategory()
+    {
+        $requireData = $this->request->all();
+        if(isset($requireData['website_name'])){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'website_name' =>'required'
+                ],
+                [
+                    'website_name.required' => '网站名称不能为空'
+                ]
+            );
+            if ($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+            $data['website_name'] = $requireData['website_name'];
+        }
+        if(isset($requireData['name'])){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'name' =>'required'
+                ],
+                [
+                    'name.required' => '底部导航名称不能为空'
+                ]
+            );
+            if ($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+            $data['name'] = $requireData['name'];
+        }
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'page' =>'required',
+                'pageSize' =>'required'
+            ],
+            [
+                'page.required' => '第几页不能为空',
+                'pageSize.required' => '每页显示数量不能为空'
+            ]
+        );
+        if ($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        $data['page'] = $requireData['page'];
+        $data['pageSize'] = $requireData['pageSize'];
+        // var_dump($data);
+        $result = $this->footerServiceClient->getFooterCategory($data);
+        if ($result['code'] != ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+        
+    }
+    /**
+     * 添加底部导航
+     * @return array
+     */
+    public function addFooterCategory()
+    {
+        $requireData = $this->request->all();
+        if(!empty($requireData)){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'website_id' =>'required',
+                    'name' =>'required',
+                    'type' =>'required'
+                ],
+                [
+                    'website_id.required' => '网站id不能为空',
+                    'name.required' => '底部导航名称不能为空',
+                    'type.required' => '底部导航类型不能为空'
+                ]
+            );
+            if ($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+            $data = $requireData;
+        }else{
+           $data = []; 
+        }
+        $result = $this->footerServiceClient->addFooterCategory($data);
+        if ($result['code'] != ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+    /**
+     * 修改底部导航
+     * @return array
+     */
+    public function upFooterCategory()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'id' =>'required'
+            ],
+            [
+                'id.required' => '底部导航id不能为空'
+            ]
+        );
+        if ($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        if(isset($requireData['name'])){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'name' =>'required' 
+                ],
+                [
+                    'name.required' => '底部导航名称不能为空'
+                ]
+            );
+            if ($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+            $data['name'] = $requireData['name'];
+        }
+        if(isset($requireData['website_id'])){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'website_id' =>'required'
+                ],
+                [
+                    'website_id.required' => '网站id不能为空'
+                ]
+            );
+            if ($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+             $data['website_id'] = $requireData['website_id'];
+        }
+       
+        $data['id'] = $requireData['id'];
+        // var_dump($data);
+        $result = $this->footerServiceClient->upFooterCategory($data);
+        if ($result['code'] != ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }        
+    }    
+     /**
+     * 删除底部导航
+     * @return array
+     */
+    public function delFooterCategory()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'id' =>'required'
+            ],
+            [
+                'id.required' => '底部导航id不能为空'
+            ]
+        );
+        $data['id'] = $requireData['id'];
+        if($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        $result = $this->footerServiceClient->delFooterCategory($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+     /**
+     * 添加底部导航(列表)内容
+     * @return array
+     */
+    public function addFooterContent()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'type' =>'required',
+                'fcat_id' =>'required',
+                'con_title' =>'required',
+                'content' =>'required'
+            ],
+            [
+                'type.required' => '底部导航类型不能为空',
+                'fcat_id.required' => '底部导航id不能为空',
+                'con_title.required' => '内容标题不能为空',
+                'content.required' => '内容不能为空'
+            ]
+        );
+        
+        if($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        $data['type'] = $requireData['type'];
+        $data['fcat_id'] = $requireData['fcat_id'];
+        $data['con_title'] = $requireData['con_title'];
+        $data['content'] = $requireData['content'];
+        if($data['type'] == 1){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'list_title' =>'required'
+                ],
+                [
+                    'list_title.required' => '列表标题不能为空'
+                ]
+            );
+            if ($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+            $data['list_title'] = $requireData['list_title'];
+        }
+        // var_dump($data);
+        $result = $this->footerServiceClient->addFooterContent($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+     /**
+     * 获取并搜索底部导航(列表)内容
+     * @return array
+     */
+    public function getFooterContent()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'fcat_id' =>'required',
+                'page' =>'required',
+                'pageSize' =>'required'
+            ],
+            [
+                'fcat_id.required' => '底部导航类型不能为空',
+                'page.required' => '第几页不能为空',
+                'pageSize.required' => '每页显示数量不能为空'
+            ]
+        );
+        if($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        if(isset($requireData['con_title'])){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'con_title' =>'required'
+                ],
+                [
+                    'con_title.required' => '内容标题不能为空'
+                ]
+            );
+            if($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+            $data['con_title'] = $requireData['con_title'];
+        }
+        
+        $data['fcat_id'] = $requireData['fcat_id'];
+        $data['page'] = $requireData['page'];
+        $data['pageSize'] = $requireData['pageSize'];
+        $result = $this->footerServiceClient->getFooterContent($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+     /**
+     * 修改底部导航(列表)内容
+     * @return array
+     */
+    public function upFooterContent()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'id' =>'required',
+                'type' =>'required',
+                'con_title' =>'required',
+                'content' =>'required'
+            ],
+            [
+                'id.required' => '底部导航内容id不能为空',
+                'type.required' => '底部导航类型不能为空',
+                'con_title.required' => '内容标题不能为空',
+                'content.required' => '内容不能为空'
+            ]
+        );
+        if($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        $data['id'] = $requireData['id'];
+        $data['type'] = $requireData['type'];
+        $data['con_title'] = $requireData['con_title'];
+        $data['content'] = $requireData['content'];
+        if($data['type'] == 1){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'list_title' =>'required'
+                ],
+                [
+                    'list_title.required' => '列表标题不能为空'
+                ]
+            );
+            if ($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+            $data['list_title'] = $requireData['list_title'];
+        }
+        // var_dump($data);
+        $result = $this->footerServiceClient->upFooterContent($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+     /**
+     * 删除底部导航(列表)内容
+     * @return array
+     */
+    public function delFooterContent()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'id' =>'required'
+            ],
+            [
+                'id.required' => '底部导航id不能为空'
+            ]
+        );
+        if($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        $data['id'] = $requireData['id'];
+        // var_dump($data);
+        $result = $this->footerServiceClient->delFooterContent($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+}

+ 85 - 0
app/JsonRpc/FooterService.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\JsonRpc;
+
+use Hyperf\RpcClient\AbstractServiceClient;
+
+class FooterService extends AbstractServiceClient implements FooterServiceInterface
+{
+    /**
+     * 定义对应服务提供者的服务名称
+     * @var string
+     */
+    protected string $serviceName = 'FooterService';
+    /**
+     * 定义对应服务提供者的服务协议
+     * @var string
+     */
+    protected string $protocol = 'jsonrpc-http';
+
+
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getFooterCategory(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function addFooterCategory(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function upFooterCategory(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function delFooterCategory(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getFooterContent(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function addFooterContent(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function upFooterContent(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function delFooterContent(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+}

+ 39 - 0
app/JsonRpc/FooterServiceInterface.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace App\JsonRpc;
+interface FooterServiceInterface
+{
+
+    /**
+     * @param array $data
+     */
+    public function getFooterCategory(array $data);
+     /**
+     * @param array $data
+     */
+    public function addFooterCategory(array $data);
+     /**
+     * @param array $data
+     */
+    public function upFooterCategory(array $data);
+     /**
+     * @param array $data
+     */
+    public function delFooterCategory(array $data);
+     /**
+     * @param array $data
+     */
+    public function getFooterContent(array $data);
+     /**
+     * @param array $data
+     */
+    public function addFooterContent(array $data);
+     /**
+     * @param array $data
+     */
+    public function upFooterContent(array $data);
+     /**
+     * @param array $data
+     */
+    public function delFooterContent(array $data);
+}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 171 - 172
composer.lock


+ 30 - 0
config/api/footer.php

@@ -0,0 +1,30 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Controller\FooterController;
+use Hyperf\HttpServer\Router\Router;
+use App\Middleware\Auth\FooMiddleware;
+Router::addGroup(
+    '/footer', function () {
+        /**获取并搜索底部导航 */
+        Router::post('/getFooterCategory', [FooterController::class, 'getFooterCategory']);
+        /**创建底部导航 */
+        Router::post('/addFooterCategory', [FooterController::class, 'addFooterCategory']);
+        /**修改底部导航 */
+        Router::post('/upFooterCategory', [FooterController::class, 'upFooterCategory']);
+         /**删除底部导航 */
+        Router::post('/delFooterCategory', [FooterController::class, 'delFooterCategory']);
+        
+
+        /**获取并搜索底部导航(列表)内容 */
+        Router::post('/getFooterContent', [FooterController::class, 'getFooterContent']);
+        /**添加底部导航(列表)内容 */
+        Router::post('/addFooterContent', [FooterController::class, 'addFooterContent']);
+        /**修改底部导航(列表)内容 */
+        Router::post('/upFooterContent', [FooterController::class, 'upFooterContent']);
+        /**删除底部导航(列表)内容 */
+        Router::post('/delFooterContent', [FooterController::class, 'delFooterContent']);
+    },
+    ['middleware' => [FooMiddleware::class]]
+);

+ 11 - 2
config/autoload/services.php

@@ -66,7 +66,7 @@ return [
             ],
         ],
         [
-            //友情链接服务
+            //商圈服务
             'name' => 'ChatService',
             'service' => \App\JsonRpc\ChatServiceInterface::class,
             // 直接对指定的节点进行消费,通过下面的 nodes 参数来配置服务提供者的节点信息
@@ -84,7 +84,7 @@ return [
             ],
         ],
         [
-            //广告订单服务
+            //采集器服务
             'name' => 'CollectorService',
             'service' => \App\JsonRpc\CollectorServiceInterface::class,
 
@@ -93,5 +93,14 @@ return [
                 ['host' => '127.0.0.1', 'port' => 9509],
             ],
         ],
+        [
+            //底部导航服务
+            'name' => 'FooterService',
+            'service' => \App\JsonRpc\FooterServiceInterface::class,
+            // 直接对指定的节点进行消费,通过下面的 nodes 参数来配置服务提供者的节点信息
+            'nodes' => [
+                ['host' => '127.0.0.1', 'port' => 9502],
+            ],
+        ],
     ],
 ];

+ 1 - 0
config/routes.php

@@ -36,4 +36,5 @@ require __DIR__ . '/api/website.php';
 require __DIR__ . '/api/web.php';
 require __DIR__ . '/api/order.php';
 require __DIR__ . '/api/collector.php';
+require __DIR__ . '/api/footer.php';
 

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio