完成课程活动Handler

This commit is contained in:
2025-11-01 23:32:29 +08:00
parent e7e4e6c155
commit 5ce00b0e1c
11 changed files with 391 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"net/http"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func CreateCourseActivityHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreateCourseActivityReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := course_activity.NewCreateCourseActivityLogic(r.Context(), svcCtx)
resp, err := l.CreateCourseActivity(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,31 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"net/http"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func DeleteCourseActivityHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DeleteCourseActivityReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := course_activity.NewDeleteCourseActivityLogic(r.Context(), svcCtx)
resp, err := l.DeleteCourseActivity(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,31 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"net/http"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func GetCourseActivityHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetCourseActivityReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := course_activity.NewGetCourseActivityLogic(r.Context(), svcCtx)
resp, err := l.GetCourseActivity(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,31 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"net/http"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func ListCourseActivityHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListCourseActivityReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := course_activity.NewListCourseActivityLogic(r.Context(), svcCtx)
resp, err := l.ListCourseActivity(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,31 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"net/http"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/logic/course_activity"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func UpdateCourseActivityHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.UpdateCourseActivityReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := course_activity.NewUpdateCourseActivityLogic(r.Context(), svcCtx)
resp, err := l.UpdateCourseActivity(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,33 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"context"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateCourseActivityLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreateCourseActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateCourseActivityLogic {
return &CreateCourseActivityLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateCourseActivityLogic) CreateCourseActivity(req *types.CreateCourseActivityReq) (resp *types.CreateCourseActivityResp, err error) {
// todo: add your logic here and delete this line
return
}

View File

@@ -0,0 +1,33 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"context"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteCourseActivityLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDeleteCourseActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteCourseActivityLogic {
return &DeleteCourseActivityLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *DeleteCourseActivityLogic) DeleteCourseActivity(req *types.DeleteCourseActivityReq) (resp *types.DeleteCourseActivityResp, err error) {
// todo: add your logic here and delete this line
return
}

View File

@@ -0,0 +1,33 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"context"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetCourseActivityLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetCourseActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCourseActivityLogic {
return &GetCourseActivityLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetCourseActivityLogic) GetCourseActivity(req *types.GetCourseActivityReq) (resp *types.GetCourseActivityResp, err error) {
// todo: add your logic here and delete this line
return
}

View File

@@ -0,0 +1,33 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"context"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type ListCourseActivityLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewListCourseActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListCourseActivityLogic {
return &ListCourseActivityLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ListCourseActivityLogic) ListCourseActivity(req *types.ListCourseActivityReq) (resp *types.ListCourseActivityResp, err error) {
// todo: add your logic here and delete this line
return
}

View File

@@ -0,0 +1,33 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.1
package course_activity
import (
"context"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/svc"
"github.com/JACKYMYPERSON/hldrCenter/internal/course_activity/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateCourseActivityLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUpdateCourseActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateCourseActivityLogic {
return &UpdateCourseActivityLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *UpdateCourseActivityLogic) UpdateCourseActivity(req *types.UpdateCourseActivityReq) (resp *types.UpdateCourseActivityResp, err error) {
// todo: add your logic here and delete this line
return
}

View File

@@ -0,0 +1,71 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.1
package types
type CreateCourseActivityReq struct {
CourseId int `json:"course_id" form:"course_id" validate:"required"` // 关联课程ID必填外键
Title string `json:"title" form:"title" validate:"required,max=255"` // 活动标题必填最长255字符
ActivityType int `json:"activity_type" form:"activity_type" validate:"omitempty,min=1,max=4"` // 活动类型可选1-作业/2-考试/3-讨论/4-直播默认1
Content string `json:"content" form:"content"` // 活动详情(可选,文本)
StartTime string `json:"start_time" form:"start_time" validate:"omitempty,datetime=2006-01-02 15:04:05"` // 开始时间可选格式yyyy-MM-dd HH:mm:ss
EndTime string `json:"end_time" form:"end_time" validate:"omitempty,datetime=2006-01-02 15:04:05"` // 结束时间(可选,格式同上)
Sort int `json:"sort" form:"sort" validate:"omitempty,min=0"` // 排序可选默认0
}
type CreateCourseActivityResp struct {
Id int `json:"id"` // 新增活动的ID
Message string `json:"message"` // 操作结果信息
}
type DeleteCourseActivityReq struct {
Id int `json:"id" form:"id" param:"id" validate:"required"` // 活动ID必填从路径参数获取
}
type DeleteCourseActivityResp struct {
Message string `json:"message"` // 操作结果信息
}
type GetCourseActivityReq struct {
Id int `json:"id" form:"id" param:"id" validate:"required"` // 活动ID必填从路径参数获取
}
type GetCourseActivityResp struct {
Id int `json:"id"` // 活动ID
CourseId int `json:"course_id"` // 关联课程ID
Title string `json:"title"` // 活动标题
ActivityType int `json:"activity_type"` // 活动类型1-作业/2-考试/3-讨论/4-直播)
Content string `json:"content"` // 活动详情
StartTime string `json:"start_time"` // 开始时间(格式化字符串)
EndTime string `json:"end_time"` // 结束时间(格式化字符串)
Sort int `json:"sort"` // 排序
}
type ListCourseActivityReq struct {
CourseId int `json:"course_id" form:"course_id" validate:"omitempty"` // 可选筛选按课程ID查询
ActivityType int `json:"activity_type" form:"activity_type" validate:"omitempty,min=1,max=4"` // 可选筛选:按活动类型查询
Page int `json:"page" form:"page" validate:"required,min=1"` // 页码必填从1开始
PageSize int `json:"page_size" form:"page_size" validate:"required,min=1,max=100"` // 每页条数必填1-100
}
type ListCourseActivityResp struct {
Total int `json:"total"` // 总条数
List []GetCourseActivityResp `json:"list"` // 活动列表(单条结构同查询单个响应)
Page int `json:"page"` // 当前页码
PageSize int `json:"page_size"` // 每页条数
}
type UpdateCourseActivityReq struct {
Id int `json:"id" form:"id" validate:"required"` // 活动ID必填
CourseId int `json:"course_id" form:"course_id" validate:"omitempty"` // 可选更新关联课程ID
Title string `json:"title" form:"title" validate:"omitempty,max=255"` // 可选更新:活动标题
ActivityType int `json:"activity_type" form:"activity_type" validate:"omitempty,min=1,max=4"` // 可选更新:活动类型
Content string `json:"content" form:"content"` // 可选更新:活动详情
StartTime string `json:"start_time" form:"start_time" validate:"omitempty,datetime=2006-01-02 15:04:05"` // 可选更新:开始时间
EndTime string `json:"end_time" form:"end_time" validate:"omitempty,datetime=2006-01-02 15:04:05"` // 可选更新:结束时间
Sort int `json:"sort" form:"sort" validate:"omitempty,min=0"` // 可选更新:排序
}
type UpdateCourseActivityResp struct {
Message string `json:"message"` // 操作结果信息
}