82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Hyperf\Database\Model\Collection;
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $cert_id 主键id
|
||
* @property int $user_id 用户id(系统证书时为null)
|
||
* @property int $is_system 是否系统证书(0:否 1:是)
|
||
* @property int $type 证书类型(1:线下 2:线上)
|
||
* @property string $cert_base64 签名值证书
|
||
* @property string $cert_chain_p7 证书链
|
||
* @property string $cert_serial_number 证书序列号
|
||
* @property string $ca_pin ca认证pin值
|
||
* @property \Carbon\Carbon $created_at 创建时间
|
||
* @property \Carbon\Carbon $updated_at 修改时间
|
||
*/
|
||
class UserCaCert extends Model
|
||
{
|
||
use Snowflake;
|
||
|
||
/**
|
||
* The table associated with the model.
|
||
*/
|
||
protected ?string $table = 'user_ca_cert';
|
||
|
||
/**
|
||
* The attributes that are mass assignable.
|
||
*/
|
||
protected array $fillable = ['cert_id', 'user_id', 'is_system', 'type', 'cert_base64', 'cert_chain_p7', 'cert_serial_number', 'ca_pin', 'created_at', 'updated_at'];
|
||
|
||
protected string $primaryKey = "cert_id";
|
||
|
||
/**
|
||
* 获取是否存在
|
||
* @param array $params
|
||
* @return bool
|
||
*/
|
||
public static function getExists(array $params): bool
|
||
{
|
||
return self::where($params)->exists();
|
||
}
|
||
|
||
/**
|
||
* 获取信息-单条
|
||
* @param array $params
|
||
* @param array $fields
|
||
* @return object|null
|
||
*/
|
||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||
{
|
||
return self::where($params)->first($fields);
|
||
}
|
||
|
||
/**
|
||
* 获取数据-多
|
||
* @param array $params
|
||
* @param array $fields
|
||
* @return Collection|array
|
||
*/
|
||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||
{
|
||
return self::where($params)->get($fields);
|
||
}
|
||
|
||
/**
|
||
* 新增
|
||
* @param array $data
|
||
* @return \Hyperf\Database\Model\Model|UserCaCert
|
||
*/
|
||
public static function addDoctorPharmacistCert(array $data = []): \Hyperf\Database\Model\Model|UserCaCert
|
||
{
|
||
return self::create($data);
|
||
}
|
||
}
|