初始化项目:添加后端代码、ThinkPHP框架、前端资源

This commit is contained in:
amb
2026-09-03 12:42:39 +08:00
commit 482bece22e
3726 changed files with 416708 additions and 0 deletions
@@ -0,0 +1,73 @@
<?php
namespace app\common\library\live\message;
/**
* 直播消息值对象
* 描述一条待发送的消息,封装消息各字段,便于在业务层与服务商层之间传递
*/
class Message
{
/**
* @var string 群组ID(奥点云 topic / 阿里云 GroupId
*/
public $groupId;
/**
* @var string 发送者ID(阿里云必填)
*/
public $senderId;
/**
* @var string 发送者扩展信息
*/
public $senderMeta;
/**
* @var string 消息体(JSON 字符串)
*/
public $body;
/**
* @var int 消息类型
*/
public $msgType;
/**
* @var string 消息唯一标识(用于撤回)
*/
public $msgTid;
/**
* 构造函数
* @param array $data 初始化数据,支持键:group_id/sender_id/sender_meta/body/msg_type/msg_tid
*/
public function __construct(array $data = [])
{
$this->groupId = $data['group_id'] ?? '';
$this->senderId = $data['sender_id'] ?? '';
$this->senderMeta = $data['sender_meta'] ?? '';
$this->body = $data['body'] ?? '';
$this->msgType = isset($data['msg_type']) ? (int)$data['msg_type'] : 10001;
$this->msgTid = $data['msg_tid'] ?? '';
}
/**
* 消息业务类型到阿里云 MsgType 的映射
* text -> 10001
* image -> 10002
* gift -> 10003
* 其他 -> 10099
* @param string $type 业务消息类型
* @return int
*/
public static function mapMsgType($type)
{
$map = [
'text' => 10001,
'image' => 10002,
'gift' => 10003,
];
return isset($map[$type]) ? $map[$type] : 10099;
}
}