resolve conflict
This commit is contained in:
parent
a5ea52b993
commit
dc2144a91e
14
.gitignore
vendored
14
.gitignore
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
# bin
|
bin
|
||||||
# coverage.out
|
coverage.out
|
||||||
# coverage
|
coverage
|
||||||
# .env
|
.env
|
||||||
# tmp
|
tmp
|
||||||
# build
|
build
|
||||||
# *.log
|
*.log
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
-- CREATE TABLE virtual_games (
|
CREATE TABLE IF NOT EXISTS virtual_games (
|
||||||
-- id BIGSERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
-- name VARCHAR(255) NOT NULL,
|
name VARCHAR(255) NOT NULL,
|
||||||
-- provider VARCHAR(100) NOT NULL,
|
provider VARCHAR(100) NOT NULL,
|
||||||
-- category VARCHAR(100) NOT NULL,
|
category VARCHAR(100) NOT NULL,
|
||||||
-- min_bet DECIMAL(15,2) NOT NULL,
|
min_bet DECIMAL(15,2) NOT NULL,
|
||||||
-- max_bet DECIMAL(15,2) NOT NULL,
|
max_bet DECIMAL(15,2) NOT NULL,
|
||||||
-- volatility VARCHAR(50) NOT NULL,
|
volatility VARCHAR(50) NOT NULL,
|
||||||
-- rtp DECIMAL(5,2) NOT NULL,
|
rtp DECIMAL(5,2) NOT NULL,
|
||||||
-- is_featured BOOLEAN DEFAULT false,
|
is_featured BOOLEAN DEFAULT false,
|
||||||
-- popularity_score INTEGER DEFAULT 0,
|
popularity_score INTEGER DEFAULT 0,
|
||||||
-- thumbnail_url TEXT,
|
thumbnail_url TEXT,
|
||||||
-- created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||||
-- updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
|
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
|
||||||
-- );
|
);
|
||||||
|
|
||||||
CREATE TABLE user_game_interactions (
|
CREATE TABLE user_game_interactions (
|
||||||
id BIGSERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ SET name = COALESCE(sqlc.narg(name), name),
|
||||||
location = COALESCE(sqlc.narg(location), location),
|
location = COALESCE(sqlc.narg(location), location),
|
||||||
branch_manager_id = COALESCE(sqlc.narg(branch_manager_id), branch_manager_id),
|
branch_manager_id = COALESCE(sqlc.narg(branch_manager_id), branch_manager_id),
|
||||||
company_id = COALESCE(sqlc.narg(company_id), company_id),
|
company_id = COALESCE(sqlc.narg(company_id), company_id),
|
||||||
is_self_owned = COALESCE(sqlc.narg(is_self_owned), is_self_owned)
|
is_self_owned = COALESCE(sqlc.narg(is_self_owned), is_self_owned),
|
||||||
|
is_active = COALESCE(sqlc.narg(is_active), is_active)
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
-- name: DeleteBranch :exec
|
-- name: DeleteBranch :exec
|
||||||
|
|
|
||||||
|
|
@ -443,7 +443,8 @@ SET name = COALESCE($2, name),
|
||||||
location = COALESCE($3, location),
|
location = COALESCE($3, location),
|
||||||
branch_manager_id = COALESCE($4, branch_manager_id),
|
branch_manager_id = COALESCE($4, branch_manager_id),
|
||||||
company_id = COALESCE($5, company_id),
|
company_id = COALESCE($5, company_id),
|
||||||
is_self_owned = COALESCE($6, is_self_owned)
|
is_self_owned = COALESCE($6, is_self_owned),
|
||||||
|
is_active = COALESCE($7, is_active)
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
RETURNING id, name, location, is_active, wallet_id, branch_manager_id, company_id, is_self_owned, created_at, updated_at
|
RETURNING id, name, location, is_active, wallet_id, branch_manager_id, company_id, is_self_owned, created_at, updated_at
|
||||||
`
|
`
|
||||||
|
|
@ -455,6 +456,7 @@ type UpdateBranchParams struct {
|
||||||
BranchManagerID pgtype.Int8 `json:"branch_manager_id"`
|
BranchManagerID pgtype.Int8 `json:"branch_manager_id"`
|
||||||
CompanyID pgtype.Int8 `json:"company_id"`
|
CompanyID pgtype.Int8 `json:"company_id"`
|
||||||
IsSelfOwned pgtype.Bool `json:"is_self_owned"`
|
IsSelfOwned pgtype.Bool `json:"is_self_owned"`
|
||||||
|
IsActive pgtype.Bool `json:"is_active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) UpdateBranch(ctx context.Context, arg UpdateBranchParams) (Branch, error) {
|
func (q *Queries) UpdateBranch(ctx context.Context, arg UpdateBranchParams) (Branch, error) {
|
||||||
|
|
@ -465,6 +467,7 @@ func (q *Queries) UpdateBranch(ctx context.Context, arg UpdateBranchParams) (Bra
|
||||||
arg.BranchManagerID,
|
arg.BranchManagerID,
|
||||||
arg.CompanyID,
|
arg.CompanyID,
|
||||||
arg.IsSelfOwned,
|
arg.IsSelfOwned,
|
||||||
|
arg.IsActive,
|
||||||
)
|
)
|
||||||
var i Branch
|
var i Branch
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ type UpdateBranch struct {
|
||||||
BranchManagerID *int64
|
BranchManagerID *int64
|
||||||
CompanyID *int64
|
CompanyID *int64
|
||||||
IsSelfOwned *bool
|
IsSelfOwned *bool
|
||||||
|
IsActive *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateSupportedOperation struct {
|
type CreateSupportedOperation struct {
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,12 @@ func convertUpdateBranch(updateBranch domain.UpdateBranch) dbgen.UpdateBranchPar
|
||||||
Valid: true,
|
Valid: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if updateBranch.IsActive != nil {
|
||||||
|
newUpdateBranch.IsActive = pgtype.Bool{
|
||||||
|
Bool: *updateBranch.IsActive,
|
||||||
|
Valid: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return newUpdateBranch
|
return newUpdateBranch
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/authentication"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/authentication"
|
||||||
|
|
@ -682,6 +683,42 @@ func (h *Handler) UpdateBranch(c *fiber.Ctx) error {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Handler) UpdateBranchStatus(c *fiber.Ctx) error {
|
||||||
|
branchID := c.Params("id")
|
||||||
|
id, err := strconv.ParseInt(branchID, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Error("Invalid branch ID", "branchID", branchID, "error", err)
|
||||||
|
return response.WriteJSON(c, fiber.StatusBadRequest, "Invalid branch ID", err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
var isActive bool
|
||||||
|
path := strings.Split(strings.Trim(c.Path(), "/"), "/")
|
||||||
|
|
||||||
|
if path[len(path)-1] == "set-active" {
|
||||||
|
isActive = true
|
||||||
|
} else if path[len(path)-1] == "set-inactive" {
|
||||||
|
isActive = false
|
||||||
|
} else {
|
||||||
|
h.logger.Error("Invalid branch status", "status", isActive, "error", err)
|
||||||
|
return response.WriteJSON(c, fiber.StatusBadRequest, "Invalid branch status", err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
branch, err := h.branchSvc.UpdateBranch(c.Context(), domain.UpdateBranch{
|
||||||
|
ID: id,
|
||||||
|
IsActive: &isActive,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Error("Failed to update branch", "branchID", id, "error", err)
|
||||||
|
return response.WriteJSON(c, fiber.StatusInternalServerError, "Failed to update branch", err, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
res := convertBranch(branch)
|
||||||
|
|
||||||
|
return response.WriteJSON(c, fiber.StatusOK, "Branch Updated", res, nil)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteBranch godoc
|
// DeleteBranch godoc
|
||||||
// @Summary Delete the branch
|
// @Summary Delete the branch
|
||||||
// @Description Delete the branch
|
// @Description Delete the branch
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,8 @@ func (a *App) initAppRoutes() {
|
||||||
a.fiber.Get("/branch/:id", a.authMiddleware, h.GetBranchByID)
|
a.fiber.Get("/branch/:id", a.authMiddleware, h.GetBranchByID)
|
||||||
a.fiber.Get("/branch/:id/bets", a.authMiddleware, h.GetBetByBranchID)
|
a.fiber.Get("/branch/:id/bets", a.authMiddleware, h.GetBetByBranchID)
|
||||||
a.fiber.Put("/branch/:id", a.authMiddleware, h.UpdateBranch)
|
a.fiber.Put("/branch/:id", a.authMiddleware, h.UpdateBranch)
|
||||||
|
a.fiber.Put("/branch/:id/set-active", a.authMiddleware, h.UpdateBranchStatus)
|
||||||
|
a.fiber.Put("/branch/:id/set-inactive", a.authMiddleware, h.UpdateBranchStatus)
|
||||||
a.fiber.Delete("/branch/:id", a.authMiddleware, h.DeleteBranch)
|
a.fiber.Delete("/branch/:id", a.authMiddleware, h.DeleteBranch)
|
||||||
a.fiber.Get("/search/branch", a.authMiddleware, h.SearchBranch)
|
a.fiber.Get("/search/branch", a.authMiddleware, h.SearchBranch)
|
||||||
// /branch/search
|
// /branch/search
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
time=2025-06-15T11:01:26.408+03:00 level=INFO msg="No events were updated" service_info.env=development
|
||||||
|
time=2025-06-15T11:01:26.410+03:00 level=INFO msg="Successfully processed results" service_info.env=development removed_events=0 total_events=0
|
||||||
|
time=2025-06-15T11:01:26.411+03:00 level=INFO msg="Starting server" service_info.env=development port=8080
|
||||||
|
time=2025-06-15T11:07:09.604+03:00 level=INFO msg="No events were updated" service_info.env=development
|
||||||
|
time=2025-06-15T11:07:09.605+03:00 level=INFO msg="Successfully processed results" service_info.env=development removed_events=0 total_events=0
|
||||||
|
time=2025-06-15T11:07:09.606+03:00 level=INFO msg="Starting server" service_info.env=development port=8080
|
||||||
Loading…
Reference in New Issue
Block a user