97 lines
2.0 KiB
PHP
97 lines
2.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
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;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* EntityParseInterface 接口
|
||
|
|
*
|
||
|
|
* 定义消息解析器的标准接口
|
||
|
|
*/
|
||
|
|
interface EntityParseInterface
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 公司作用域匹配
|
||
|
|
*
|
||
|
|
* @param ConsumerMessageInterface $message
|
||
|
|
* @return Company
|
||
|
|
*/
|
||
|
|
public function companyScopeMatch(ConsumerMessageInterface $message): Company;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 平台作用域匹配
|
||
|
|
*
|
||
|
|
* @param ConsumerMessageInterface $message
|
||
|
|
* @return Platform
|
||
|
|
*/
|
||
|
|
public function platformScopeMatch(ConsumerMessageInterface $message): Platform;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 店铺作用域匹配
|
||
|
|
*
|
||
|
|
* @param ConsumerMessageInterface $message
|
||
|
|
* @return Store
|
||
|
|
*/
|
||
|
|
public function storeScopeMatch(ConsumerMessageInterface $message): Store;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 实体类型匹配
|
||
|
|
*
|
||
|
|
* @param ConsumerMessageInterface $message
|
||
|
|
* @return Entity
|
||
|
|
*/
|
||
|
|
public function entityMatch(ConsumerMessageInterface $message): Entity;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 实体数据映射
|
||
|
|
*
|
||
|
|
* @param array $data
|
||
|
|
* @param Entity $entity
|
||
|
|
* @return Entity
|
||
|
|
*/
|
||
|
|
public function entityMap(array $data, Entity $entity): Entity;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 提取实体唯一标识符
|
||
|
|
*
|
||
|
|
* @param ConsumerMessageInterface $message
|
||
|
|
* @return string|int
|
||
|
|
*/
|
||
|
|
public function entityUniqueIdentifierExtract(ConsumerMessageInterface $message): string|int;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取消息对象
|
||
|
|
*
|
||
|
|
* @return ConsumerMessageInterface
|
||
|
|
*/
|
||
|
|
public function getMessage(): ConsumerMessageInterface;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取平台对象
|
||
|
|
*
|
||
|
|
* @return Platform
|
||
|
|
*/
|
||
|
|
public function getPlatform(): Platform;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取公司对象
|
||
|
|
*
|
||
|
|
* @return Company
|
||
|
|
*/
|
||
|
|
public function getCompany(): Company;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取店铺对象
|
||
|
|
*
|
||
|
|
* @return Store
|
||
|
|
*/
|
||
|
|
public function getStore(): Store;
|
||
|
|
}
|