修改api结构

This commit is contained in:
2025-11-01 23:38:51 +08:00
parent c2db98cd76
commit 6351539237
21 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
// 创建课程活动请求无需id由数据库自增生成
type CreateCourseActivityReq {
CourseId int `json:"course_id" form:"course_id" validate:"required"` // 关联课程ID必填外键
Title string `json:"title" form:"title" validate:"required,max=255"` // 活动标题必填最长255字符
ActivityType int `json:"activity_type" form:"activity_type" validate:"omitempty,min=1,max=4"` // 活动类型可选1-作业/2-考试/3-讨论/4-直播默认1
Content string `json:"content" form:"content"` // 活动详情(可选,文本)
StartTime string `json:"start_time" form:"start_time" validate:"omitempty,datetime=2006-01-02 15:04:05"` // 开始时间可选格式yyyy-MM-dd HH:mm:ss
EndTime string `json:"end_time" form:"end_time" validate:"omitempty,datetime=2006-01-02 15:04:05"` // 结束时间(可选,格式同上)
Sort int `json:"sort" form:"sort" validate:"omitempty,min=0"` // 排序可选默认0
}
// 创建课程活动响应
type CreateCourseActivityResp {
Id int `json:"id"` // 新增活动的ID
Message string `json:"message"` // 操作结果信息
}
// 查询单个课程活动请求按ID查询
type GetCourseActivityReq {
Id int `json:"id" form:"id" param:"id" validate:"required"` // 活动ID必填从路径参数获取
}
// 查询单个课程活动响应(返回完整活动信息)
type GetCourseActivityResp {
Id int `json:"id"` // 活动ID
CourseId int `json:"course_id"` // 关联课程ID
Title string `json:"title"` // 活动标题
ActivityType int `json:"activity_type"` // 活动类型1-作业/2-考试/3-讨论/4-直播)
Content string `json:"content"` // 活动详情
StartTime string `json:"start_time"` // 开始时间(格式化字符串)
EndTime string `json:"end_time"` // 结束时间(格式化字符串)
Sort int `json:"sort"` // 排序
}
// 课程活动列表查询请求(支持筛选和分页)
type ListCourseActivityReq {
CourseId int `json:"course_id" form:"course_id" validate:"omitempty"` // 可选筛选按课程ID查询
ActivityType int `json:"activity_type" form:"activity_type" validate:"omitempty,min=1,max=4"` // 可选筛选:按活动类型查询
Page int `json:"page" form:"page" validate:"required,min=1"` // 页码必填从1开始
PageSize int `json:"page_size" form:"page_size" validate:"required,min=1,max=100"` // 每页条数必填1-100
}
// 课程活动列表响应
type ListCourseActivityResp {
Total int `json:"total"` // 总条数
List []GetCourseActivityResp `json:"list"` // 活动列表(单条结构同查询单个响应)
Page int `json:"page"` // 当前页码
PageSize int `json:"page_size"` // 每页条数
}
// 更新课程活动请求
type UpdateCourseActivityReq {
Id int `json:"id" form:"id" validate:"required"` // 活动ID必填
CourseId int `json:"course_id" form:"course_id" validate:"omitempty"` // 可选更新关联课程ID
Title string `json:"title" form:"title" validate:"omitempty,max=255"` // 可选更新:活动标题
ActivityType int `json:"activity_type" form:"activity_type" validate:"omitempty,min=1,max=4"` // 可选更新:活动类型
Content string `json:"content" form:"content"` // 可选更新:活动详情
StartTime string `json:"start_time" form:"start_time" validate:"omitempty,datetime=2006-01-02 15:04:05"` // 可选更新:开始时间
EndTime string `json:"end_time" form:"end_time" validate:"omitempty,datetime=2006-01-02 15:04:05"` // 可选更新:结束时间
Sort int `json:"sort" form:"sort" validate:"omitempty,min=0"` // 可选更新:排序
}
// 更新课程活动响应
type UpdateCourseActivityResp {
Message string `json:"message"` // 操作结果信息
}
// 删除课程活动请求
type DeleteCourseActivityReq {
Id int `json:"id" form:"id" param:"id" validate:"required"` // 活动ID必填从路径参数获取
}
// 删除课程活动响应
type DeleteCourseActivityResp {
Message string `json:"message"` // 操作结果信息
}
@server (
group: course_activity // 接口分组:课程活动
prefix: /api/course-activity
)
service course_activity_api { // 服务名称课程活动API
@handler CreateCourseActivityHandler // 创建课程活动
post /course-activity (CreateCourseActivityReq) returns (CreateCourseActivityResp)
@handler GetCourseActivityHandler // 查询单个课程活动
get /course-activity/:id (GetCourseActivityReq) returns (GetCourseActivityResp)
@handler ListCourseActivityHandler // 课程活动列表查询(支持分页/筛选)
post /course-activity/list (ListCourseActivityReq) returns (ListCourseActivityResp)
@handler UpdateCourseActivityHandler // 更新课程活动
put /course-activity (UpdateCourseActivityReq) returns (UpdateCourseActivityResp)
@handler DeleteCourseActivityHandler // 删除课程活动
delete /course-activity/:id (DeleteCourseActivityReq) returns (DeleteCourseActivityResp)
}

