resolve conflict
This commit is contained in:
parent
bfba23bc69
commit
5461feaa0b
|
|
@ -1,18 +1,18 @@
|
|||
-- CREATE TABLE virtual_games (
|
||||
-- id BIGSERIAL PRIMARY KEY,
|
||||
-- name VARCHAR(255) NOT NULL,
|
||||
-- provider VARCHAR(100) NOT NULL,
|
||||
-- category VARCHAR(100) NOT NULL,
|
||||
-- min_bet DECIMAL(15,2) NOT NULL,
|
||||
-- max_bet DECIMAL(15,2) NOT NULL,
|
||||
-- volatility VARCHAR(50) NOT NULL,
|
||||
-- rtp DECIMAL(5,2) NOT NULL,
|
||||
-- is_featured BOOLEAN DEFAULT false,
|
||||
-- popularity_score INTEGER DEFAULT 0,
|
||||
-- thumbnail_url TEXT,
|
||||
-- created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
-- updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
|
||||
-- );
|
||||
CREATE TABLE IF NOT EXISTS virtual_games (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
provider VARCHAR(100) NOT NULL,
|
||||
category VARCHAR(100) NOT NULL,
|
||||
min_bet DECIMAL(15,2) NOT NULL,
|
||||
max_bet DECIMAL(15,2) NOT NULL,
|
||||
volatility VARCHAR(50) NOT NULL,
|
||||
rtp DECIMAL(5,2) NOT NULL,
|
||||
is_featured BOOLEAN DEFAULT false,
|
||||
popularity_score INTEGER DEFAULT 0,
|
||||
thumbnail_url TEXT,
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE user_game_interactions (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ SET name = COALESCE(sqlc.narg(name), name),
|
|||
location = COALESCE(sqlc.narg(location), location),
|
||||
branch_manager_id = COALESCE(sqlc.narg(branch_manager_id), branch_manager_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
|
||||
RETURNING *;
|
||||
-- name: DeleteBranch :exec
|
||||
|
|
|
|||
|
|
@ -443,7 +443,8 @@ SET name = COALESCE($2, name),
|
|||
location = COALESCE($3, location),
|
||||
branch_manager_id = COALESCE($4, branch_manager_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
|
||||
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"`
|
||||
CompanyID pgtype.Int8 `json:"company_id"`
|
||||
IsSelfOwned pgtype.Bool `json:"is_self_owned"`
|
||||
IsActive pgtype.Bool `json:"is_active"`
|
||||
}
|
||||
|
||||
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.CompanyID,
|
||||
arg.IsSelfOwned,
|
||||
arg.IsActive,
|
||||
)
|
||||
var i Branch
|
||||
err := row.Scan(
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ type UpdateBranch struct {
|
|||
BranchManagerID *int64
|
||||
CompanyID *int64
|
||||
IsSelfOwned *bool
|
||||
IsActive *bool
|
||||
}
|
||||
|
||||
type CreateSupportedOperation struct {
|
||||
|
|
|
|||
|
|
@ -83,6 +83,12 @@ func convertUpdateBranch(updateBranch domain.UpdateBranch) dbgen.UpdateBranchPar
|
|||
Valid: true,
|
||||
}
|
||||
}
|
||||
if updateBranch.IsActive != nil {
|
||||
newUpdateBranch.IsActive = pgtype.Bool{
|
||||
Bool: *updateBranch.IsActive,
|
||||
Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
return newUpdateBranch
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package handlers
|
|||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
||||
"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
|
||||
// @Summary 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/bets", a.authMiddleware, h.GetBetByBranchID)
|
||||
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.Get("/search/branch", a.authMiddleware, h.SearchBranch)
|
||||
// /branch/search
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user