使用workman

This commit is contained in:
2025-05-13 15:49:27 +08:00
parent c1547e191c
commit 2ff864b8c8
9 changed files with 446 additions and 13 deletions

View File

@@ -29,8 +29,11 @@ class AppUserCreateRequest extends IRequest
return $this->biz;
}
public function setBiz(array $biz): void
public function setBiz(array|string $biz): void
{
if (is_string($biz)) {
$biz = [$biz];
}
$this->biz = $biz;
}

View File

@@ -0,0 +1,34 @@
<?php
namespace cn\com\maiyoule\mqttclient\biz;
use cn\com\maiyoule\mqttclient\IRequest;
class AppUsersRequest extends IRequest
{
public function path(): string
{
return 'mqtt/users';
}
private string $role;
public function getRole(): string
{
return $this->role;
}
public function setRole(string $role): void
{
$this->role = $role;
}
public function body(): array
{
return [
'role' => $this->role,
];
}
}

View File

@@ -0,0 +1,91 @@
<?php
namespace cn\com\maiyoule\mqttclient\biz\client;
class SendMQTTMessage
{
/**
* @var string 业务标识符
*/
private string $biz;
/**
* @var string 目标客户端ID
*/
private string $targetId;
private string $message;
private int $qoS = 0;
private bool $retain = false;
private function __construct()
{
}
public static function create(string $biz, string $targetId, string $message, int $qos = 0, bool $retain = false): SendMQTTMessage
{
$instance = new self();
$instance->setBiz($biz);
$instance->setTargetId($targetId);
$instance->setMessage($message);
$instance->setQoS($qos);
$instance->setRetain($retain);
return $instance;
}
const QOS_0 = 0;
const QOS_1 = 1;
const QOS_2 = 2;
public function isRetain(): bool
{
return $this->retain;
}
public function setRetain(bool $retain): void
{
$this->retain = $retain;
}
public function getQoS(): int
{
return $this->qoS;
}
public function setQoS(int $qoS): void
{
$this->qoS = $qoS;
}
public function getMessage(): string
{
return $this->message;
}
public function setMessage(string $message): void
{
$this->message = $message;
}
public function getTargetId(): string
{
return $this->targetId;
}
public function setTargetId(string $targetId): void
{
$this->targetId = $targetId;
}
public function getBiz(): string
{
return $this->biz;
}
public function setBiz(string $biz): void
{
$this->biz = $biz;
}
}