Add Balance Api
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package balance
|
||||
|
||||
import (
|
||||
"context"
|
||||
"furtuna-be/internal/common/logger"
|
||||
"furtuna-be/internal/entity"
|
||||
"furtuna-be/internal/repository"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type BalanceService struct {
|
||||
repo repository.WalletRepository
|
||||
}
|
||||
|
||||
func NewBalanceService(repo repository.WalletRepository) *BalanceService {
|
||||
return &BalanceService{
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *BalanceService) GetByID(ctx context.Context, id int64) (*entity.Balance, error) {
|
||||
balanceDB, err := s.repo.GetByPartnerID(ctx, nil, id)
|
||||
if err != nil {
|
||||
logger.ContextLogger(ctx).Error("error when get branch by id", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &entity.Balance{
|
||||
PartnerID: id,
|
||||
Balance: balanceDB.Balance,
|
||||
AuthBalance: balanceDB.AuthBalance,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user