From b605217625da37e47eaaadfc72ee33467bddc43e Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Wed, 18 Oct 2023 16:43:04 +0200 Subject: [PATCH] db.WriteParticipant erstellt und dazu alle IDs von int auf int64 umgestellt --- packages/data/db.go | 19 +++++++++++++++++++ packages/types/types.go | 16 ++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/data/db.go b/packages/data/db.go index 1c4528d..0303a4b 100644 --- a/packages/data/db.go +++ b/packages/data/db.go @@ -320,3 +320,22 @@ func (db *DB) GetInstructors() (*[]*types.Instructor, error) { return &instructors, nil } + +func (db *DB) WriteParticipant(p *types.Participant) error { + result, err := db.Exec(` + INSERT INTO participants + (first_name, last_name, company) + VALUES + (?, ?, ?) + `, p.FirstName, p.LastName, p.Company) + if err != nil { + return fmt.Errorf("*DB.writeParticipant: db.Exec(): %v\n", err) + } + + p.ID, err = result.LastInsertId() + if err != nil { + return fmt.Errorf("*DB.writeParticipant: result.LastInsertId(): %v\n", err) + } + + return nil +} diff --git a/packages/types/types.go b/packages/types/types.go index 6615f09..0f38580 100644 --- a/packages/types/types.go +++ b/packages/types/types.go @@ -1,7 +1,7 @@ package types type Person struct { - ID int + ID int64 FirstName string LastName string } @@ -14,31 +14,31 @@ type Participant struct { } type Briefing struct { - ID int + ID int64 Date string Time string Location string DocumentName string AsOf string - InstructorID int + InstructorID int64 } type Answer struct { - ID int + ID int64 Text string } type Question struct { - ID int + ID int64 Text string Answers []Answer Correct int } type GivenAnswer struct { - BriefingID int - ParticipantID int - QuestionID int + BriefingID int64 + ParticipantID int64 + QuestionID int64 GivenAnswer int }