添加视频案例和教学案例业务层
This commit is contained in:
46
server/internal/teaching_case/handler/routes.go
Normal file
46
server/internal/teaching_case/handler/routes.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
teaching_case2 "github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/handler/teaching_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
|
server.AddRoutes(
|
||||||
|
[]rest.Route{
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/teaching-cases",
|
||||||
|
Handler: teaching_case2.CreateTeachingCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPut,
|
||||||
|
Path: "/api/teaching-cases",
|
||||||
|
Handler: teaching_case2.UpdateTeachingCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/api/teaching-cases",
|
||||||
|
Handler: teaching_case2.ListTeachingCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/api/teaching-cases/:id",
|
||||||
|
Handler: teaching_case2.GetTeachingCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodDelete,
|
||||||
|
Path: "/api/teaching-cases/:id",
|
||||||
|
Handler: teaching_case2.DeleteTeachingCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rest.WithPrefix("/api/teaching-case"),
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/logic/teaching_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreateTeachingCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.CreateTeachingCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := teaching_case.NewCreateTeachingCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.CreateTeachingCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/logic/teaching_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DeleteTeachingCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.DeleteTeachingCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := teaching_case.NewDeleteTeachingCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.DeleteTeachingCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/logic/teaching_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetTeachingCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.GetTeachingCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := teaching_case.NewGetTeachingCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetTeachingCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/logic/teaching_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ListTeachingCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.ListTeachingCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := teaching_case.NewListTeachingCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ListTeachingCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/logic/teaching_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UpdateTeachingCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.UpdateTeachingCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := teaching_case.NewUpdateTeachingCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.UpdateTeachingCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateTeachingCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCreateTeachingCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTeachingCaseLogic {
|
||||||
|
return &CreateTeachingCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *CreateTeachingCaseLogic) CreateTeachingCase(req *types.CreateTeachingCaseReq) (resp *types.BaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteTeachingCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDeleteTeachingCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTeachingCaseLogic {
|
||||||
|
return &DeleteTeachingCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *DeleteTeachingCaseLogic) DeleteTeachingCase(req *types.DeleteTeachingCaseReq) (resp *types.BaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetTeachingCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetTeachingCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTeachingCaseLogic {
|
||||||
|
return &GetTeachingCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetTeachingCaseLogic) GetTeachingCase(req *types.GetTeachingCaseReq) (resp *types.TeachingCaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListTeachingCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewListTeachingCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListTeachingCaseLogic {
|
||||||
|
return &ListTeachingCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ListTeachingCaseLogic) ListTeachingCase(req *types.ListTeachingCaseReq) (resp *types.ListTeachingCaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package teaching_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/teaching_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UpdateTeachingCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUpdateTeachingCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateTeachingCaseLogic {
|
||||||
|
return &UpdateTeachingCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *UpdateTeachingCaseLogic) UpdateTeachingCase(req *types.UpdateTeachingCaseReq) (resp *types.BaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
63
server/internal/teaching_case/internal/types/types.go
Normal file
63
server/internal/teaching_case/internal/types/types.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
type BaseResp struct {
|
||||||
|
Code int `json:"code"` // 状态码(0成功,非0失败)
|
||||||
|
Msg string `json:"msg"` // 提示信息
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateTeachingCaseReq struct {
|
||||||
|
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 DeleteTeachingCaseReq struct {
|
||||||
|
Id int `json:"id" validate:"required" uri:"id"` // 案例ID
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetTeachingCaseReq struct {
|
||||||
|
Id int `json:"id" validate:"required" uri:"id"` // 案例ID
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListTeachingCaseReq struct {
|
||||||
|
Page int `json:"page" default:"1"` // 页码
|
||||||
|
Size int `json:"size" default:"10"` // 每页数量
|
||||||
|
Keyword string `json:"keyword"` // 搜索关键词(标题/导师姓名)
|
||||||
|
Sort int `json:"sort"` // 排序筛选
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListTeachingCaseResp struct {
|
||||||
|
Total int64 `json:"total"` // 总条数
|
||||||
|
List []TeachingCaseResp `json:"list"` // 案例列表
|
||||||
|
}
|
||||||
|
|
||||||
|
type TeachingCaseResp struct {
|
||||||
|
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 UpdateTeachingCaseReq struct {
|
||||||
|
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"` // 排序
|
||||||
|
}
|
||||||
46
server/internal/video_case/handler/routes.go
Normal file
46
server/internal/video_case/handler/routes.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
video_case2 "github.com/JACKYMYPERSON/hldrCenter/internal/video_case/handler/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
|
server.AddRoutes(
|
||||||
|
[]rest.Route{
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/api/video-cases",
|
||||||
|
Handler: video_case2.CreateVideoCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPut,
|
||||||
|
Path: "/api/video-cases",
|
||||||
|
Handler: video_case2.UpdateVideoCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/api/video-cases",
|
||||||
|
Handler: video_case2.ListVideoCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/api/video-cases/:id",
|
||||||
|
Handler: video_case2.GetVideoCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodDelete,
|
||||||
|
Path: "/api/video-cases/:id",
|
||||||
|
Handler: video_case2.DeleteVideoCaseHandler(serverCtx),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rest.WithPrefix("/api/video-case"),
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CreateVideoCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.CreateVideoCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := video_case.NewCreateVideoCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.CreateVideoCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DeleteVideoCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.DeleteVideoCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := video_case.NewDeleteVideoCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.DeleteVideoCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetVideoCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.GetVideoCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := video_case.NewGetVideoCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetVideoCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ListVideoCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.ListVideoCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := video_case.NewListVideoCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ListVideoCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/logic/video_case"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UpdateVideoCaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.UpdateVideoCaseReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := video_case.NewUpdateVideoCaseLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.UpdateVideoCase(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateVideoCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCreateVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateVideoCaseLogic {
|
||||||
|
return &CreateVideoCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *CreateVideoCaseLogic) CreateVideoCase(req *types.CreateVideoCaseReq) (resp *types.BaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteVideoCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDeleteVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteVideoCaseLogic {
|
||||||
|
return &DeleteVideoCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *DeleteVideoCaseLogic) DeleteVideoCase(req *types.DeleteVideoCaseReq) (resp *types.BaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetVideoCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGetVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVideoCaseLogic {
|
||||||
|
return &GetVideoCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetVideoCaseLogic) GetVideoCase(req *types.GetVideoCaseReq) (resp *types.VideoCaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListVideoCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewListVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListVideoCaseLogic {
|
||||||
|
return &ListVideoCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ListVideoCaseLogic) ListVideoCase(req *types.ListVideoCaseReq) (resp *types.ListVideoCaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package video_case
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/svc"
|
||||||
|
"github.com/JACKYMYPERSON/hldrCenter/internal/video_case/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UpdateVideoCaseLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUpdateVideoCaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateVideoCaseLogic {
|
||||||
|
return &UpdateVideoCaseLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *UpdateVideoCaseLogic) UpdateVideoCase(req *types.UpdateVideoCaseReq) (resp *types.BaseResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
60
server/internal/video_case/internal/types/types.go
Normal file
60
server/internal/video_case/internal/types/types.go
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
type BaseResp struct {
|
||||||
|
Code int `json:"code"` // 状态码(0成功,非0失败)
|
||||||
|
Msg string `json:"msg"` // 提示信息
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateVideoCaseReq struct {
|
||||||
|
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 DeleteVideoCaseReq struct {
|
||||||
|
Id int `json:"id" validate:"required" uri:"id"` // 视频案例ID
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetVideoCaseReq struct {
|
||||||
|
Id int `json:"id" validate:"required" uri:"id"` // 视频案例ID
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListVideoCaseReq struct {
|
||||||
|
Page int `json:"page" default:"1"` // 页码
|
||||||
|
Size int `json:"size" default:"10"` // 每页数量
|
||||||
|
Keyword string `json:"keyword"` // 搜索关键词(标题/设计人员/指导老师)
|
||||||
|
Sort int `json:"sort"` // 排序筛选
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListVideoCaseResp struct {
|
||||||
|
Total int64 `json:"total"` // 总条数
|
||||||
|
List []VideoCaseResp `json:"list"` // 视频案例列表
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateVideoCaseReq struct {
|
||||||
|
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 VideoCaseResp struct {
|
||||||
|
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"` // 更新时间
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user