This commit is contained in:
2023-03-27 13:31:49 +08:00
parent 426988d8d3
commit d2825476d5
5 changed files with 210 additions and 6 deletions
+25 -1
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;
@@ -15,6 +16,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
* @property int $notice_type 消息类型(1:医生服务通知 2:医生系统公告 3:患者系统消息)
* @property int $notice_system_type 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息)
* @property int $read_status 读取状态(0:未读 1:已读)
* @property int $inquiry_type 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
* @property string $from_name 发送人姓名
* @property string $notice_title 消息标题
* @property string $notice_send_time 发送时间
@@ -41,7 +43,7 @@ class MessageNotice extends Model
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['notice_id', 'user_id', 'user_type', 'notice_type', 'notice_system_type', 'read_status', 'from_name', 'notice_title', 'notice_send_time', 'notice_content', 'send_status', 'send_fail_reason', 'button_type', 'link_type', 'link_params', 'show_type', 'show_params', 'created_at', 'updated_at'];
protected array $fillable = ['notice_id', 'user_id', 'user_type', 'notice_type', 'notice_system_type', 'read_status', 'inquiry_type', 'from_name', 'notice_title', 'notice_send_time', 'notice_content', 'send_status', 'send_fail_reason', 'button_type', 'link_type', 'link_params', 'show_type', 'show_params', 'created_at', 'updated_at'];
protected string $primaryKey = "message_id";
@@ -121,4 +123,26 @@ class MessageNotice extends Model
{
return self::where($params)->update($data);
}
/**
* 获取单条
* @param array $params
* @param string $order_field
* @param array $fields
* @return object|null
*/
public static function getOrderOne(array $params, string $order_field,array $fields = ['*']): object|null
{
return self::where($params)->orderBy($order_field,'desc')->first($fields);
}
/**
* 获取数量
* @param array $params
* @return int
*/
public static function getCount(array $params): int
{
return self::where($params)->count();
}
}