Insert election with uuid instead of auto-generated id

This commit is contained in:
2025-01-20 10:04:15 +01:00
parent 729fbecae6
commit 5668b1cd6a
13 changed files with 94 additions and 360 deletions

View File

@ -47,7 +47,7 @@ type Election struct {
Choices []string `json:"choices"`
CreatedAt string `json:"createdAt"`
ExpiresAt string `json:"expiresAt"`
Id int `json:"id"`
Id string `json:"id"`
MaxVoters int `json:"maxVoters"`
Name string `json:"name"`
Tokens int `json:"tokens"`
@ -89,13 +89,13 @@ type ServerInterface interface {
CreateElection(w http.ResponseWriter, r *http.Request)
// Get an election
// (GET /election/{id})
GetElection(w http.ResponseWriter, r *http.Request, id int)
GetElection(w http.ResponseWriter, r *http.Request, id string)
// Get the results of an election
// (GET /election/{id}/results)
GetElectionResults(w http.ResponseWriter, r *http.Request, id int)
GetElectionResults(w http.ResponseWriter, r *http.Request, id string)
// Cast your votes for an election
// (POST /election/{id}/votes)
CreateVotes(w http.ResponseWriter, r *http.Request, id int)
CreateVotes(w http.ResponseWriter, r *http.Request, id string)
}
// ServerInterfaceWrapper converts contexts to parameters.
@ -129,7 +129,7 @@ func (siw *ServerInterfaceWrapper) GetElection(w http.ResponseWriter, r *http.Re
var err error
// ------------- Path parameter "id" -------------
var id int
var id string
err = runtime.BindStyledParameterWithOptions("simple", "id", r.PathValue("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
@ -155,7 +155,7 @@ func (siw *ServerInterfaceWrapper) GetElectionResults(w http.ResponseWriter, r *
var err error
// ------------- Path parameter "id" -------------
var id int
var id string
err = runtime.BindStyledParameterWithOptions("simple", "id", r.PathValue("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
@ -181,7 +181,7 @@ func (siw *ServerInterfaceWrapper) CreateVotes(w http.ResponseWriter, r *http.Re
var err error
// ------------- Path parameter "id" -------------
var id int
var id string
err = runtime.BindStyledParameterWithOptions("simple", "id", r.PathValue("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {