完成社会服务业务层

This commit is contained in:
2025-10-29 11:33:13 +08:00
parent 8c4208a2f0
commit a48a800d02
12 changed files with 468 additions and 0 deletions

View File

@@ -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"),
)
}

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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"`
}