View File

@@ -0,0 +1,105 @@
// 课程内容请求和响应类型定义
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)
}

View File

@@ -0,0 +1,72 @@
// 课程文件创建请求无需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)
}

View File

@@ -0,0 +1,75 @@
// 课程请求结构体
type CreateCourseReq {
Title string `json:"title" validate:"required"` // 课程标题
Subtitle string `json:"subtitle"` // 课程副标题
CoverUrl string `json:"cover_url"` // 课程封面图URL
Intro string `json:"intro"` // 课程简介
Status int8 `json:"status" default:"1"` // 课程状态0删除1-已发布)
}
type UpdateCourseReq {
Id int64 `json:"id" validate:"required"` // 课程ID
Title string `json:"title"` // 课程标题
Subtitle string `json:"subtitle"` // 课程副标题
CoverUrl string `json:"cover_url"` // 课程封面图URL
Intro string `json:"intro"` // 课程简介
Status int8 `json:"status"` // 课程状态0删除1-已发布)
}
type GetCourseReq {
Id int64 `json:"id" validate:"required"` // 课程ID
}
type DeleteCourseReq {
Id int64 `json:"id" validate:"required"` // 课程ID
}
type ListCourseReq {
Page int `json:"page" default:"1"` // 页码
Size int `json:"size" default:"10"` // 每页数量
Status int8 `json:"status"` // 课程状态筛选
Keyword string `json:"keyword"` // 搜索关键词(标题/副标题)
}
// 课程响应结构体
type CourseResp {
Id int64 `json:"id"` // 课程ID
Title string `json:"title"` // 课程标题
Subtitle string `json:"subtitle"` // 课程副标题
CoverUrl string `json:"cover_url"` // 课程封面图URL
Intro string `json:"intro"` // 课程简介
Status int8 `json:"status"` // 课程状态
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type ListCourseResp {
Total int64 `json:"total"` // 总条数
List []CourseResp `json:"list"` // 课程列表
}
type BaseResp {
Code int `json:"code"` // 状态码0成功非0失败
Msg string `json:"msg"` // 提示信息
}
@server (
group: course
)
service course-api {
@handler CreateCourseHandler
post /api/courses (CreateCourseReq) returns (BaseResp)
@handler UpdateCourseHandler
put /api/courses (UpdateCourseReq) returns (BaseResp)
@handler GetCourseHandler
get /api/courses/:id (GetCourseReq) returns (CourseResp)
@handler DeleteCourseHandler
delete /api/courses/:id (DeleteCourseReq) returns (BaseResp)
@handler ListCourseHandler
get /api/courses (ListCourseReq) returns (ListCourseResp)
}

View File

@@ -0,0 +1,82 @@
// 教学案例请求结构体
type CreateTeachingCaseReq {
Title string `json:"title" validate:"required"` // 案例标题
TutorName string `json:"tutor_name" validate:"required"` // 导师姓名
TutorTitle string `json:"tutor_title"` // 导师头衔
StudentNames string `json:"student_names" validate:"required"` // 学生姓名(逗号分隔)
Content string `json:"content" validate:"required"` // 案例内容
CoverUrl string `json:"cover_url"` // 案例封面图URL
Sort int `json:"sort" default:"0"` // 排序
}
type UpdateTeachingCaseReq {
Id int `json:"id" validate:"required"` // 案例ID
Title string `json:"title"` // 案例标题
TutorName string `json:"tutor_name"` // 导师姓名
TutorTitle string `json:"tutor_title"` // 导师头衔
StudentNames string `json:"student_names"` // 学生姓名(逗号分隔)
Content string `json:"content"` // 案例内容
CoverUrl string `json:"cover_url"` // 案例封面图URL
Sort int `json:"sort"` // 排序
}
type GetTeachingCaseReq {
Id int `json:"id" validate:"required" uri:"id"` // 案例ID
}
type DeleteTeachingCaseReq {
Id int `json:"id" validate:"required" uri:"id"` // 案例ID
}
type ListTeachingCaseReq {
Page int `json:"page" default:"1"` // 页码
Size int `json:"size" default:"10"` // 每页数量
Keyword string `json:"keyword"` // 搜索关键词(标题/导师姓名)
Sort int `json:"sort"` // 排序筛选
}
// 教学案例响应结构体
type TeachingCaseResp {
Id int `json:"id"` // 案例ID
Title string `json:"title"` // 案例标题
TutorName string `json:"tutor_name"` // 导师姓名
TutorTitle string `json:"tutor_title"` // 导师头衔
StudentNames string `json:"student_names"` // 学生姓名
Content string `json:"content"` // 案例内容
CoverUrl string `json:"cover_url"` // 封面图URL
Sort int `json:"sort"` // 排序
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type ListTeachingCaseResp {
Total int64 `json:"total"` // 总条数
List []TeachingCaseResp `json:"list"` // 案例列表
}
type BaseResp {
Code int `json:"code"` // 状态码0成功非0失败
Msg string `json:"msg"` // 提示信息
}
@server (
group: teaching_case
prefix: /api/teaching-case
)
service teaching_case_api {
@handler CreateTeachingCaseHandler
post /api/teaching-cases (CreateTeachingCaseReq) returns (BaseResp)
@handler UpdateTeachingCaseHandler
put /api/teaching-cases (UpdateTeachingCaseReq) returns (BaseResp)
@handler GetTeachingCaseHandler
get /api/teaching-cases/:id (GetTeachingCaseReq) returns (TeachingCaseResp)
@handler DeleteTeachingCaseHandler
delete /api/teaching-cases/:id (DeleteTeachingCaseReq) returns (BaseResp)
@handler ListTeachingCaseHandler
get /api/teaching-cases (ListTeachingCaseReq) returns (ListTeachingCaseResp)
}

View File

@@ -0,0 +1,79 @@
// 视频案例请求结构体
type CreateVideoCaseReq {
Title string `json:"title" validate:"required"` // 视频案例标题
Intro string `json:"intro"` // 视频简介
VideoUrl string `json:"video_url" validate:"required"` // 视频播放地址
DesignerNames string `json:"designer_names" validate:"required"` // 设计人员名单(逗号分隔)
TutorNames string `json:"tutor_names" validate:"required"` // 指导老师名单(逗号分隔)
Sort int `json:"sort" default:"0"` // 排序
}
type UpdateVideoCaseReq {
Id int `json:"id" validate:"required"` // 视频案例ID
Title string `json:"title"` // 视频案例标题
Intro string `json:"intro"` // 视频简介
VideoUrl string `json:"video_url"` // 视频播放地址
DesignerNames string `json:"designer_names"` // 设计人员名单
TutorNames string `json:"tutor_names"` // 指导老师名单
Sort int `json:"sort"` // 排序
}
type GetVideoCaseReq {
Id int `json:"id" validate:"required" uri:"id"` // 视频案例ID
}
type DeleteVideoCaseReq {
Id int `json:"id" validate:"required" uri:"id"` // 视频案例ID
}
type ListVideoCaseReq {
Page int `json:"page" default:"1"` // 页码
Size int `json:"size" default:"10"` // 每页数量
Keyword string `json:"keyword"` // 搜索关键词(标题/设计人员/指导老师)
Sort int `json:"sort"` // 排序筛选
}
// 视频案例响应结构体
type VideoCaseResp {
Id int `json:"id"` // 视频案例ID
Title string `json:"title"` // 视频案例标题
Intro string `json:"intro"` // 视频简介
VideoUrl string `json:"video_url"` // 视频播放地址
DesignerNames string `json:"designer_names"` // 设计人员名单
TutorNames string `json:"tutor_names"` // 指导老师名单
Sort int `json:"sort"` // 排序
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type ListVideoCaseResp {
Total int64 `json:"total"` // 总条数
List []VideoCaseResp `json:"list"` // 视频案例列表
}
type BaseResp {
Code int `json:"code"` // 状态码0成功非0失败
Msg string `json:"msg"` // 提示信息
}
@server (
group: video_case
prefix: /api/video-case
)
service video_case_api {
@handler CreateVideoCaseHandler
post /api/video-cases (CreateVideoCaseReq) returns (BaseResp)
@handler UpdateVideoCaseHandler
put /api/video-cases (UpdateVideoCaseReq) returns (BaseResp)
@handler GetVideoCaseHandler
get /api/video-cases/:id (GetVideoCaseReq) returns (VideoCaseResp)
@handler DeleteVideoCaseHandler
delete /api/video-cases/:id (DeleteVideoCaseReq) returns (BaseResp)
@handler ListVideoCaseHandler
get /api/video-cases (ListVideoCaseReq) returns (ListVideoCaseResp)
}