diff --git a/server/internal/social_service/handler/routes.go b/server/internal/social_service/handler/routes.go new file mode 100644 index 00000000..637cac0a --- /dev/null +++ b/server/internal/social_service/handler/routes.go @@ -0,0 +1,46 @@ +// Code generated by goctl. DO NOT EDIT. +// goctl 1.9.2 + +package handler + +import ( + "net/http" + + socialService2 "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/handler/socialService" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + + "github.com/zeromicro/go-zero/rest" +) + +func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodPost, + Path: "/", + Handler: socialService2.CreateSocialServiceHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/:id", + Handler: socialService2.GetSocialServiceHandler(serverCtx), + }, + { + Method: http.MethodPut, + Path: "/:id", + Handler: socialService2.UpdateSocialServiceHandler(serverCtx), + }, + { + Method: http.MethodDelete, + Path: "/:id", + Handler: socialService2.DeleteSocialServiceHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/list", + Handler: socialService2.ListSocialServiceHandler(serverCtx), + }, + }, + rest.WithPrefix("/api/social-service"), + ) +} diff --git a/server/internal/social_service/handler/socialService/createsocialservicehandler.go b/server/internal/social_service/handler/socialService/createsocialservicehandler.go new file mode 100644 index 00000000..e4568ccf --- /dev/null +++ b/server/internal/social_service/handler/socialService/createsocialservicehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/logic/socialService" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func CreateSocialServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CreateSocialServiceReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := socialService.NewCreateSocialServiceLogic(r.Context(), svcCtx) + resp, err := l.CreateSocialService(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/social_service/handler/socialService/deletesocialservicehandler.go b/server/internal/social_service/handler/socialService/deletesocialservicehandler.go new file mode 100644 index 00000000..c611aaf7 --- /dev/null +++ b/server/internal/social_service/handler/socialService/deletesocialservicehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/logic/socialService" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func DeleteSocialServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.DeleteSocialServiceReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := socialService.NewDeleteSocialServiceLogic(r.Context(), svcCtx) + resp, err := l.DeleteSocialService(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/social_service/handler/socialService/getsocialservicehandler.go b/server/internal/social_service/handler/socialService/getsocialservicehandler.go new file mode 100644 index 00000000..3b773cc7 --- /dev/null +++ b/server/internal/social_service/handler/socialService/getsocialservicehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/logic/socialService" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func GetSocialServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.GetSocialServiceReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := socialService.NewGetSocialServiceLogic(r.Context(), svcCtx) + resp, err := l.GetSocialService(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/social_service/handler/socialService/listsocialservicehandler.go b/server/internal/social_service/handler/socialService/listsocialservicehandler.go new file mode 100644 index 00000000..68d3d3e8 --- /dev/null +++ b/server/internal/social_service/handler/socialService/listsocialservicehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/logic/socialService" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func ListSocialServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.ListSocialServiceReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := socialService.NewListSocialServiceLogic(r.Context(), svcCtx) + resp, err := l.ListSocialService(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/social_service/handler/socialService/updatesocialservicehandler.go b/server/internal/social_service/handler/socialService/updatesocialservicehandler.go new file mode 100644 index 00000000..4abb8fd2 --- /dev/null +++ b/server/internal/social_service/handler/socialService/updatesocialservicehandler.go @@ -0,0 +1,31 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "net/http" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/logic/socialService" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func UpdateSocialServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.UpdateSocialServiceReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := socialService.NewUpdateSocialServiceLogic(r.Context(), svcCtx) + resp, err := l.UpdateSocialService(&req) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/server/internal/social_service/internal/logic/socialService/createsocialservicelogic.go b/server/internal/social_service/internal/logic/socialService/createsocialservicelogic.go new file mode 100644 index 00000000..1bf56b65 --- /dev/null +++ b/server/internal/social_service/internal/logic/socialService/createsocialservicelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type CreateSocialServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewCreateSocialServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateSocialServiceLogic { + return &CreateSocialServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *CreateSocialServiceLogic) CreateSocialService(req *types.CreateSocialServiceReq) (resp *types.CreateSocialServiceResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/social_service/internal/logic/socialService/deletesocialservicelogic.go b/server/internal/social_service/internal/logic/socialService/deletesocialservicelogic.go new file mode 100644 index 00000000..a4434c3f --- /dev/null +++ b/server/internal/social_service/internal/logic/socialService/deletesocialservicelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DeleteSocialServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDeleteSocialServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSocialServiceLogic { + return &DeleteSocialServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DeleteSocialServiceLogic) DeleteSocialService(req *types.DeleteSocialServiceReq) (resp *types.DeleteSocialServiceResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/social_service/internal/logic/socialService/getsocialservicelogic.go b/server/internal/social_service/internal/logic/socialService/getsocialservicelogic.go new file mode 100644 index 00000000..362d67df --- /dev/null +++ b/server/internal/social_service/internal/logic/socialService/getsocialservicelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetSocialServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetSocialServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSocialServiceLogic { + return &GetSocialServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetSocialServiceLogic) GetSocialService(req *types.GetSocialServiceReq) (resp *types.GetSocialServiceResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/social_service/internal/logic/socialService/listsocialservicelogic.go b/server/internal/social_service/internal/logic/socialService/listsocialservicelogic.go new file mode 100644 index 00000000..8e1b93dd --- /dev/null +++ b/server/internal/social_service/internal/logic/socialService/listsocialservicelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ListSocialServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewListSocialServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSocialServiceLogic { + return &ListSocialServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *ListSocialServiceLogic) ListSocialService(req *types.ListSocialServiceReq) (resp *types.ListSocialServiceResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/social_service/internal/logic/socialService/updatesocialservicelogic.go b/server/internal/social_service/internal/logic/socialService/updatesocialservicelogic.go new file mode 100644 index 00000000..eb4e7edf --- /dev/null +++ b/server/internal/social_service/internal/logic/socialService/updatesocialservicelogic.go @@ -0,0 +1,33 @@ +// Code scaffolded by goctl. Safe to edit. +// goctl 1.9.2 + +package socialService + +import ( + "context" + + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/svc" + "github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UpdateSocialServiceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUpdateSocialServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateSocialServiceLogic { + return &UpdateSocialServiceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UpdateSocialServiceLogic) UpdateSocialService(req *types.UpdateSocialServiceReq) (resp *types.UpdateSocialServiceResp, err error) { + // todo: add your logic here and delete this line + + return +} diff --git a/server/internal/social_service/internal/types/types.go b/server/internal/social_service/internal/types/types.go new file mode 100644 index 00000000..7ebfe66a --- /dev/null +++ b/server/internal/social_service/internal/types/types.go @@ -0,0 +1,102 @@ +// 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:"message"` // 提示信息 +} + +type CreateSocialServiceData struct { + Id int64 `json:"id"` // 新增记录的ID +} + +type CreateSocialServiceReq struct { + Title string `json:"title" validate:"required"` // 标题(必填) + Subtitle string `json:"subtitle,omitempty"` // 副标题 + CoverUrl string `json:"cover_url,omitempty"` // 封面图片URL + Intro string `json:"intro,omitempty"` // 简介(纯文字) + Content string `json:"content,omitempty"` // 内容(Markdown格式) + ImageEditors string `json:"image_editors,omitempty"` // 图片编辑者名单(逗号分隔) + TextEditors string `json:"text_editors,omitempty"` // 文字编辑者名单(逗号分隔) + ChiefEditor string `json:"chief_editor,omitempty"` // 总编辑 + Proofreaders string `json:"proofreaders,omitempty"` // 校对者名单(逗号分隔) + Reviewers string `json:"reviewers,omitempty"` // 审核者名单(逗号分隔) +} + +type CreateSocialServiceResp struct { + Code int `json:"code"` + Msg string `json:"message"` + Data CreateSocialServiceData `json:"data,omitempty"` +} + +type DeleteSocialServiceReq struct { + Id int64 `json:"id" path:"id" validate:"min=1"` // 社会服务ID(必填) +} + +type DeleteSocialServiceResp struct { + Code int `json:"code"` + Msg string `json:"message"` +} + +type GetSocialServiceReq struct { + Id int64 `json:"id" path:"id" validate:"min=1"` // 社会服务ID(必填) +} + +type GetSocialServiceResp struct { + Code int `json:"code"` + Msg string `json:"message"` + Data SocialService `json:"data,omitempty"` +} + +type ListSocialServiceData struct { + Total int64 `json:"total"` // 总条数 + List []SocialService `json:"list"` // 列表数据 +} + +type ListSocialServiceReq struct { + Page int `json:"page" form:"page" validate:"min=1"` // 页码(默认1) + PageSize int `json:"page_size" form:"page_size" validate:"min=1,max=100"` // 每页条数(默认10,最大100) +} + +type ListSocialServiceResp struct { + Code int `json:"code"` + Msg string `json:"message"` + Data ListSocialServiceData `json:"data,omitempty"` +} + +type SocialService struct { + Id int64 `json:"id"` // 主键ID + Title string `json:"title"` // 标题 + Subtitle string `json:"subtitle,omitempty"` // 副标题 + CoverUrl string `json:"cover_url,omitempty"` // 封面图片URL + Intro string `json:"intro,omitempty"` // 简介(纯文字) + Content string `json:"content,omitempty"` // 内容(Markdown格式) + ImageEditors string `json:"image_editors,omitempty"` // 图片编辑者名单(逗号分隔) + TextEditors string `json:"text_editors,omitempty"` // 文字编辑者名单(逗号分隔) + ChiefEditor string `json:"chief_editor,omitempty"` // 总编辑 + Proofreaders string `json:"proofreaders,omitempty"` // 校对者名单(逗号分隔) + Reviewers string `json:"reviewers,omitempty"` // 审核者名单(逗号分隔) + PublishTime string `json:"publish_time"` // 发布时间(格式:yyyy-MM-dd HH:mm:ss) + UpdateTime string `json:"update_time"` // 最后更改时间(格式:yyyy-MM-dd HH:mm:ss) +} + +type UpdateSocialServiceReq struct { + Id int64 `json:"-" path:"id" validate:"min=1"` // 社会服务ID(路径参数,必填) + Title string `json:"title,omitempty"` // 标题 + Subtitle string `json:"subtitle,omitempty"` // 副标题 + CoverUrl string `json:"cover_url,omitempty"` // 封面图片URL + Intro string `json:"intro,omitempty"` // 简介(纯文字) + Content string `json:"content,omitempty"` // 内容(Markdown格式) + ImageEditors string `json:"image_editors,omitempty"` // 图片编辑者名单(逗号分隔) + TextEditors string `json:"text_editors,omitempty"` // 文字编辑者名单(逗号分隔) + ChiefEditor string `json:"chief_editor,omitempty"` // 总编辑 + Proofreaders string `json:"proofreaders,omitempty"` // 校对者名单(逗号分隔) + Reviewers string `json:"reviewers,omitempty"` // 审核者名单(逗号分隔) +} + +type UpdateSocialServiceResp struct { + Code int `json:"code"` + Msg string `json:"message"` +}