mirror of
https://devops.lemonos.cn/lawson/FendxPHP.git
synced 2026-06-15 23:12:49 +08:00
67 lines
1.3 KiB
PHP
67 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Entity;
|
||
|
|
|
||
|
|
use Fendx\Db\Annotation\Table;
|
||
|
|
use Fendx\Db\Annotation\Id;
|
||
|
|
use Fendx\Db\Annotation\Column;
|
||
|
|
use Fendx\Db\ORM\Model;
|
||
|
|
|
||
|
|
#[Table('users')]
|
||
|
|
class User extends Model
|
||
|
|
{
|
||
|
|
#[Id]
|
||
|
|
public int $id;
|
||
|
|
|
||
|
|
#[Column('username')]
|
||
|
|
public string $username;
|
||
|
|
|
||
|
|
#[Column('email')]
|
||
|
|
public string $email;
|
||
|
|
|
||
|
|
#[Column('password')]
|
||
|
|
public string $password;
|
||
|
|
|
||
|
|
#[Column('status', 'tinyint')]
|
||
|
|
public int $status = 1;
|
||
|
|
|
||
|
|
#[Column('created_at', 'datetime')]
|
||
|
|
public string $createdAt;
|
||
|
|
|
||
|
|
#[Column('updated_at', 'datetime')]
|
||
|
|
public string $updatedAt;
|
||
|
|
|
||
|
|
public function getCreatedAt(): string
|
||
|
|
{
|
||
|
|
return $this->createdAt;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setCreatedAt(string $createdAt): void
|
||
|
|
{
|
||
|
|
$this->createdAt = $createdAt;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getUpdatedAt(): string
|
||
|
|
{
|
||
|
|
return $this->updatedAt;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setUpdatedAt(string $updatedAt): void
|
||
|
|
{
|
||
|
|
$this->updatedAt = $updatedAt;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function isActive(): bool
|
||
|
|
{
|
||
|
|
return $this->status === 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function toArray(): array
|
||
|
|
{
|
||
|
|
$data = parent::toArray();
|
||
|
|
unset($data['password']); // 不返回密码
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
}
|