19cc7a778c
- 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`.
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"juwan-backend/app/wallet/rpc/internal/models"
|
|
"juwan-backend/app/wallet/rpc/internal/models/wallet"
|
|
"juwan-backend/app/wallet/rpc/internal/svc"
|
|
"juwan-backend/app/wallet/rpc/pb"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetWalletsByIdLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetWalletsByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWalletsByIdLogic {
|
|
return &GetWalletsByIdLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetWalletsByIdLogic) GetWalletsById(in *pb.GetWalletsByIdReq) (*pb.GetWalletsByIdResp, error) {
|
|
item, err := l.svcCtx.WalletModelsRO.Wallet.Query().
|
|
Where(wallet.UserIDEQ(in.Id)).
|
|
First(l.ctx)
|
|
if err != nil {
|
|
if models.IsNotFound(err) {
|
|
return &pb.GetWalletsByIdResp{}, nil
|
|
}
|
|
return nil, err
|
|
}
|
|
|
|
updatedAt := int64(0)
|
|
if !item.UpdatedAt.IsZero() {
|
|
updatedAt = item.UpdatedAt.Unix()
|
|
}
|
|
|
|
return &pb.GetWalletsByIdResp{
|
|
Wallets: &pb.Wallets{
|
|
UserId: item.UserID,
|
|
Balance: item.Balance.String(),
|
|
FrozenBalance: item.FrozenBalance.String(),
|
|
UpdatedAt: updatedAt,
|
|
Version: int64(item.Version),
|
|
},
|
|
}, nil
|
|
}
|