Merge remote-tracking branch 'origin/main'

This commit is contained in:
堂吉诃德拉曼查的英豪
2026-08-06 17:21:13 +08:00
11 changed files with 323 additions and 8 deletions

View File

@@ -0,0 +1,56 @@
<?php
/**
* 文件服务
*/
return [
// 对应消费者类的 $serviceName
'name' => 'CourseService',
// 服务接口名,可选,默认值等于 name 配置的值,如果 name 直接定义为接口类则可忽略此行配置,如 name 为字符串则需要配置 service 对应到接口类
'service' => \Dhd\Micro\CourseService\CourseService::class,
// 对应容器对象 ID,可选,默认值等于 service 配置的值,用来定义依赖注入的 key
// 'id' => \App\JsonRpc\File\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,13 @@
<?php
/**
* 课程服务
*/
namespace Dhd\Micro\Interface\CourseService;
interface CourseService extends
\Dhd\Micro\Interface\CourseService\JsonRpcInterface\CourseServiceInterface,
\Dhd\Micro\Interface\CourseService\JsonRpcInterface\CourseFileInterface,
\Dhd\Micro\Interface\CourseService\JsonRpcInterface\CourseUnitInterface,
\Dhd\Micro\Interface\CourseService\JsonRpcInterface\CourseVideoInterface {}

View File

@@ -0,0 +1,42 @@
<?php
/**
* 课程讲义服务接口
*/
namespace Dhd\Micro\Interface\CourseService\JsonRpcInterface;
interface CourseFileInterface
{
/**
* 获取课程讲义列表
* @param int $courseId 课程ID
* @param bool $onlyShow 是否只显示显示状态的讲义
*/
public function getCourseFileList(int $courseId, bool $onlyShow = false): array;
/**
* 新增、编辑课程讲义
*/
public function editCourseFile(array $data);
/**
* 删除课程讲义
* @param int $id 课程讲义ID
*/
public function deleteCourseFile(int $id);
/**
* 修改课程讲义显示状态
* @param int $id 课程讲义ID
* @param int $isShow 显示状态 0-不显示 1-显示
*/
public function editCourseFileShow(int $id, int $isShow);
/**
* 修改课程讲义排序
* @param int $id 课程讲义ID
* @param int $sort 排序
*/
public function editCourseFileSort(int $id, int $sort);
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* 课程服务接口
*/
namespace Dhd\Micro\Interface\CourseService\JsonRpcInterface;
interface CourseServiceInterface
{
/**
* 获取课程分类列表
*/
public function getCourseCategoryList(): array;
/**
* 编辑/创建课程分类
*/
public function editCourseCategory(array $data);
/**
* 删除课程分类
* @param int $id 课程分类ID
*/
public function deleteCourseCategory(int $id);
/**
* 后台管理获取课程列表
* @param array $params 查询参数
*/
public function adminGetCourseList(array $params): array;
/**
* APP获取课程列表
* @param array $params 获取参数
*/
public function appGetCourseList(array $params): array;
/**
* 获取课程详情
* @param int $id 课程ID
* @param string $platform 平台 admin-后台 app-APP
* @param int $userId 用户ID
*/
public function getCourseDetail(int $id, string $platform = 'admin', int $userId = 0): array;
/**
* 新增、编辑课程
*/
public function editCourse(array $data);
/**
* 修改课程显示状态
* @param int $id 课程ID
* @param int $isShow 显示状态 0-不显示 1-显示
*/
public function editCourseShow(int $id, int $isShow);
/**
* 修改课程排序
* @param int $id 课程ID
* @param int $sort 排序
*/
public function editCourseSort(int $id, int $sort);
/**
* 删除课程
* @param int $id 课程ID
*/
public function deleteCourse(int $id);
/**
* 用户添加课程学习
* @param int $courseId 课程ID
* @param int $userId 用户ID
*/
public function addLearnCourse(int $courseId, int $userId);
/**
* 验证领取码
* @param int $courseId 课程ID
* @param int $userId 用户ID
* @param string $inviteCode 领取码
* @return void
*/
public function virfyInviteCode(int $courseId, int $userId, string $inviteCode);
/**
* 搜索课程
* @param string $keyword 搜索关键词
* @param array $params 搜索参数
* @return array
*/
public function searchCourses(string $keyword, array $params = []): array;
/**
* 根据教师ID获取课程列表
* @param int $teacherId 教师ID
* @param string $platform 平台 admin-后台 app-APP
*/
public function getCoursesByTeacherId(int $teacherId, string $platform = 'app'): array;
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* 课程单元、章节接口
*/
namespace Dhd\Micro\Interface\CourseService\JsonRpcInterface;
interface CourseUnitInterface
{
/**
* 获取课程单、章节元列表
* @param int $courseId 课程ID
*/
public function getCourseUnitList(int $courseId): array;
/**
* 获取课程单、章节元详情
* @param int $id 课程单、章节元ID
*/
public function getCourseUnitDetail(int $id): array;
/**
* 新增、编辑课程单、章节元
*/
public function editCourseUnit(array $data);
/**
* 删除课程单、章节元
* @param int $id 课程单、章节元ID
*/
public function deleteCourseUnit(int $id);
}

View File

@@ -0,0 +1,68 @@
<?php
/**
* 课程视频接口
*/
namespace Dhd\Micro\Interface\CourseService\JsonRpcInterface;
interface CourseVideoInterface
{
/**
* 获取课程视频列表
* @param int $courseId 课程ID
* @param string $platform 平台 admin-后台 app-APP
*/
public function getVideoLists(int $courseId, string $platform = 'admin'): array;
/**
* 获取课程视频详情
* @param int $id 课程视频ID
* @param string $platform 平台 admin-后台 app-APP
*/
public function getVideoDetail(int $id, string $platform = 'admin'): array;
/**
* 新增、编辑课程视频
* 'id',
* 'course_id',
* 'unit_id',
* 'cover_image',
* 'sort',
* 'title',
* 'video_url',
* 'video_size',
* 'video_time',
* 'format',
* 'is_show',
* 'main_teacher',
*/
public function editVideo(array $data);
/**
* 删除课程视频
* @param int $id 课程视频ID
*/
public function deleteVideo(int $id);
/**
* 修改课程视频排序
* @param int $id 课程视频ID
* @param int $sort 排序
*/
public function editVideoSort(int $id, int $sort);
/**
* 课程视频显示状态
* @param int $id 课程视频ID
* @param int $isShow 显示状态 0-不显示 1-显示
*/
public function editVideoShow(int $id, int $isShow);
/**
* 课程视频浏览量+1
* @param int $id 课程视频ID
* @param int $userId 用户ID
*/
public function addVideoBrowse(int $id, int $userId);
}

View File

@@ -7,7 +7,7 @@
namespace Dhd\Micro\Interface\FileService;
interface FileService extends
\Dhd\Micro\Interface\FileService\FileServiceInterface,
\Dhd\Micro\Interface\FileService\QuestionParseInterface,
\Dhd\Micro\Interface\FileService\QuestionQrCodeInterface,
\Dhd\Micro\Interface\FileService\ExcelParseInterface {}
\Dhd\Micro\Interface\FileService\JsonRpcInterface\FileServiceInterface,
\Dhd\Micro\Interface\FileService\JsonRpcInterface\QuestionParseInterface,
\Dhd\Micro\Interface\FileService\JsonRpcInterface\QuestionQrCodeInterface,
\Dhd\Micro\Interface\FileService\JsonRpcInterface\ExcelParseInterface {}

View File

@@ -4,7 +4,7 @@
* JsonRpc服务接口
*/
namespace Dhd\Micro\Interface\FileService;
namespace Dhd\Micro\Interface\FileService\JsonRpcInterface;
interface ExcelParseInterface
{

View File

@@ -4,7 +4,7 @@
* JsonRpc服务接口
*/
namespace Dhd\Micro\Interface\FileService;
namespace Dhd\Micro\Interface\FileService\JsonRpcInterface;
interface FileServiceInterface
{

View File

@@ -4,7 +4,7 @@
* JsonRpc服务接口
*/
namespace Dhd\Micro\Interface\FileService;
namespace Dhd\Micro\Interface\FileService\JsonRpcInterface;
interface QuestionParseInterface
{

View File

@@ -4,7 +4,7 @@
* JsonRpc服务接口
*/
namespace Dhd\Micro\Interface\FileService;
namespace Dhd\Micro\Interface\FileService\JsonRpcInterface;
interface QuestionQrCodeInterface
{