Atlas Gaming Fixes
This commit is contained in:
parent
fc69ca3f52
commit
e0e4ff4b64
|
|
@ -52,7 +52,6 @@ func (c *Client) generateHash(body []byte, timestamp string) string {
|
|||
func (c *Client) post(ctx context.Context, path string, body map[string]any, result any) error {
|
||||
// Add timestamp first
|
||||
timestamp := nowTimestamp()
|
||||
body["timestamp"] = timestamp
|
||||
|
||||
// Marshal without hash first
|
||||
tmp, _ := json.Marshal(body)
|
||||
|
|
@ -61,12 +60,14 @@ func (c *Client) post(ctx context.Context, path string, body map[string]any, res
|
|||
hash := c.generateHash(tmp, timestamp)
|
||||
body["hash"] = hash
|
||||
|
||||
body["timestamp"] = timestamp
|
||||
|
||||
fmt.Printf("atlasPost: %v \n", body)
|
||||
// Marshal final body
|
||||
data, _ := json.Marshal(body)
|
||||
|
||||
req, _ := http.NewRequestWithContext(ctx, "POST", c.BaseURL+path, bytes.NewReader(data))
|
||||
req.Header.Set("Content-Type", "text/javascript")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
// Debug
|
||||
fmt.Println("Request URL:", c.BaseURL+path)
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ func (h *Handler) GetFixturesWithPreodds(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// Helper: parse comma-separated string into []int
|
||||
func parseIntSlice(input string) []int {
|
||||
func ParseIntSlice(input string) []int {
|
||||
if input == "" {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -250,7 +250,7 @@ func parseIntSlice(input string) []int {
|
|||
}
|
||||
|
||||
// Helper: convert []int to []int64
|
||||
func intSliceToInt64Slice(input []int) []int64 {
|
||||
func IntSliceToInt64Slice(input []int) []int64 {
|
||||
if input == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package handlers
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
// "fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
||||
|
|
@ -120,13 +120,14 @@ func (h *Handler) GetGamesByProvider(c *fiber.Ctx) error {
|
|||
// @Failure 502 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/veli/start-game [post]
|
||||
func (h *Handler) StartGame(c *fiber.Ctx) error {
|
||||
userId, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(domain.ErrorResponse{
|
||||
Error: "missing user id",
|
||||
Message: "Unauthorized",
|
||||
})
|
||||
}
|
||||
// userId, ok := c.Locals("user_id").(int64)
|
||||
// fmt.Printf("\n\nVeli Start Game User ID is %v\n\n", userId)
|
||||
// if !ok {
|
||||
// return c.Status(fiber.StatusUnauthorized).JSON(domain.ErrorResponse{
|
||||
// Error: "missing user id",
|
||||
// Message: "Unauthorized",
|
||||
// })
|
||||
// }
|
||||
|
||||
var req domain.GameStartRequest
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -135,11 +136,11 @@ func (h *Handler) StartGame(c *fiber.Ctx) error {
|
|||
Error: err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// There needs to be a way to generate a sessionID
|
||||
|
||||
|
||||
// Attach user ID to request
|
||||
req.PlayerID = fmt.Sprintf("%d", userId)
|
||||
// req.PlayerID = fmt.Sprintf("%d", userId)
|
||||
|
||||
// Default brand if not provided
|
||||
if req.BrandID == "" {
|
||||
|
|
|
|||
|
|
@ -264,6 +264,14 @@ func (h *Handler) HandlePlayerInfo(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
func (h *Handler) HandleBet(c *fiber.Ctx) error {
|
||||
// userID := c.Locals("user_id")
|
||||
// fmt.Printf("\n\nBet User ID is%v\n\n",userID)
|
||||
// if userID == "" {
|
||||
// return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
||||
// Message: "Failed to process Bet request",
|
||||
// Error: "Invalid user identification",
|
||||
// })
|
||||
// }
|
||||
// Read the raw body
|
||||
body := c.Body()
|
||||
if len(body) == 0 {
|
||||
|
|
@ -292,6 +300,8 @@ func (h *Handler) HandleBet(c *fiber.Ctx) error {
|
|||
})
|
||||
}
|
||||
|
||||
// req.PlayerID = fmt.Sprintf("%v", userID)
|
||||
|
||||
res, err := h.veliVirtualGameSvc.ProcessBet(c.Context(), req)
|
||||
if err != nil {
|
||||
if errors.Is(err, veli.ErrDuplicateTransaction) {
|
||||
|
|
@ -316,6 +326,8 @@ func (h *Handler) HandleBet(c *fiber.Ctx) error {
|
|||
})
|
||||
}
|
||||
|
||||
// req.PlayerID = fmt.Sprintf("%v", userID)
|
||||
|
||||
resp, err := h.virtualGameSvc.ProcessBet(c.Context(), &req)
|
||||
if err != nil {
|
||||
code := fiber.StatusInternalServerError
|
||||
|
|
@ -341,6 +353,8 @@ func (h *Handler) HandleBet(c *fiber.Ctx) error {
|
|||
})
|
||||
}
|
||||
|
||||
// req.PlayerID = fmt.Sprintf("%v", userID)
|
||||
|
||||
resp, err := h.atlasVirtualGameSvc.ProcessBet(c.Context(), req)
|
||||
if err != nil {
|
||||
// code := fiber.StatusInternalServerError
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ func (a *App) initAppRoutes() {
|
|||
tenant.Get("/events/:id/bets", a.authMiddleware, a.CompanyOnly, h.GetTenantBetsByEventID)
|
||||
|
||||
//EnetPulse
|
||||
groupV1.Get("/odds/pre-match", h.GetPreMatchOdds)
|
||||
// groupV1.Get("/odds/pre-match", h.GetPreMatchOdds)
|
||||
groupV1.Get("/sports", h.GetAllSports)
|
||||
groupV1.Get("/tournament_templates", h.GetAllTournamentTemplates)
|
||||
groupV1.Get("/tournaments", h.GetAllTournaments)
|
||||
|
|
@ -400,7 +400,7 @@ func (a *App) initAppRoutes() {
|
|||
//Veli Virtual Game Routes
|
||||
groupV1.Post("/veli/providers", h.GetProviders)
|
||||
groupV1.Post("/veli/games-list", h.GetGamesByProvider)
|
||||
groupV1.Post("/veli/start-game", a.authMiddleware, h.StartGame)
|
||||
groupV1.Post("/veli/start-game", h.StartGame)
|
||||
groupV1.Post("/veli/start-demo-game", h.StartDemoGame)
|
||||
a.fiber.Post("/balance", h.GetBalance)
|
||||
groupV1.Post("/veli/gaming-activity", a.authMiddleware, h.GetGamingActivity)
|
||||
|
|
@ -408,7 +408,7 @@ func (a *App) initAppRoutes() {
|
|||
groupV1.Post("/veli/credit-balances", a.authMiddleware, h.GetCreditBalances)
|
||||
|
||||
//Atlas Virtual Game Routes
|
||||
groupV1.Get("/atlas/games", a.authMiddleware, h.InitAtlasGame)
|
||||
groupV1.Get("/atlas/games", h.GetAtlasVGames)
|
||||
groupV1.Post("/atlas/init-game", a.authMiddleware, h.InitAtlasGame)
|
||||
a.fiber.Post("/account", h.AtlasGetUserDataCallback)
|
||||
a.fiber.Post("/betwin", h.HandleAtlasBetWin)
|
||||
|
|
|
|||
20
makefile
20
makefile
|
|
@ -46,45 +46,45 @@ postgres:
|
|||
.PHONY: backup
|
||||
backup:
|
||||
@mkdir -p backup
|
||||
@docker exec -t fortunebet-backend-postgres-1 pg_dump -U root --data-only --exclude-table=schema_migrations gh | gzip > backup/dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql.gz
|
||||
@docker exec -t fortunebet-postgres-1 pg_dump -U root --data-only --exclude-table=schema_migrations gh | gzip > backup/dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql.gz
|
||||
|
||||
restore:
|
||||
@echo "Restoring latest backup..."
|
||||
@latest_file=$$(ls -t backup/dump_*.sql.gz | head -n 1); \
|
||||
echo "Restoring from $$latest_file"; \
|
||||
gunzip -c $$latest_file | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh
|
||||
gunzip -c $$latest_file | docker exec -i fortunebet-postgres-1 psql -U root -d gh
|
||||
restore_file:
|
||||
@echo "Restoring latest backup..."
|
||||
gunzip -c $(file) | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh
|
||||
gunzip -c $(file) | docker exec -i fortunebet-postgres-1 psql -U root -d gh
|
||||
|
||||
.PHONY: seed_data
|
||||
seed_data:
|
||||
|
||||
@echo "Waiting for PostgreSQL to be ready..."
|
||||
@until docker exec fortunebet-backend-postgres-1 pg_isready -U root -d gh; do \
|
||||
@until docker exec fortunebet-postgres-1 pg_isready -U root -d gh; do \
|
||||
echo "PostgreSQL is not ready yet..."; \
|
||||
sleep 1; \
|
||||
done
|
||||
@for file in db/data/*.sql; do \
|
||||
echo "Seeding $$file..."; \
|
||||
cat $$file | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh; \
|
||||
cat $$file | docker exec -i fortunebet-postgres-1 psql -U root -d gh; \
|
||||
done
|
||||
.PHONY: seed_dev_data
|
||||
seed_dev_data:
|
||||
@echo "Waiting for PostgreSQL to be ready..."
|
||||
@until docker exec fortunebet-backend-postgres-1 pg_isready -U root -d gh; do \
|
||||
@until docker exec fortunebet-postgres-1 pg_isready -U root -d gh; do \
|
||||
echo "PostgreSQL is not ready yet..."; \
|
||||
sleep 1; \
|
||||
done
|
||||
cat db/scripts/fix_autoincrement_desync.sql | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh;
|
||||
cat db/scripts/fix_autoincrement_desync.sql | docker exec -i fortunebet-postgres-1 psql -U root -d gh;
|
||||
@for file in db/dev_data/*.sql; do \
|
||||
if [ -f "$$file" ]; then \
|
||||
echo "Seeding $$file..."; \
|
||||
cat $$file | docker exec -i fortunebet-backend-postgres-1 psql -U root -d gh; \
|
||||
cat $$file | docker exec -i fortunebet-postgres-1 psql -U root -d gh; \
|
||||
fi \
|
||||
done
|
||||
postgres_log:
|
||||
docker logs fortunebet-backend-postgres-1
|
||||
docker logs fortunebet-postgres-1
|
||||
.PHONY: swagger
|
||||
swagger:
|
||||
@swag init -g cmd/main.go
|
||||
|
|
@ -94,7 +94,7 @@ logs:
|
|||
db-up: | logs
|
||||
@mkdir -p logs
|
||||
@docker compose up -d postgres migrate mongo
|
||||
@docker logs fortunebet-backend-postgres-1 > logs/postgres.log 2>&1 &
|
||||
@docker logs fortunebet-postgres-1 > logs/postgres.log 2>&1 &
|
||||
.PHONY: db-down
|
||||
db-down:
|
||||
@docker compose down -v
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user