소스 검색

修改接口:网民留言-获取详情、网民留言-获取列表;新增接口:网民留言-检查是否可编辑

FengR 5 일 전
부모
커밋
044d1962ab
3개의 변경된 파일40개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      .env
  2. 34 1
      app/JsonRpc/NewsService.php
  3. 5 0
      app/JsonRpc/NewsServiceInterface.php

+ 1 - 1
.env

@@ -1,4 +1,4 @@
-APP_NAME=public_producer
+APP_NAME=zxt_admincenter
 APP_ENV=dev
 
 DB_DRIVER=mysql

+ 34 - 1
app/JsonRpc/NewsService.php

@@ -9049,10 +9049,14 @@ class NewsService implements NewsServiceInterface
    */
   public function getMessageInfo(array $data): array
   {
-    $result = Message::where('id', $data['id'])->first();
+    $result = Message::where('message.id', $data['id'])
+    ->leftJoin('website_column', 'message.column_id', '=', 'website_column.id')
+    ->select('message.*', 'website_column.column_arr_id')
+    ->first();
     if (empty($result)) {
       return Result::error('留言不存在!');
     }
+    $result['column_arr_id'] = json_decode($result['column_arr_id'] ?? [], true);
     return Result::success($result);
   }
   /**
@@ -9065,6 +9069,10 @@ class NewsService implements NewsServiceInterface
     $where = [];
     if($data['is_master'] == 1){
       $where['status'] = 1;
+    }else if($data['is_master'] == 2){
+      $where['status'] = 2;
+    }else if($data['is_master'] == 3){
+      $where['status'] = 0;
     }
     $user = User::where('id', $data['user_id'])->first();
     if (empty($user)) {
@@ -9093,4 +9101,29 @@ class NewsService implements NewsServiceInterface
     ];
     return Result::success($result);
   }
+  /**
+   * 网民留言-检查是否可编辑
+   * @param array $data
+   * @return array
+   */
+  public function checkMessageEdit(array $data): array
+  {
+    $message = Message::where('id', $data['id'])->first();
+    if (empty($message)) {
+      return Result::error('留言不存在!');
+    }
+    
+    $web = Website::where('id', $data['website_id'])->first();
+    if (empty($web)) {
+      return Result::error('网站不存在!');
+    }
+    $column_arr = json_decode($web['website_column_arr_id'] ?? [], true);
+    if(empty($column_arr)){
+      return Result::error('该网站未关联任何属性!');
+    }
+    if(!in_array($message['column_id'], $column_arr)){
+      return Result::error('不可编辑');
+    }
+    return Result::success('可编辑');
+  }
 }

+ 5 - 0
app/JsonRpc/NewsServiceInterface.php

@@ -399,4 +399,9 @@ interface NewsServiceInterface
      * @return array
      */
     public function getMessageList(array $data):array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function checkMessageEdit(array $data):array;
 }