完成课程文件handler
This commit is contained in:
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
50
server/internal/course_file/internal/types/types.go
Normal file
50
server/internal/course_file/internal/types/types.go
Normal file
@@ -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"` // 操作结果信息
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user