|
@@ -5,6 +5,7 @@ namespace SixShop\Message\Entity;
|
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
|
use SixShop\Message\Model\MessageNotificationsModel;
|
|
use SixShop\Message\Model\MessageNotificationsModel;
|
|
|
use think\Paginator;
|
|
use think\Paginator;
|
|
|
|
|
+use function SixShop\Core\throw_logic_exception;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @mixin MessageNotificationsModel
|
|
* @mixin MessageNotificationsModel
|
|
@@ -16,4 +17,15 @@ class MessageNotificationsEntity extends BaseEntity
|
|
|
return $this->withSearch(['user_id', 'is_read'], $params)
|
|
return $this->withSearch(['user_id', 'is_read'], $params)
|
|
|
->paginate($pageAndLimit);
|
|
->paginate($pageAndLimit);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function read(int $id): self
|
|
|
|
|
+ {
|
|
|
|
|
+ $entity = $this->findOrEmpty($id);
|
|
|
|
|
+ if ($entity->isEmpty()) {
|
|
|
|
|
+ throw_logic_exception('消息不存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ $entity->is_read = 1;
|
|
|
|
|
+ $entity->save();
|
|
|
|
|
+ return $entity;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|