Przeglądaj źródła

Wesmiler OTC 提交更新 0729

APPLE 3 lat temu
rodzic
commit
c8c0456473

+ 2 - 3
app/Helpers/function.php

@@ -232,9 +232,8 @@ if(!function_exists('getChatKey')){
      * @return string
      */
     function getChatKey($fromUid, $toUid){
-        $arr = [$fromUid,$toUid];
-        arsort($arr);
-
+        $arr = array_values([$fromUid,$toUid]);
+        asort($arr);
         return implode('', $arr);
     }
 }

+ 72 - 0
app/Http/Controllers/Admin/ChatController.php

@@ -0,0 +1,72 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+
+use App\Services\ChatMessageService;
+
+/**
+ * 聊天管理-控制器
+ * Class ChatController
+ * @package App\Http\Controllers
+ */
+class ChatController extends Backend
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * ChatController constructor.
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->service = new ChatMessageService();
+    }
+
+    /**
+     * 获取聊天消息历史
+     * @return array
+     */
+    public function index()
+    {
+        $pageSize = request()->post('limit', 30);
+        $params = request()->all();
+        $list = $this->service->getDataList($params, $pageSize);
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => isset($list['list'])? $list['list']:[],
+            "count" => isset($list['total'])? $list['total']:0,
+        );
+        return $message;
+    }
+
+    /**
+     * 获取最新的聊天窗口列表
+     * @return array
+     */
+    public function newlist()
+    {
+        $pageSize = request()->post('limit', 30);
+        $params = request()->all();
+        $list = $this->service->getNewList($params, $pageSize);
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => isset($list['list'])? $list['list']:[],
+            "count" => isset($list['total'])? $list['total']:0,
+        );
+        return $message;
+    }
+
+}

+ 6 - 0
app/Http/Kernel.php

@@ -47,6 +47,11 @@ class Kernel extends HttpKernel
             \Illuminate\Routing\Middleware\SubstituteBindings::class,
             \Illuminate\Session\Middleware\StartSession::class,
         ],
+
+        'oapi' => [
+            \Illuminate\Routing\Middleware\SubstituteBindings::class,
+            \Illuminate\Session\Middleware\StartSession::class,
+        ],
     ];
 
     /**
@@ -68,5 +73,6 @@ class Kernel extends HttpKernel
         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
         'user.login' => \App\Http\Middleware\UserLogin::class,
         'web.login' => \App\Http\Middleware\WebLogin::class,
+        'api.login' => \App\Http\Middleware\ApiLogin::class,
     ];
 }

+ 8 - 2
app/Http/Validator/MemberValidator.php

@@ -7,12 +7,13 @@ class MemberValidator extends BaseValidator
         'id' => 'required',
         'username' => 'required|username|min:2|max:20',
         'new_username' => 'required|username|min:2|max:20',
-        'password' => 'required|max:30',
+        'password' => 'required|min:6|max:30',
         'code' => 'required',
+        'api_key' => 'required',
         'mobile'=> 'required|mobile',
         'email'=> 'required|email',
         'idcard'=> 'required|idcard',
-        'realname'=> 'required|max:20',
+        'realname'=> 'required|realname|max:20',
         'idcard_front_img'=> 'required|max:200',
         'idcard_back_img'=> 'required|max:200',
         'idcard_hand_img'=> 'required|max:200',
@@ -29,7 +30,9 @@ class MemberValidator extends BaseValidator
         'mobile' => ':attribute格式不正确',
         'email' => ':attribute格式不正确',
         'username' => ':attribute格式不正确',
+        'realname' => ':attribute格式不正确',
         'idcard' => ':attribute格式不正确',
+        'password' => ':attribute格式不正确',
     ];
 
     // 当前模型所有验证字段
@@ -46,6 +49,7 @@ class MemberValidator extends BaseValidator
         'idcard_front_img' => '身份证正面',
         'idcard_back_img' => '身份证反面',
         'idcard_hand_img' => '身份证手持',
+        'api_key' => '接口密钥参数',
     ];
 
     // 当前模型所有验证场景
@@ -57,6 +61,8 @@ class MemberValidator extends BaseValidator
         'tradePassword'=> ['username','trade_password','code'],
         'auth'=> ['realname','idcard','idcard_front_img','idcard_back_img'],
         'login'=> ['username','password'],
+        'apiLogin'=> ['username','password','api_key'],
+        'apiRegister'=> ['username','password','api_key'],
         'forget'=> ['username','code'],
         'save'=> ['username','realname','gender'],
         'mobile'=> ['mobile'],

+ 6 - 0
app/Providers/AppServiceProvider.php

@@ -61,5 +61,11 @@ class AppServiceProvider extends ServiceProvider
             $reg1='/^[0-9a-zA-Z]+@(([0-9a-zA-Z]+)[.])+[a-z]{2,4}$/i';
             return preg_match($reg,$value) || preg_match($reg1,$value);
         });
+
+        Validator::extend('realname', function ($attribute, $value, $parameters, $validator) {
+            // 返回true/false
+            $reg='/^[\u4e00-\u9fa5]{2,5}$/';
+            return preg_match($reg,$value);
+        });
     }
 }

+ 5 - 0
app/Providers/RouteServiceProvider.php

@@ -43,6 +43,11 @@ class RouteServiceProvider extends ServiceProvider
                 ->namespace($this->namespace)
                 ->group(base_path('routes/api.php'));
 
+            Route::prefix('oapi')
+                ->middleware('oapi','api.login')
+                ->namespace($this->namespace)
+                ->group(base_path('routes/oapi.php'));
+
             Route::middleware('web')
                 ->namespace($this->namespace)
                 ->group(base_path('routes/web.php'));