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

@ -145,7 +145,7 @@ func (r *createVotesRequestWithValidator) isValid() bool {
return r.Valid()
}
func (app *application) CreateVotes(w http.ResponseWriter, r *http.Request, id int) {
func (app *application) CreateVotes(w http.ResponseWriter, r *http.Request, id string) {
var request createVotesRequestWithValidator
if err := app.unmarshalRequest(r, &request); err != nil {
@ -284,7 +284,7 @@ func (app *application) createVotesHandleUnknownVotersElection(w http.ResponseWr
return voterIdentity, nil
}
func (app *application) GetElectionResults(w http.ResponseWriter, r *http.Request, id int) {
func (app *application) GetElectionResults(w http.ResponseWriter, r *http.Request, id string) {
votes, err := app.votes.GetByElection(id)
if err != nil {
if errors.Is(sql.ErrNoRows, err) {
@ -325,7 +325,7 @@ func getResultsFromVotes(votes *[]models.Vote) []api.VotesForChoice {
return results
}
func (app *application) GetElection(w http.ResponseWriter, r *http.Request, id int) {
func (app *application) GetElection(w http.ResponseWriter, r *http.Request, id string) {
election, err := app.elections.GetById(id)
if err != nil {
if errors.Is(sql.ErrNoRows, err) {