LiuJ 4 ماه پیش
والد
کامیت
b475589bb2
2فایلهای تغییر یافته به همراه43 افزوده شده و 13 حذف شده
  1. 13 13
      app/JsonRpc/ChatService.php
  2. 30 0
      config/autoload/databases.php

+ 13 - 13
app/JsonRpc/ChatService.php

@@ -956,7 +956,7 @@ class ChatService implements ChatServiceInterface
         $result = ChatTopic::where(['chat_topics.id' => $data['id']])
             ->leftJoin('user', 'user.id', '=', 'chat_topics.user_id')
             ->leftJoin('chat_topic_class', 'chat_topic_class.id', '=', 'chat_topics.type')
-            ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name','chat_topic_class.topicname')
+            ->select('chat_topics.*', 'user.nickname', 'user.avatar', 'user.user_name', 'chat_topic_class.topicname')
             ->first();
         return Result::success($result);
     }
@@ -1179,13 +1179,13 @@ class ChatService implements ChatServiceInterface
             ->leftJoin('chat_topic_class', 'chat_topic_class.id', '=', 'chat_topics.type')
             ->where(['chat_groups_members.user_id' => $data['user_id']])
             ->when($data, function ($query) use ($data) {
-                if(!empty($data['type'])){
+                if (!empty($data['type'])) {
                     $query->where(['chat_topics.type' => $data['type']]);
                 }
-                if(!empty($data['title'])){
-                    $query->where('chat_topics.title','like','%'.$data['title'].'%');
+                if (!empty($data['title'])) {
+                    $query->where('chat_topics.title', 'like', '%' . $data['title'] . '%');
                 }
-                if(!empty($data['created_at'])){
+                if (!empty($data['created_at'])) {
                     $query->whereDate('chat_topics.created_at', $data['created_at']);
                 }
             })
@@ -1198,14 +1198,14 @@ class ChatService implements ChatServiceInterface
                 'chat_topic_class.topicname',
             )
             ->orderBy('chat_topics.created_at', 'desc');
-            $total = $query->count();
-            $list = $query->forPage($data['page'], $data['page_size'])->get();
-            $result = [
-                'list' => $list,
-                'total' => $total,
-                'page' => intval($data['page']),
-                'page_size' => intval($data['page_size']),
-            ];
+        $total = $query->count();
+        $list = $query->forPage($data['page'], $data['page_size'])->get();
+        $result = [
+            'list' => $list,
+            'total' => $total,
+            'page' => intval($data['page']),
+            'page_size' => intval($data['page_size']),
+        ];
         return  Result::success($result);
     }
 }

+ 30 - 0
config/autoload/databases.php

@@ -9,6 +9,7 @@ declare(strict_types=1);
  * @contact  group@hyperf.io
  * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
  */
+
 use function Hyperf\Support\env;
 
 return [
@@ -41,4 +42,33 @@ return [
             ],
         ],
     ],
+    'imp' => [
+        'driver' => env('DB_DRIVER', 'mysql'),
+        'host' => env('DB_HOST', 'localhost'),
+        'database' => 'imp',
+        'port' => env('DB_PORT', 3306),
+        'username' => env('DB_USERNAME', 'root'),
+        'password' => env('DB_PASSWORD', ''),
+        'charset' => env('DB_CHARSET', 'utf8'),
+        'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
+        'prefix' => env('DB_PREFIX', ''),
+        'pool' => [
+            'min_connections' => 1,
+            'max_connections' => 10,
+            'connect_timeout' => 10.0,
+            'wait_timeout' => 3.0,
+            'heartbeat' => -1,
+            'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
+        ],
+        'variables' => [
+            'time_zone' => 'Asia/Shanghai', // 设置MySQL连接的时区
+        ],
+        'commands' => [
+            'gen:model' => [
+                'path' => 'app/Model',
+                'force_casts' => true,
+                'inheritance' => 'Model',
+            ],
+        ],
+    ],
 ];