124 lines
2.4 KiB
PHP
124 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace cn\com\maiyoule\mqttclient\biz;
|
|
|
|
use cn\com\maiyoule\mqttclient\IRequest;
|
|
|
|
/**
|
|
* 用户修改请求
|
|
*/
|
|
class AppUserUpdateRequest extends IRequest
|
|
{
|
|
|
|
public function path(): string
|
|
{
|
|
return 'mqtt/user/update';
|
|
}
|
|
|
|
public function body(): array
|
|
{
|
|
$data = [
|
|
'username' => $this->getUsername(),
|
|
'state' => $this->isState() ? 0 : 1,
|
|
'role' => $this->getRole()
|
|
];
|
|
|
|
if (!is_null($this->password)) {
|
|
$data['password'] = $this->password;
|
|
}
|
|
if (!is_null($this->fettle)) {
|
|
$data['fettle'] = $this->fettle;
|
|
}
|
|
if (!empty($this->publish)) {
|
|
$data['publish'] = join(',', $this->getPublish());
|
|
}
|
|
if (!empty($this->subscribe)) {
|
|
$data['subscribe'] = join(',', $this->getSubscribe());
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
private array $subscribe = [];
|
|
|
|
public function getSubscribe(): array
|
|
{
|
|
return $this->subscribe;
|
|
}
|
|
|
|
public function setSubscribe(array|string $subscribe): void
|
|
{
|
|
if (is_string($subscribe)) {
|
|
$subscribe = [$subscribe];
|
|
}
|
|
$this->subscribe = $subscribe;
|
|
}
|
|
|
|
|
|
private array $publish = [];
|
|
|
|
public function getPublish(): array
|
|
{
|
|
return $this->publish;
|
|
}
|
|
|
|
private string $username;
|
|
private ?string $password = null;
|
|
private bool $state = true;
|
|
private ?string $fettle = null;
|
|
|
|
private string $role = '';
|
|
|
|
public function getRole(): string
|
|
{
|
|
return $this->role;
|
|
}
|
|
|
|
public function setRole(string $role): void
|
|
{
|
|
$this->role = $role;
|
|
}
|
|
|
|
|
|
public function getUsername(): string
|
|
{
|
|
return $this->username;
|
|
}
|
|
|
|
public function setUsername(string $username): void
|
|
{
|
|
$this->username = $username;
|
|
}
|
|
|
|
public function getPassword(): string
|
|
{
|
|
return $this->password;
|
|
}
|
|
|
|
public function setPassword(string $password): void
|
|
{
|
|
$this->password = $password;
|
|
}
|
|
|
|
public function isState(): bool
|
|
{
|
|
return $this->state;
|
|
}
|
|
|
|
public function setState(bool $state): void
|
|
{
|
|
$this->state = $state;
|
|
}
|
|
|
|
public function getFettle(): string
|
|
{
|
|
return $this->fettle;
|
|
}
|
|
|
|
public function setFettle(string $fettle): void
|
|
{
|
|
$this->fettle = $fettle;
|
|
}
|
|
|
|
|
|
} |