添加视频案例和教学案例业务层
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"` // 排序
|
||||
}
|
||||
Reference in New Issue
Block a user