新增ArticleService聚合契约与消费者配置
This commit is contained in:
40
consumers/article_service.php
Normal file
40
consumers/article_service.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Dhd\Micro\Interface\ArticleService\ArticleService;
|
||||
use function Hyperf\Support\env;
|
||||
|
||||
return [
|
||||
// 对应消费者类的 $serviceName
|
||||
'name' => 'ArticleService',
|
||||
// 服务接口名
|
||||
'service' => ArticleService::class,
|
||||
// 服务提供者的服务协议,可选,默认值为 jsonrpc-http
|
||||
'protocol' => 'jsonrpc-http',
|
||||
// 负载均衡算法,可选,默认值为 random
|
||||
'load_balancer' => 'random',
|
||||
// 这个消费者要从哪个服务中心获取节点信息,如不配置则不会从服务中心获取节点信息
|
||||
'registry' => [
|
||||
'protocol' => env('CONSUMERS_PROTOCOL', 'consul'),
|
||||
'address' => env('CONSUMERS_ADDRESS', 'http://127.0.0.1:8500'),
|
||||
],
|
||||
// 配置项,会影响到 Packer 和 Transporter
|
||||
'options' => [
|
||||
'connect_timeout' => 5.0,
|
||||
'recv_timeout' => 5.0,
|
||||
'settings' => [
|
||||
'open_eof_split' => true,
|
||||
'package_eof' => "\r\n",
|
||||
],
|
||||
'retry_count' => 2,
|
||||
'retry_interval' => 100,
|
||||
'heartbeat' => 30,
|
||||
'pool' => [
|
||||
'min_connections' => 1,
|
||||
'max_connections' => 32,
|
||||
'connect_timeout' => 10.0,
|
||||
'wait_timeout' => 3.0,
|
||||
'heartbeat' => -1,
|
||||
'max_idle_time' => 60.0,
|
||||
],
|
||||
],
|
||||
];
|
||||
86
src/ArticleService/ArticleService.php
Normal file
86
src/ArticleService/ArticleService.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dhd\Micro\Interface\ArticleService;
|
||||
|
||||
/**
|
||||
* 文章中心 RPC 聚合契约
|
||||
*/
|
||||
interface ArticleService
|
||||
{
|
||||
// 文章
|
||||
public function createArticle(array $data): int;
|
||||
public function updateArticle(int $id, array $data): bool;
|
||||
public function deleteArticle(int $id): bool;
|
||||
public function getArticleDetail(int $id): array;
|
||||
public function getArticleDetailWithUser(int $id, int $userId): array;
|
||||
public function getArticleList(array $params = []): array;
|
||||
public function appGetArticleList(array $params = []): array;
|
||||
|
||||
// 类型
|
||||
public function createType(array $data): int;
|
||||
public function updateType(int $id, array $data): bool;
|
||||
public function deleteType(int $id): bool;
|
||||
public function getTypeList(array $params = []): array;
|
||||
|
||||
// 分类
|
||||
public function createCategory(array $data): int;
|
||||
public function updateCategory(int $id, array $data): bool;
|
||||
public function deleteCategory(int $id): bool;
|
||||
public function getCategoryList(array $params = []): array;
|
||||
public function appGetCategoryList(array $params = []): array;
|
||||
public function getCategoryTree(array $params = []): array;
|
||||
public function bindCategoryTypes(int $categoryId, array $typeIds): bool;
|
||||
public function unbindCategoryTypes(int $categoryId, array $typeIds): bool;
|
||||
public function getCategoryBoundTypes(int $categoryId): array;
|
||||
|
||||
// 标签
|
||||
public function createTag(array $data): int;
|
||||
public function updateTag(int $id, array $data): bool;
|
||||
public function deleteTag(int $id): bool;
|
||||
public function getTagList(array $params = []): array;
|
||||
public function createTagGroup(array $data): int;
|
||||
public function updateTagGroup(int $id, array $data): bool;
|
||||
public function deleteTagGroup(int $id): bool;
|
||||
public function getTagGroupList(array $params = []): array;
|
||||
public function getTagGroupDetail(int $id): array;
|
||||
|
||||
// 附件
|
||||
public function createAttachment(array $data): int;
|
||||
public function updateAttachment(int $id, array $data): bool;
|
||||
public function deleteAttachment(int $id): bool;
|
||||
public function getAttachmentsByArticleId(int $articleId): array;
|
||||
|
||||
// 交互
|
||||
public function likeArticle(int $articleId, int $userId): bool;
|
||||
public function cancelLikeArticle(int $articleId, int $userId): bool;
|
||||
public function collectArticle(int $articleId, int $userId, ?string $remark = null): bool;
|
||||
public function cancelCollectArticle(int $articleId, int $userId): bool;
|
||||
public function recordShareArticle(int $articleId, int $userId): bool;
|
||||
public function recordReadArticle(int $articleId, int $userId, ?string $ip = null): bool;
|
||||
|
||||
// 内容页
|
||||
public function createContentPage(array $data): int;
|
||||
public function updateContentPage(int $id, array $data): bool;
|
||||
public function deleteContentPage(int $id): bool;
|
||||
public function getContentPageList(array $params = []): array;
|
||||
public function getContentPageDetail(int $id): array;
|
||||
public function getContentPageListByGroupCode(string $groupCode, array $params = []): array;
|
||||
public function getContentPageByGroupCode(string $groupCode): array;
|
||||
|
||||
// 内容栏目
|
||||
public function createContentColumn(array $data): int;
|
||||
public function updateContentColumn(int $id, array $data): bool;
|
||||
public function deleteContentColumn(int $id): bool;
|
||||
public function getContentColumnList(array $params = []): array;
|
||||
public function getContentColumnDetail(int $id): array;
|
||||
public function getContentColumnsByChannel(string $channel): array;
|
||||
|
||||
// FAQ
|
||||
public function createFaq(array $data): int;
|
||||
public function updateFaq(int $id, array $data): bool;
|
||||
public function deleteFaq(int $id): bool;
|
||||
public function getFaqList(array $params = []): array;
|
||||
public function getFaqDetail(int $id): array;
|
||||
}
|
||||
Reference in New Issue
Block a user