完成社会服务的增删改查

This commit is contained in:
2025-10-30 14:24:20 +08:00
parent 019c99238b
commit 9f566027dc
22 changed files with 867 additions and 76 deletions

View File

@@ -6,6 +6,8 @@ package socialService
import (
"fmt"
"net/http"
"strconv"
"strings"
"github.com/JACKYMYPERSON/hldrCenter/config"
"github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/logic/socialService"
@@ -18,10 +20,19 @@ import (
func DeleteSocialServiceHandler(cfg *config.Config) 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)
pathParts := strings.Split(r.URL.Path, "/")
if len(pathParts) < 3 { // 确保路径格式正确
httpx.ErrorCtx(r.Context(), w, fmt.Errorf("invalid path format"))
return
}
idStr := pathParts[3]
id, err := strconv.ParseInt(idStr, 10, 64)
if err != nil {
httpx.ErrorCtx(r.Context(), w, fmt.Errorf("invalid meeting ID"))
return
}
fmt.Println("idStr:", idStr)
req.Id = id
mysqlCfg := cfg.MySQL
dsn := fmt.Sprintf(

View File

@@ -6,6 +6,8 @@ package socialService
import (
"fmt"
"net/http"
"strconv"
"strings"
"github.com/JACKYMYPERSON/hldrCenter/config"
"github.com/JACKYMYPERSON/hldrCenter/internal/social_service/internal/logic/socialService"
@@ -18,10 +20,19 @@ import (
func GetSocialServiceHandler(cfg *config.Config) 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)
pathParts := strings.Split(r.URL.Path, "/")
if len(pathParts) < 3 { // 确保路径格式正确
httpx.ErrorCtx(r.Context(), w, fmt.Errorf("invalid path format"))
return
}
idStr := pathParts[3]
id, err := strconv.ParseInt(idStr, 10, 64)
if err != nil {
httpx.ErrorCtx(r.Context(), w, fmt.Errorf("invalid meeting ID"))
return
}
fmt.Println("idStr:", idStr)
req.Id = id
mysqlCfg := cfg.MySQL
dsn := fmt.Sprintf(

View File

@@ -56,8 +56,8 @@ type ListSocialServiceData struct {
}
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
Page int `json:"page" validate:"min=1"` // 页码默认1
PageSize int `json:"page_size" validate:"min=1,max=100"` // 每页条数默认10最大100
}
type ListSocialServiceResp struct {
@@ -83,17 +83,17 @@ type SocialService struct {
}
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"` // 审核者名单(逗号分隔)
Id int64 `json:"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 {