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:
@@ -27,16 +27,16 @@ func NewGetGameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGameLo
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetGameLogic) GetGame(req *types.GetGameReq) (resp *types.Game) {
|
||||
func (l *GetGameLogic) GetGame(req *types.GetGameReq) (resp *types.Game, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
game, err := l.svcCtx.GameRpc.GetGamesById(l.ctx, &pb.GetGamesByIdReq{Id: req.Id})
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
return &types.Game{
|
||||
Id: game.Games.Id,
|
||||
Name: game.Games.Name,
|
||||
Icon: game.Games.Icon,
|
||||
Category: game.Games.Category,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ package game
|
||||
|
||||
import (
|
||||
"context"
|
||||
"juwan-backend/app/game/rpc/pb"
|
||||
|
||||
"juwan-backend/app/game/api/internal/svc"
|
||||
"juwan-backend/app/game/api/internal/types"
|
||||
@@ -29,6 +30,30 @@ func NewListGamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListGam
|
||||
|
||||
func (l *ListGamesLogic) ListGames(req *types.PageReq) (resp *types.GameListResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
all, err := l.svcCtx.GameRpc.SearchGames(l.ctx, &pb.SearchGamesReq{
|
||||
Page: req.Offset,
|
||||
Limit: req.Limit,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := make([]types.Game, 0, len(all.Games))
|
||||
for _, v := range all.Games {
|
||||
list = append(list, types.Game{
|
||||
Id: v.Id,
|
||||
Name: v.Name,
|
||||
Icon: v.Icon,
|
||||
Category: v.Category,
|
||||
})
|
||||
}
|
||||
return &types.GameListResp{
|
||||
Items: list,
|
||||
Meta: types.PageMeta{
|
||||
Total: 0,
|
||||
Offset: req.Offset + 1,
|
||||
Limit: 20,
|
||||
},
|
||||
}, nil
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user