增加文件服务接口配置

This commit is contained in:
2026-08-05 15:45:42 +08:00
parent 189f24d5b5
commit ac59397968
7 changed files with 158 additions and 2 deletions

View File

@@ -11,8 +11,6 @@ declare(strict_types=1);
*/
use Dhd\Micro\Interface\AIService\AIService;
// use function Hyperf\Support\env;
return [
// 对应消费者类的 $serviceName
'name' => 'AIService',

View File

@@ -0,0 +1,56 @@
<?php
/**
* 文件服务
*/
return [
// 对应消费者类的 $serviceName
'name' => 'FileService',
// 服务接口名,可选,默认值等于 name 配置的值,如果 name 直接定义为接口类则可忽略此行配置,如 name 为字符串则需要配置 service 对应到接口类
'service' => \Dhd\Micro\Interface\FileService\FileServiceInterface::class,
// 对应容器对象 ID,可选,默认值等于 service 配置的值,用来定义依赖注入的 key
// 'id' => \Dhd\Micro\Interface\FileService\FileServiceInterface::class,
// 服务提供者的服务协议,可选,默认值为 jsonrpc-http
// 可选 jsonrpc-http jsonrpc jsonrpc-tcp-length-check
'protocol' => 'jsonrpc-http',
// 负载均衡算法,可选,默认值为 random
'load_balancer' => 'random',
// 这个消费者要从哪个服务中心获取节点信息,如不配置则不会从服务中心获取节点信息
'registry' => [
'protocol' => env("CONSUMERS_PROTOCOL", "consul"),
'address' => env("CONSUMERS_ADDRESS", "http://127.0.0.1:8500"),
],
// 'nodes' => [
// ['host' => '172.18.0.2', 'port' => 9501],
// ],
// 配置项,会影响到 Packer 和 Transporter
'options' => [
'connect_timeout' => 5.0,
'recv_timeout' => 5.0,
'settings' => [
// 根据协议不同,区分配置
'open_eof_split' => true,
'package_eof' => "\r\n",
// 'open_length_check' => true,
// 'package_length_type' => 'N',
// 'package_length_offset' => 0,
// 'package_body_offset' => 4,
],
// 重试次数,默认值为 2,收包超时不进行重试。暂只支持 JsonRpcPoolTransporter
'retry_count' => 2,
// 重试间隔,毫秒
'retry_interval' => 100,
// 使用多路复用 RPC 时的心跳间隔,null 为不触发心跳
'heartbeat' => 30,
// 当使用 JsonRpcPoolTransporter 时会用到以下配置
'pool' => [
'min_connections' => 1,
'max_connections' => 32,
'connect_timeout' => 10.0,
'wait_timeout' => 3.0,
'heartbeat' => -1,
'max_idle_time' => 60.0,
],
],
];

View File

@@ -0,0 +1,15 @@
<?php
/**
* JsonRpc服务接口
*/
namespace Dhd\Micro\Interface\FileService;
interface ExcelParseInterface
{
/**
* 解析文件
*/
public function excelParse(array $header, string $highestColumn, int $fileId, int $page = 1, int $limit = 1000): array;
}

View File

@@ -0,0 +1,13 @@
<?php
/**
* 文件服务
*/
namespace Dhd\Micro\Interface\FileService;
interface FileService extends
FileServiceInterface,
QuestionParseInterface,
QuestionQrCodeInterface,
ExcelParseInterface {}

View File

@@ -0,0 +1,30 @@
<?php
/**
* JsonRpc服务接口
*/
namespace Dhd\Micro\Interface\FileService;
interface FileServiceInterface
{
/**
* 获取文件分组列表
*/
public function getFileGroupList(): array;
/**
* 添加/编辑文件分组
*/
public function editFileGroup(int $groupId, int $pid, string $groupName): array;
/**
* 删除文件分组
*/
public function deleteFileGroup(int $groupId): array;
/**
* 获取文件列表
*/
public function getFileList(array $params): array;
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* JsonRpc服务接口
*/
namespace Dhd\Micro\Interface\FileService;
interface QuestionParseInterface
{
/**
* 解析文件
*/
public function questionWordParse(int $fileId): array;
/**
* 根据code确认导入题目,设置submit_save为1,且移动图片到$this->imageDir目录,变更图片路径
*/
public function submitSaveByCode(string $code): array;
/**
* 读取解析暂存数据,不确认导入且不移动图片。
*/
public function getQuestionParseByCode(string $code): array;
}

View File

@@ -0,0 +1,19 @@
<?php
/**
* JsonRpc服务接口
*/
namespace Dhd\Micro\Interface\FileService;
interface QuestionQrCodeInterface
{
/**
* 生成题目、试卷二维码
* @param int $type 二维码类型
* @param int $id 记录ID
* @param array $data 额外参数
* @return array
*/
public function createQuestionQr(int $type, int $id, array $data): array;
}