Files
hldrCenter/server/api/course_content.api
2025-10-31 13:24:44 +08:00

106 lines
2.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 课程内容请求和响应类型定义
type CourseContent {
Id int `json:"id"` // 内容ID主键
CourseId int `json:"course_id"` // 关联课程ID
ParentId int `json:"parent_id"` // 父级ID0表示章节>0表示小节
Title string `json:"title"` // 章节/小节标题
Content string `json:"content"` // 内容详情
Sort int `json:"sort"` // 排序
}
// 基础响应结构
type BaseResp {
Code int `json:"code"` // 状态码0表示成功
Message string `json:"message"` // 提示信息
Data interface{} `json:"data"` // 响应数据
}
// 获取课程内容列表请求
type GetContentListReq {
CourseId int `json:"course_id" form:"course_id"` // 课程ID必填
ParentId int `json:"parent_id" form:"parent_id"` // 父级ID可选0表示获取章节
}
// 获取课程内容列表响应
type GetContentListResp {
BaseResp
Data []CourseContent `json:"data"` // 内容列表
}
// 获取单个内容详情请求
type GetContentReq {
Id int `json:"id" form:"id" uri:"id"` // 内容ID必填
}
// 获取单个内容详情响应
type GetContentResp {
BaseResp
Data CourseContent `json:"data"` // 内容详情
}
// 新增内容请求
type AddContentReq {
CourseId int `json:"course_id" form:"course_id"` // 课程ID必填
ParentId int `json:"parent_id" form:"parent_id"` // 父级ID必填
Title string `json:"title" form:"title"` // 标题,必填
Content string `json:"content" form:"content"` // 内容详情,可选
Sort int `json:"sort" form:"sort"` // 排序,可选
}
// 新增内容响应
type AddContentResp {
BaseResp
Data int `json:"data"` // 新增内容的ID
}
// 更新内容请求
type UpdateContentReq {
Id int `json:"id" form:"id"` // 内容ID必填
Title string `json:"title" form:"title"` // 标题,可选
Content string `json:"content" form:"content"` // 内容详情,可选
Sort int `json:"sort" form:"sort"` // 排序,可选
}
// 更新内容响应
type UpdateContentResp {
BaseResp
}
// 删除内容请求
type DeleteContentReq {
Id int `json:"id" form:"id" uri:"id"` // 内容ID必填
}
// 删除内容响应
type DeleteContentResp {
BaseResp
}
// 课程内容API服务
@server (
group: course_content
prefix: /api/course-content
)
service course_content_api {
// 获取课程内容列表
@handler GetContentListHandler
get /api/course-content/list (GetContentListReq) returns (GetContentListResp)
// 获取单个内容详情
@handler GetContentHandler
get /api/course-content/:id (GetContentReq) returns (GetContentResp)
// 新增内容
@handler AddContentHandler
post /api/course-content (AddContentReq) returns (AddContentResp)
// 更新内容
@handler UpdateContentHandler
put /api/course-content (UpdateContentReq) returns (UpdateContentResp)
// 删除内容
@handler DeleteContentHandler
delete /api/course-content/:id (DeleteContentReq) returns (DeleteContentResp)
}