AI 2 сар өмнө
parent
commit
dbcacc9b1b

+ 37 - 4
app/Controller/NewsController.php

@@ -9,6 +9,7 @@ use Hyperf\HttpServer\Annotation\AutoController;
 use App\Tools\Result;
 use Hyperf\Validation\Contract\ValidatorFactoryInterface;
 use Hyperf\Context\Context;
+use App\JsonRpc\UserServiceInterface;
 /**
  * Class NewsController
  * @package App\Controller
@@ -25,6 +26,13 @@ class NewsController extends AbstractController
     #[Inject]
     private $newsServiceClient;
 
+     /**
+     * @var UserServiceInterface
+     */
+    #[Inject]
+    private $userServiceClient;
+
+
     /**
      * 导航池列表
      * @return void
@@ -47,8 +55,12 @@ class NewsController extends AbstractController
             $errorMessage = $validator->errors()->first();
             return Result::error($errorMessage);
         }
-
-
+         //获取用户信息
+         $user_id = Context::get("UserId");
+         $userInfo = $this->userServiceClient->getUserInfo((int)$user_id);
+         var_dump("用户信息:",$userInfo);
+         $sszq = $userInfo['data']['sszq'];
+         $type_id = $userInfo['data']['type_id']; //'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
         $result = $this->newsServiceClient->getCategoryList($requireData);
         if($result['data']){
             foreach ($result['data']['rows'] as $k=>$v) {
@@ -80,8 +92,19 @@ class NewsController extends AbstractController
         }
 
         $requireData['website_id'] = Context::get("SiteId");
-
-        $result = $this->newsServiceClient->categoryList($requireData);
+         //获取用户信息
+         $user_id = Context::get("UserId");
+         $userInfo = $this->userServiceClient->getUserInfo((int)$user_id);
+         var_dump("用户信息:",$userInfo);
+         $sszq = $userInfo['data']['sszq'];
+         $type_id = $userInfo['data']['type_id']; //'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
+         //管理员看所有
+         if($type_id == 10000){
+             $result = $this->newsServiceClient->categoryList($requireData);
+        } else {
+            $requireData['sszq'] = $sszq;
+            $result = $this->newsServiceClient->myCategoryList($requireData);
+        }
 //        $rep = PublicData::buildMenuTree($result['data']);
         return $result ? Result::success($result['data']) : Result::error($result['message']);
     }
@@ -218,6 +241,16 @@ class NewsController extends AbstractController
             return Result::error($errorMessage);
         }
         $requireData['website_id'] = Context::get("SiteId");
+        //获取用户信息
+        $user_id = Context::get("UserId");
+        $userInfo = $this->userServiceClient->getUserInfo((int)$user_id);
+        var_dump("用户信息:",$userInfo);
+        $sszq = $userInfo['data']['sszq'];
+        $type_id = $userInfo['data']['type_id']; //'1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)'
+        $requireData['type_id'] = $type_id;
+        $requireData['user_id'] = $user_id;
+
+
         var_dump("资讯:",$requireData);
         $result = $this->newsServiceClient->getArticleList($requireData);
         //1通过,2待审核,3待发 4,拒绝 5删除

+ 9 - 1
app/JsonRpc/NewsService.php

@@ -26,7 +26,15 @@ class NewsService extends AbstractServiceClient implements NewsServiceInterface
     {
         return $this->__request(__FUNCTION__, $data);
     }
-
+    
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function myCategoryList(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
     /**
      * @param array $data
      * @return array

+ 8 - 2
app/JsonRpc/NewsServiceInterface.php

@@ -1,6 +1,7 @@
 <?php
 
 namespace App\JsonRpc;
+
 interface NewsServiceInterface
 {
 
@@ -8,6 +9,11 @@ interface NewsServiceInterface
      * @param array $data
      */
     public function getCategoryList(array $data);
+
+    /**
+     * @param array $data
+     */
+    public function myCategoryList(array $data);
     /**
      * @param array $data
      */
@@ -30,7 +36,7 @@ interface NewsServiceInterface
 
     /**
      * @param array $data
-    */
+     */
     public function getArticleList(array $data);
 
     /**
@@ -71,4 +77,4 @@ interface NewsServiceInterface
      */
     public function upArticleStatus(array $data);
 
-}
+}

+ 5 - 2
config/api/news.php

@@ -1,6 +1,6 @@
 <?php
 
-declare(strict_types=1);
+declare (strict_types = 1);
 
 use App\Controller\NewsController;
 use Hyperf\HttpServer\Router\Router;
@@ -9,6 +9,9 @@ Router::addGroup(
     '/news', function () {
         //获取导航池列表
         Router::get('/getCategoryList', [NewsController::class, 'getCategoryList']);
+        //后台获取  我的导航池
+        Router::get('/myCategoryList', [NewsController::class, 'myCategoryList']);
+
         //导航池 筛选 搜索
         Router::get('/categoryList', [NewsController::class, 'categoryList']);
         //添加导航池
@@ -32,6 +35,6 @@ Router::addGroup(
         //获取导航池信息
         Router::get('/getCategoryInfo', [NewsController::class, 'getCategoryInfo']);
 
-},
+    },
     ['middleware' => [FooMiddleware::class]]
 );