소스 검색

修改获取广告位的接口

15313670163 1 개월 전
부모
커밋
7298b22d43
7개의 변경된 파일177개의 추가작업 그리고 13개의 파일을 삭제
  1. 16 5
      .env
  2. 114 7
      app/Controller/WebController.php
  3. 24 0
      app/JsonRpc/NewsService.php
  4. 15 0
      app/JsonRpc/NewsServiceInterface.php
  5. 1 0
      app/JsonRpc/WebsiteService.php
  6. 1 0
      app/JsonRpc/WebsiteServiceInterface.php
  7. 6 1
      config/api/web.php

+ 16 - 5
.env

@@ -17,15 +17,26 @@ DB_PREFIX=
 #REDIS_DB=0
 
 
-REDIS_HOST=192.168.1.201
+# REDIS_HOST=192.168.1.201
+# REDIS_AUTH=
+# REDIS_PORT=6379
+# REDIS_DB=0
+
+REDIS_HOST=192.168.1.123
 REDIS_AUTH=
-REDIS_PORT=6379
+REDIS_PORT=26739
+REDIS_PASSWORD=zxt_redis_dev
 REDIS_DB=0
 
-AMQP_HOST=103.105.201.2
-AMQP_PORT=5673
+AMQP_HOST=192.168.1.123
+AMQP_PORT=5672
 AMQP_USER=rabbitmq
-AMQP_PASSWORD=H8eDTAk6LY7EjJ8y
+AMQP_PASSWORD=zxt_mq_dev
+
+# AMQP_HOST=103.105.201.2
+# AMQP_PORT=5673
+# AMQP_USER=rabbitmq
+# AMQP_PASSWORD=H8eDTAk6LY7EjJ8y
 
 
 #小程序获取openid

+ 114 - 7
app/Controller/WebController.php

@@ -101,21 +101,21 @@ class WebController extends AbstractController
     {
         $requireData = $this->request->all();
         $data = ['website_id'=>Context::get("SiteId")]; 
-        if(isset($requireData['adPlace'])){
+        if($requireData['ad_tag']){
             $validator = $this->validationFactory->make(
                 $requireData,
                 [
-                    'adPlace' => 'required'
+                    'ad_tag' => 'required'
                 ],
                 [
-                    'adPlace.required' => '广告位置编号不能为空'
+                    'ad_tag.required' => '广告位置表示不能为空'
                 ]
             );
             if ($validator->fails()){
                 $errorMessage = $validator->errors()->first();
                 return Result::error($errorMessage);
             }
-            $data['place_id'] = $requireData['adPlace'];
+            $data['ad_tag'] = $requireData['ad_tag'];
         }
         
         
@@ -389,9 +389,7 @@ class WebController extends AbstractController
 
             ]
             );
-            if(is_string($requireData['catid'])){
-                $data['catid'] = json_decode ($requireData['catid'])??''; 
-            }
+            $data['catid'] = $requireData['catid'];
         }
             
         $validator = $this->validationFactory->make(
@@ -655,4 +653,113 @@ class WebController extends AbstractController
          }
 
     }
