| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services\Common;
- use App\Models\AdModel;
- use App\Models\ApiModel;
- use App\Models\ChatMessageModel;
- use App\Services\BaseService;
- use App\Services\RedisService;
- /**
- * 聊天管理-服务类
- * Class ChatMessageService
- * @package App\Services\Common
- */
- class ChatMessageService extends BaseService
- {
- // 静态对象
- protected static $instance = null;
- /**
- * 构造函数
- * ChatMessageService constructor.
- */
- public function __construct()
- {
- $this->model = new ChatMessageModel();
- }
- /**
- * 静态入口
- * @return static|null
- */
- public static function make()
- {
- if (!self::$instance) {
- self::$instance = (new static());
- }
- return self::$instance;
- }
- /**
- * 绑定用户
- * @param $fd
- * @param $data
- * @return bool
- */
- public function bind($fd, $data)
- {
- $userId = isset($data['from_uid'])? intval($data['from_uid']) : 0;
- if($userId<=0){
- $this->error = '1013';
- return false;
- }
- RedisService::set("caches:chats:bind:{$userId}", ['fd'=> $fd, 'user_id'=> $userId], 86400);
- return true;
- }
- /**
- * 添加或编辑
- * @return array
- */
- public function saveData($fd, $data)
- {
- return parent::edit($data); // TODO: Change the autogenerated stub
- }
- }
|