使用workman
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
34
src/biz/AppUsersRequest.php
Normal file
34
src/biz/AppUsersRequest.php
Normal 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,
|
||||
];
|
||||
}
|
||||
}
|
91
src/biz/client/SendMQTTMessage.php
Normal file
91
src/biz/client/SendMQTTMessage.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user