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:
@@ -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"),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user