完成社会服务的增删改查

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(