Files
hldrCenter/server/api/course/course_file/course_file.api
2025-11-01 23:38:51 +08:00

73 lines
3.0 KiB
Plaintext
Raw Permalink 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.
// 课程文件创建请求无需id、create_time、update_time由数据库自动生成
type CreateCourseFileReq {
ContentId int `json:"content_id" form:"content_id" validate:"required"` // 关联的内容ID必填
Title string `json:"title" form:"title" validate:"required,max=255"` // 文件标题必填最长255字符
FileType string `json:"file_type" form:"file_type" validate:"required,max=30"` // 文件类型必填最长30字符
FileUrl string `json:"file_url" form:"file_url" validate:"required,max=255"` // 文件URL必填最长255字符
}
// 课程文件创建响应
type CreateCourseFileResp {
Id int `json:"id"` // 新增文件的ID
Message string `json:"message"` // 操作结果信息
}
// 课程文件查询请求根据ID查询
type GetCourseFileReq {
Id int `json:"id" form:"id" param:"id" validate:"required"` // 文件ID必填从路径参数获取
}
// 课程文件查询响应(返回完整文件信息)
type GetCourseFileResp {
Id int `json:"id"` // 文件ID
ContentId int `json:"content_id"` // 关联的内容ID
Title string `json:"title"` // 文件标题
FileType string `json:"file_type"` // 文件类型
FileUrl string `json:"file_url"` // 文件URL
CreateTime string `json:"create_time"` // 创建时间(格式化字符串)
UpdateTime string `json:"update_time"` // 更新时间(格式化字符串)
}
// 课程文件更新请求(部分字段更新)
type UpdateCourseFileReq {
Id int `json:"id" form:"id" validate:"required"` // 文件ID必填
ContentId int `json:"content_id" form:"content_id"` // 可选更新关联的内容ID
Title string `json:"title" form:"title" validate:"omitempty,max=255"` // 可选:更新标题
FileType string `json:"file_type" form:"file_type" validate:"omitempty,max=30"` // 可选:更新文件类型
FileUrl string `json:"file_url" form:"file_url" validate:"omitempty,max=255"` // 可选更新文件URL
}
// 课程文件更新响应
type UpdateCourseFileResp {
Message string `json:"message"` // 操作结果信息
}
// 课程文件删除请求
type DeleteCourseFileReq {
Id int `json:"id" form:"id" param:"id" validate:"required"` // 文件ID必填从路径参数获取
}
// 课程文件删除响应
type DeleteCourseFileResp {
Message string `json:"message"` // 操作结果信息
}
@server (
group: course_file // 接口分组改为课程文件相关
prefix: /api/course-file
)
service course_file_api { // 服务名称修改为课程文件API
@handler CreateCourseFileHandler // 创建课程文件
post /course-file (CreateCourseFileReq) returns (CreateCourseFileResp)
@handler GetCourseFileHandler // 查询单个课程文件
get /course-file/:id (GetCourseFileReq) returns (GetCourseFileResp)
@handler UpdateCourseFileHandler // 更新课程文件
put /course-file (UpdateCourseFileReq) returns (UpdateCourseFileResp)
@handler DeleteCourseFileHandler // 删除课程文件
delete /course-file/:id (DeleteCourseFileReq) returns (DeleteCourseFileResp)
}