From b4968af2264ad0e7d4b62dd011dd2978ca77f8b9 Mon Sep 17 00:00:00 2001 From: mayiming <1627832236@qq.com> Date: Sat, 1 Nov 2025 23:01:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AF=BE=E7=A8=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../course_file/createcoursefilehandler.go | 31 ++++++++++++ .../course_file/deletecoursefilehandler.go | 31 ++++++++++++ .../course_file/getcoursefilehandler.go | 31 ++++++++++++ .../course_file/updatecoursefilehandler.go | 31 ++++++++++++ .../course_file/createcoursefilelogic.go | 33 ++++++++++++ .../course_file/deletecoursefilelogic.go | 33 ++++++++++++ .../logic/course_file/getcoursefilelogic.go | 33 ++++++++++++ .../course_file/updatecoursefilelogic.go | 33 ++++++++++++ .../course_file/internal/types/types.go | 50 +++++++++++++++++++ 9 files changed, 306 insertions(+) create mode 100644 server/internal/course_file/handler/course_file/createcoursefilehandler.go create mode 100644 server/internal/course_file/handler/course_file/deletecoursefilehandler.go create mode 100644 server/internal/course_file/handler/course_file/getcoursefilehandler.go create mode 100644 server/internal/course_file/handler/course_file/updatecoursefilehandler.go create mode 100644 server/internal/course_file/internal/logic/course_file/createcoursefilelogic.go create mode 100644 server/internal/course_file/internal/logic/course_file/deletecoursefilelogic.go create mode 100644 server/internal/course_file/internal/logic/course_file/getcoursefilelogic.go create mode 100644 server/internal/course_file/internal/logic/course_file/updatecoursefilelogic.go create mode 100644 server/internal/course_file/internal/types/types.go diff --git a/server/internal/course_file/handler/course_file/createcoursefilehandler.go b/server/internal/course_file/handler/course_file/createcoursefilehandler.go new file mode 100644 index 00000000..9b5743ab --- /dev/null +++ b/server/internal/course_file/handler/course_file/createcoursefilehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.1 + +package course_file + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/logic/course_file" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func CreateCourseFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateCourseFileReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := course_file.NewCreateCourseFileLogic(r.Context(), svcCtx) + resp, err := l.CreateCourseFile(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/course_file/handler/course_file/deletecoursefilehandler.go b/server/internal/course_file/handler/course_file/deletecoursefilehandler.go new file mode 100644 index 00000000..24078e76 --- /dev/null +++ b/server/internal/course_file/handler/course_file/deletecoursefilehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.1 + +package course_file + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/logic/course_file" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func DeleteCourseFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteCourseFileReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := course_file.NewDeleteCourseFileLogic(r.Context(), svcCtx) + resp, err := l.DeleteCourseFile(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/course_file/handler/course_file/getcoursefilehandler.go b/server/internal/course_file/handler/course_file/getcoursefilehandler.go new file mode 100644 index 00000000..6a4def2f --- /dev/null +++ b/server/internal/course_file/handler/course_file/getcoursefilehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.1 + +package course_file + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/logic/course_file" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func GetCourseFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetCourseFileReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := course_file.NewGetCourseFileLogic(r.Context(), svcCtx) + resp, err := l.GetCourseFile(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/course_file/handler/course_file/updatecoursefilehandler.go b/server/internal/course_file/handler/course_file/updatecoursefilehandler.go new file mode 100644 index 00000000..dd1a3e59 --- /dev/null +++ b/server/internal/course_file/handler/course_file/updatecoursefilehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.1 + +package course_file + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/logic/course_file" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func UpdateCourseFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateCourseFileReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := course_file.NewUpdateCourseFileLogic(r.Context(), svcCtx) + resp, err := l.UpdateCourseFile(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/course_file/internal/logic/course_file/createcoursefilelogic.go b/server/internal/course_file/internal/logic/course_file/createcoursefilelogic.go new file mode 100644 index 00000000..008e188e --- /dev/null +++ b/server/internal/course_file/internal/logic/course_file/createcoursefilelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.1 + +package course_file + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateCourseFileLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateCourseFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateCourseFileLogic { + return &CreateCourseFileLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateCourseFileLogic) CreateCourseFile(req *types.CreateCourseFileReq) (resp *types.CreateCourseFileResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/course_file/internal/logic/course_file/deletecoursefilelogic.go b/server/internal/course_file/internal/logic/course_file/deletecoursefilelogic.go new file mode 100644 index 00000000..79c9c57c --- /dev/null +++ b/server/internal/course_file/internal/logic/course_file/deletecoursefilelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.1 + +package course_file + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteCourseFileLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteCourseFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteCourseFileLogic { + return &DeleteCourseFileLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteCourseFileLogic) DeleteCourseFile(req *types.DeleteCourseFileReq) (resp *types.DeleteCourseFileResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/course_file/internal/logic/course_file/getcoursefilelogic.go b/server/internal/course_file/internal/logic/course_file/getcoursefilelogic.go new file mode 100644 index 00000000..9f3c4af9 --- /dev/null +++ b/server/internal/course_file/internal/logic/course_file/getcoursefilelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.1 + +package course_file + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetCourseFileLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetCourseFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCourseFileLogic { + return &GetCourseFileLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetCourseFileLogic) GetCourseFile(req *types.GetCourseFileReq) (resp *types.GetCourseFileResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/course_file/internal/logic/course_file/updatecoursefilelogic.go b/server/internal/course_file/internal/logic/course_file/updatecoursefilelogic.go new file mode 100644 index 00000000..1e60e974 --- /dev/null +++ b/server/internal/course_file/internal/logic/course_file/updatecoursefilelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.1 + +package course_file + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/course_file/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateCourseFileLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateCourseFileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateCourseFileLogic { + return &UpdateCourseFileLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateCourseFileLogic) UpdateCourseFile(req *types.UpdateCourseFileReq) (resp *types.UpdateCourseFileResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/course_file/internal/types/types.go b/server/internal/course_file/internal/types/types.go new file mode 100644 index 00000000..df422583 --- /dev/null +++ b/server/internal/course_file/internal/types/types.go @@ -0,0 +1,50 @@ +// Code generated by goctl. DO NOT EDIT. +// goctl 1.9.1 + +package types + +type CreateCourseFileReq struct { + ContentId int `json:"content_id" form:"content_id" validate:"required"` // 关联的内容ID(必填) + Title string `json:"title" form:"title" validate:"required,max=255"` // 文件标题(必填,最长255字符) + FileType string `json:"file_type" form:"file_type" validate:"required,max=30"` // 文件类型(必填,最长30字符) + FileUrl string `json:"file_url" form:"file_url" validate:"required,max=255"` // 文件URL(必填,最长255字符) +} + +type CreateCourseFileResp struct { + Id int `json:"id"` // 新增文件的ID + Message string `json:"message"` // 操作结果信息 +} + +type DeleteCourseFileReq struct { + Id int `json:"id" form:"id" param:"id" validate:"required"` // 文件ID(必填,从路径参数获取) +} + +type DeleteCourseFileResp struct { + Message string `json:"message"` // 操作结果信息 +} + +type GetCourseFileReq struct { + Id int `json:"id" form:"id" param:"id" validate:"required"` // 文件ID(必填,从路径参数获取) +} + +type GetCourseFileResp struct { + Id int `json:"id"` // 文件ID + ContentId int `json:"content_id"` // 关联的内容ID + Title string `json:"title"` // 文件标题 + FileType string `json:"file_type"` // 文件类型 + FileUrl string `json:"file_url"` // 文件URL + CreateTime string `json:"create_time"` // 创建时间(格式化字符串) + UpdateTime string `json:"update_time"` // 更新时间(格式化字符串) +} + +type UpdateCourseFileReq struct { + Id int `json:"id" form:"id" validate:"required"` // 文件ID(必填) + ContentId int `json:"content_id" form:"content_id"` // 可选:更新关联的内容ID + Title string `json:"title" form:"title" validate:"omitempty,max=255"` // 可选:更新标题 + FileType string `json:"file_type" form:"file_type" validate:"omitempty,max=30"` // 可选:更新文件类型 + FileUrl string `json:"file_url" form:"file_url" validate:"omitempty,max=255"` // 可选:更新文件URL +} + +type UpdateCourseFileResp struct { + Message string `json:"message"` // 操作结果信息 +}