Refactor: Remove deprecated gRPC service files and implement new API structure

- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`.
- Added new API server implementations for objectstory, player, and shop services.
- Introduced configuration files for new APIs in `etc/*.yaml`.
- Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`.
- Removed unused user update handler and user API files.
- Added utility functions for context management and HTTP header parsing.
- Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
This commit is contained in:
wwweww
2026-02-28 18:35:56 +08:00
parent d2f33b4b96
commit 19cc7a778c
349 changed files with 42548 additions and 1453 deletions
@@ -0,0 +1,37 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 发表评论
func CreateCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
types.PathId
types.CreateCommentReq
}
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
req.CreateCommentReq.PostId = req.PathId.Id
l := community.NewCreateCommentLogic(r.Context(), svcCtx)
resp, err := l.CreateComment(&req.CreateCommentReq)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 发布帖子
func CreatePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreatePostReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewCreatePostLogic(r.Context(), svcCtx)
resp, err := l.CreatePost(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 获取帖子详情
func GetPostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PathId
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewGetPostLogic(r.Context(), svcCtx)
resp, err := l.GetPost(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 点赞评论
func LikeCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PathId
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewLikeCommentLogic(r.Context(), svcCtx)
resp, err := l.LikeComment(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 点赞帖子
func LikePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PathId
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewLikePostLogic(r.Context(), svcCtx)
resp, err := l.LikePost(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 获取帖子评论
func ListCommentsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListCommentsReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewListCommentsLogic(r.Context(), svcCtx)
resp, err := l.ListComments(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 获取帖子列表
func ListPostsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PostListReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewListPostsLogic(r.Context(), svcCtx)
resp, err := l.ListPosts(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 获取用户帖子
func ListUserPostsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListCommentsReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewListUserPostsLogic(r.Context(), svcCtx)
resp, err := l.ListUserPosts(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 置顶帖子
func PinPostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PathId
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewPinPostLogic(r.Context(), svcCtx)
resp, err := l.PinPost(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 取消点赞评论
func UnlikeCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PathId
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewUnlikeCommentLogic(r.Context(), svcCtx)
resp, err := l.UnlikeComment(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 取消点赞帖子
func UnlikePostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PathId
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewUnlikePostLogic(r.Context(), svcCtx)
resp, err := l.UnlikePost(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,32 @@
// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package community
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/community/api/internal/logic/community"
"juwan-backend/app/community/api/internal/svc"
"juwan-backend/app/community/api/internal/types"
)
// 取消置顶
func UnpinPostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PathId
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := community.NewUnpinPostLogic(r.Context(), svcCtx)
resp, err := l.UnpinPost(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
@@ -0,0 +1,99 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.9.2
package handler
import (
"net/http"
community "juwan-backend/app/community/api/internal/handler/community"
"juwan-backend/app/community/api/internal/svc"
"github.com/zeromicro/go-zero/rest"
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{
// 获取帖子列表
Method: http.MethodGet,
Path: "/posts",
Handler: community.ListPostsHandler(serverCtx),
},
{
// 获取帖子详情
Method: http.MethodGet,
Path: "/posts/:id",
Handler: community.GetPostHandler(serverCtx),
},
{
// 获取帖子评论
Method: http.MethodGet,
Path: "/posts/:id/comments",
Handler: community.ListCommentsHandler(serverCtx),
},
{
// 获取用户帖子
Method: http.MethodGet,
Path: "/users/:id/posts",
Handler: community.ListUserPostsHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1"),
)
server.AddRoutes(
[]rest.Route{
{
// 点赞评论
Method: http.MethodPost,
Path: "/comments/:id/like",
Handler: community.LikeCommentHandler(serverCtx),
},
{
// 取消点赞评论
Method: http.MethodDelete,
Path: "/comments/:id/like",
Handler: community.UnlikeCommentHandler(serverCtx),
},
{
// 发布帖子
Method: http.MethodPost,
Path: "/posts",
Handler: community.CreatePostHandler(serverCtx),
},
{
// 发表评论
Method: http.MethodPost,
Path: "/posts/:id/comments",
Handler: community.CreateCommentHandler(serverCtx),
},
{
// 点赞帖子
Method: http.MethodPost,
Path: "/posts/:id/like",
Handler: community.LikePostHandler(serverCtx),
},
{
// 取消点赞帖子
Method: http.MethodDelete,
Path: "/posts/:id/like",
Handler: community.UnlikePostHandler(serverCtx),
},
{
// 置顶帖子
Method: http.MethodPost,
Path: "/posts/:id/pin",
Handler: community.PinPostHandler(serverCtx),
},
{
// 取消置顶
Method: http.MethodDelete,
Path: "/posts/:id/pin",
Handler: community.UnpinPostHandler(serverCtx),
},
},
rest.WithPrefix("/api/v1"),
)
}