diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-06-11 17:17:26 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-06-11 17:17:26 +0530 |
commit | 671c3a765ffc53575f517cef715dc16be5aa43c5 (patch) | |
tree | 4f6d7ea1059f339bef6e245638fdb52cd0363844 /server | |
parent | 33c10cfa027d769c1d02a54bad766f431b1196ee (diff) |
cleaned up some code and fixed formatter for the client name/address
Diffstat (limited to 'server')
-rw-r--r-- | server/database/main.go | 7 | ||||
-rw-r--r-- | server/database/people.go | 19 | ||||
-rw-r--r-- | server/main.go | 7 |
3 files changed, 17 insertions, 16 deletions
diff --git a/server/database/main.go b/server/database/main.go index de2365c..811a8eb 100644 --- a/server/database/main.go +++ b/server/database/main.go @@ -33,9 +33,10 @@ func StartDB() { init_people, _ := myDatabase.Prepare( `CREATE TABLE IF NOT EXISTS People (id INTEGER PRIMARY KEY AUTOINCREMENT, - Name TEXT, - Phone TEXT, - Email TEXT)`, + Name TEXT, + Address TEXT, + Phone TEXT, + Email TEXT)`, ) init_people.Exec() } diff --git a/server/database/people.go b/server/database/people.go index 01cbba8..e0930b0 100644 --- a/server/database/people.go +++ b/server/database/people.go @@ -14,10 +14,10 @@ import ( _ "github.com/mattn/go-sqlite3" ) type Person struct { - ID int - Name string - Phone string - Email string + Name string + Address string + Phone string + Email string } func GetAllPeople() []Person { @@ -27,13 +27,12 @@ func GetAllPeople() []Person { ) var ( - name, phone, email string - id int + name, address, phone, email string ) for rows.Next() { - rows.Scan(&id, &name, &phone, &email) - allPeople = append(allPeople, Person{id, name, phone, email}) + rows.Scan(&name, &address, &phone, &email) + allPeople = append(allPeople, Person{name, address, phone, email}) } return allPeople @@ -43,12 +42,12 @@ func RegisterPerson(person Person) bool { register_person, _ := myDatabase.Prepare( `INSERT INTO People - (Name, Phone, Email) + (Name, Address, Phone, Email) VALUES (?, ?, ?)`, ) register_person.Exec( - person.Name, person.Phone, person.Email, + person.Name, person.Address, person.Phone, person.Email, ) return true diff --git a/server/main.go b/server/main.go index 8b400fe..e6c70e6 100644 --- a/server/main.go +++ b/server/main.go @@ -81,9 +81,10 @@ func getAllPeople(ctx *gin.Context) { func registerPerson(ctx *gin.Context) { person := db.Person { - Name: ctx.Query("name"), - Phone: ctx.Query("phone"), - Email: ctx.Query("email"), + Name: ctx.Query("name"), + Address: ctx.Query("address"), + Phone: ctx.Query("phone"), + Email: ctx.Query("email"), } db.RegisterPerson(person) |