添加视频案例api和sql

This commit is contained in:
2025-10-31 14:05:48 +08:00
parent b47f3e7143
commit afadb4471c
2 changed files with 91 additions and 0 deletions

79
server/api/video_case.api Normal file
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)
}

12
server/sql/video_case.sql Normal file
View File

@@ -0,0 +1,12 @@
CREATE TABLE `video_case` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '视频案例ID主键',
`title` varchar(255) NOT NULL COMMENT '视频案例标题',
`intro` text COMMENT '视频简介(描述案例背景、内容等)',
`video_url` varchar(512) NOT NULL COMMENT '视频播放地址如MP4 URL、视频平台嵌入链接',
`designer_names` varchar(1000) NOT NULL COMMENT '设计人员名单(多人用逗号分隔)',
`tutor_names` varchar(1000) NOT NULL COMMENT '指导老师名单(多人用逗号分隔)',
`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='视频案例表(独立存储,不关联其他表)';