修改api结构
This commit is contained in:
98
server/api/course/course_activity/course_activity.api
Normal file
98
server/api/course/course_activity/course_activity.api
Normal 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user