change struct

This commit is contained in:
cano
2024-03-25 06:29:56 +08:00
parent 489090382f
commit 6ce37d789f
11 changed files with 128 additions and 81 deletions

View File

@ -2,6 +2,7 @@
namespace App\Models\Api\Post;
use App\Bean\Queue\Api\QueueAddPostBean;
use App\Exceptions\ModelException;
use App\Jobs\Api\AddPostQueue;
use App\Models\Api\Base\ApiBaseModel;
@ -9,7 +10,6 @@ use App\Models\Api\Comment\PostCommentModel;
use App\Models\Api\Customer\CustomerUserExtendModel;
use App\Models\Api\Follow\FollowModel;
use App\Models\Api\Post\Structs\PostParamsStruct;
use App\Structs\QueueAddPostStruct;
use App\Tools\CollectOffsetLimit;
use App\Tools\Tools;
use Illuminate\Database\Eloquent\Casts\Attribute;
@ -82,22 +82,16 @@ class PostPushBoxModel extends ApiBaseModel
);
}
public static function addPostQueueProducer(array $params): void
{
AddPostQueue::dispatch($params)->onQueue(QueueAddPostStruct::QUEUE_NAME);
}
/**
* 提交后调用事件,在消费队列跑推送
* @throws ModelException
*/
function addPostQueueConsumer(array $params)
function addPostQueueConsumer(QueueAddPostBean $bean)
{
if (empty($params)) return false;
if (isset($params['id'])) return false;
if (isset($params['type'])) return false;
$id = $params['id'];
$type = $params['type'];
$id = $bean->getId();
$type = $bean->getType();
if (empty($id)) return false;
if (empty($type)) return false;
if (!in_array($type, [self::TYPE_POST, self::TYPE_REPOST, self::TYPE_COMMENT])) return false;
if (empty($id)) return false;