+    /**
+     * 获取网站调查问卷
+     */
+    public function getWebsiteSurvey()
+    {
+        $requireData = $this->request->all();
+        if(isset($requireData['art_id'])){
+            $validator = $this->validationFactory->make(
+                $requireData,
+                [
+                    'art_id' =>'required|integer'
+                ],
+                [
+                    'art_id.required' => 'id不能为空',
+                    'art_id.integer' => 'id必须为整数'
+                ]
+            ); 
+            if ($validator->fails()){
+                $errorMessage = $validator->errors()->first();
+                return Result::error($errorMessage);
+            }
+            $data['art_id'] = $requireData['art_id'];
+        }
+        $data['website_id'] =  Context::get("SiteId");
+        // return Result::success($data);
+        $result = $this->newsServiceClient->getWebsiteSurvey($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+
+    }
+    /*
+     * 添加网站调查问卷选项
+     * 
+     * */
+    public function addWebsiteSurveyOption()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'sur_id' =>'required',
+                'choice_name' =>'required|string|max:30',
+            ],
+            [
+                'sur_id.required' => '问卷id不能为空',
+                'choice_name.required' => '选项名称不能为空',
+                'choice_name.string' => '选项名称必须为字符串',
+                'choice_name.max' => '选项名称不能超过30个字符',
+            ]
+        );
+        if ($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        $data = [
+            'website_id' => Context::get("SiteId"),
+            'sur_id' => $requireData['sur_id'],
+            'choice_name' => $requireData['choice_name'],
+        ];
+        $result = $this->newsServiceClient->addWebsiteSurveyOption($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+    }
+    /*
+     * 调查问卷-投票
+     * 
+     * */
+    public function addWebsiteSurveyVote()
+    {
+        $requireData = $this->request->all();
+        $validator = $this->validationFactory->make(
+            $requireData,
+            [
+                'sur_id' =>'required',
+                'choice_id' =>'required',
+            ],
+            [
+                'sur_id.required' => '问卷id不能为空',
+                'choice_id.required' => '选项名称不能为空'
+            ]
+        );
+        if ($validator->fails()){
+            $errorMessage = $validator->errors()->first();
+            return Result::error($errorMessage);
+        }
+        if(is_array($requireData['choice_id'])){
+            // return Result::error('选项名称必须为数组');
+            // $$requireData['choice_id'] = json_encode($requireData['choice_id']); 
+            // return Result::success($requireData['choice_id']);
+        }
+        $data = [
+            'website_id' => Context::get("SiteId"),
+            'sur_id' => $requireData['sur_id'],
+            'choice_id' => $requireData['choice_id']
+        ];
+        // return Result::success($data);
+        $result = $this->newsServiceClient->addWebsiteSurveyVote($data);
+        if ($result['code']!= ErrorCode::SUCCESS) {
+            return Result::error($result['message'],0,[]);
+        }else{
+            return Result::success($result['data']);
+        }
+    }
 }

+ 24 - 0
app/JsonRpc/NewsService.php

@@ -159,4 +159,28 @@ class NewsService extends AbstractServiceClient implements NewsServiceInterface
     {
         return $this->__request(__FUNCTION__, $data);
     }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteSurvey(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function addWebsiteSurveyOption(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
+    /**
+     * @param array $data
+     * @return mixed
+     */
+    public function addWebsiteSurveyVote(array $data)
+    {
+        return $this->__request(__FUNCTION__, $data);
+    }
 }

+ 15 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -81,4 +81,19 @@ interface NewsServiceInterface
      * @return mixed
      */
     public function selectWebsiteArticleInfo(array $data);
+     /**
+     * @param array $data
+     * @return mixed
+     */
+    public function getWebsiteSurvey(array $data);
+      /**
+     * @param array $data
+     * @return mixed
+     */
+    public function addWebsiteSurveyOption(array $data);
+      /**
+     * @param array $data
+     * @return mixed
+     */
+    public function addWebsiteSurveyVote(array $data);
 }

+ 1 - 0
app/JsonRpc/WebsiteService.php

@@ -512,4 +512,5 @@ class WebsiteService extends AbstractServiceClient implements WebsiteServiceInte
     {
         return $this->__request(__FUNCTION__, $data);
     }
+    
 }

+ 1 - 0
app/JsonRpc/WebsiteServiceInterface.php

@@ -348,4 +348,5 @@ interface WebsiteServiceInterface
      * @return mixed
      */
     public function getOneWebsiteCategory(array $data);
+     
 }

+ 6 - 1
config/api/web.php

@@ -33,7 +33,12 @@ Router::addGroup(
                 Router::get('/getWebsiteCategoryHead', [WebController::class, 'getWebsiteCategoryHead']);
                 //获取某个栏目
                 Router::get('/getOneWebsiteCategory', [WebController::class, 'getOneWebsiteCategory']);
-                
+                //获取调查问卷
+                Router::get('/getWebsiteSurvey', [WebController::class, 'getWebsiteSurvey']);
+                // 添加调查问卷选项
+                Router::get('/addWebsiteSurveyOption', [WebController::class, 'addWebsiteSurveyOption']);
+                // 调查问卷-投票
+                Router::get('/addWebsiteSurveyVote', [WebController::class, 'addWebsiteSurveyVote']);
             },
     ['middleware' => [WebMiddleware::class]]
 );