添加教学案例api和sql
This commit is contained in:
82
server/api/teaching_case.api
Normal file
82
server/api/teaching_case.api
Normal 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)
|
||||||
|
}
|
||||||
|
|
||||||
13
server/sql/teaching_case.sql
Normal file
13
server/sql/teaching_case.sql
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
CREATE TABLE `teaching_case` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT COMMENT '案例ID(主键)',
|
||||||
|
`title` varchar(255) NOT NULL COMMENT '案例标题',
|
||||||
|
`tutor_name` varchar(100) NOT NULL COMMENT '导师姓名',
|
||||||
|
`tutor_title` varchar(200) DEFAULT '' COMMENT '导师头衔(如:XX讲师)',
|
||||||
|
`student_names` varchar(500) NOT NULL COMMENT '学生姓名(多人用逗号分隔,如“张三,李四”)',
|
||||||
|
`content` text NOT NULL COMMENT '案例内容(详细描述)',
|
||||||
|
`cover_url` varchar(512) DEFAULT '' COMMENT '案例封面图URL',
|
||||||
|
`sort` int DEFAULT 0 COMMENT '排序(数字越小越靠前)',
|
||||||
|
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='独立教学案例表';
|
||||||
Reference in New Issue
Block a user