hospital-applets-api/app/Model/UserCaCert.php
2023-04-20 13:16:52 +08:00

95 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 int $is_sign_config 是否已添加签章配置(第一次需申请)
* @property string $sign_config 签章坐标配置
* @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', 'is_sign_config', 'sign_config', '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 UserCaCert|\Hyperf\Database\Model\Model
*/
public static function addUserCaCert(array $data): UserCaCert|\Hyperf\Database\Model\Model
{
return self::create($data);
}
/**
* 修改
* @param array $params
* @param array $data
* @return int
*/
public static function edit(array $params = [], array $data = []): int
{
return self::where($params)->update($data);
}
}