update entiity parse
This commit is contained in:
@@ -4,11 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Parse;
|
||||
|
||||
use Hyperf\Amqp\Message\ConsumerMessageInterface;
|
||||
use App\Model\Company;
|
||||
use App\Model\Platform;
|
||||
use App\Model\Store;
|
||||
use App\Model\Model as Entity;
|
||||
use Hyperf\Collection\LazyCollection;
|
||||
|
||||
/**
|
||||
* EntityParseInterface 接口
|
||||
@@ -17,61 +17,74 @@ use App\Model\Model as Entity;
|
||||
*/
|
||||
interface EntityParseInterface
|
||||
{
|
||||
/**
|
||||
* 消息数据验证
|
||||
*
|
||||
* 验证消息数据是否包含必需字段
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function messageValidate(array $data): bool;
|
||||
|
||||
/**
|
||||
* 公司作用域匹配
|
||||
*
|
||||
* @param ConsumerMessageInterface $message
|
||||
* @param array $metadata
|
||||
* @return Company
|
||||
*/
|
||||
public function companyScopeMatch(ConsumerMessageInterface $message): Company;
|
||||
public function companyScopeMatch(array $metadata): Company;
|
||||
|
||||
/**
|
||||
* 平台作用域匹配
|
||||
*
|
||||
* @param ConsumerMessageInterface $message
|
||||
* @param array $metadata
|
||||
* @return Platform
|
||||
*/
|
||||
public function platformScopeMatch(ConsumerMessageInterface $message): Platform;
|
||||
public function platformScopeMatch(array $metadata): Platform;
|
||||
|
||||
/**
|
||||
* 店铺作用域匹配
|
||||
*
|
||||
* @param ConsumerMessageInterface $message
|
||||
* @param array $metadata
|
||||
* @return Store
|
||||
*/
|
||||
public function storeScopeMatch(ConsumerMessageInterface $message): Store;
|
||||
public function storeScopeMatch(array $metadata): Store;
|
||||
|
||||
/**
|
||||
* 实体类型匹配
|
||||
*
|
||||
* @param ConsumerMessageInterface $message
|
||||
* 根据 metadata 返回实体模板实例
|
||||
*
|
||||
* @param array $metadata
|
||||
* @return Entity
|
||||
*/
|
||||
public function entityMatch(ConsumerMessageInterface $message): Entity;
|
||||
public function entityMatch(array $metadata): Entity;
|
||||
|
||||
/**
|
||||
* 实体数据映射
|
||||
*
|
||||
* @param array $data
|
||||
* @param Entity $entity
|
||||
* @return Entity
|
||||
* 将原始数据转换为可填充到 Model 的数据集合
|
||||
*
|
||||
* @param array $rawData
|
||||
* @return LazyCollection
|
||||
*/
|
||||
public function entityMap(array $data, Entity $entity): Entity;
|
||||
public function entityMap(array $rawData): LazyCollection;
|
||||
|
||||
/**
|
||||
* 提取实体唯一标识符
|
||||
*
|
||||
* @param ConsumerMessageInterface $message
|
||||
* @param array $metadata
|
||||
* @return string|int
|
||||
*/
|
||||
public function entityUniqueIdentifierExtract(ConsumerMessageInterface $message): string|int;
|
||||
public function entityUniqueIdentifierExtract(array $metadata): string|int;
|
||||
|
||||
/**
|
||||
* 获取消息对象
|
||||
* 获取消息数据
|
||||
*
|
||||
* @return ConsumerMessageInterface
|
||||
* @return array
|
||||
*/
|
||||
public function getMessage(): ConsumerMessageInterface;
|
||||
public function getData(): array;
|
||||
|
||||
/**
|
||||
* 获取平台对象
|
||||
|
||||
Reference in New Issue
Block a user