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:
@@ -3,7 +3,7 @@ package logic
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"juwan-backend/app/shop/rpc/internal/models"
|
||||
"juwan-backend/app/shop/rpc/internal/models/predicate"
|
||||
"juwan-backend/app/shop/rpc/internal/models/shopplayers"
|
||||
"time"
|
||||
|
||||
@@ -28,5 +28,32 @@ func NewUpdateShopPlayersLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||
}
|
||||
|
||||
func (l *UpdateShopPlayersLogic) UpdateShopPlayers(in *pb.UpdateShopPlayersReq) (*pb.UpdateShopPlayersResp, error) {
|
||||
if in.ShopId <= 0 || in.PlayerId <= 0 {
|
||||
return nil, errors.New("invalid shop_id or player_id")
|
||||
}
|
||||
|
||||
preds := []predicate.ShopPlayers{
|
||||
shopplayers.ShopIDEQ(in.ShopId),
|
||||
shopplayers.PlayerIDEQ(in.PlayerId),
|
||||
}
|
||||
|
||||
updater := l.svcCtx.ShopModelRW.ShopPlayers.Update().
|
||||
Where(shopplayers.And(preds...)).
|
||||
SetIsPrimary(in.IsPrimary)
|
||||
|
||||
if in.LeftAt > 0 {
|
||||
t := time.Unix(in.LeftAt, 0)
|
||||
updater = updater.SetLeftAt(t)
|
||||
}
|
||||
|
||||
affected, err := updater.Save(l.ctx)
|
||||
if err != nil {
|
||||
logx.Errorf("update shop players failed, %s", err.Error())
|
||||
return nil, errors.New("update shop players failed")
|
||||
}
|
||||
if affected == 0 {
|
||||
return nil, errors.New("shop player not found")
|
||||
}
|
||||
|
||||
return &pb.UpdateShopPlayersResp{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user