Change internal variable representation vs JSON one
This commit is contained in:
parent
8cf2a36fe1
commit
e89af34c5c
6 changed files with 61 additions and 61 deletions
|
|
@ -3,8 +3,8 @@ package main
|
|||
import ()
|
||||
|
||||
type Theme struct {
|
||||
id int64
|
||||
Name string
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func GetThemes() ([]Theme, error) {
|
||||
|
|
@ -16,7 +16,7 @@ func GetThemes() ([]Theme, error) {
|
|||
var themes = make([]Theme, 0)
|
||||
for rows.Next() {
|
||||
var t Theme
|
||||
if err := rows.Scan(&t.id, &t.Name); err != nil {
|
||||
if err := rows.Scan(&t.Id, &t.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
themes = append(themes, t)
|
||||
|
|
@ -31,7 +31,7 @@ func GetThemes() ([]Theme, error) {
|
|||
|
||||
func GetTheme(id int) (Theme, error) {
|
||||
var t Theme
|
||||
if err := DBQueryRow("SELECT id_theme, name FROM themes WHERE id_theme=?", id).Scan(&t.id, &t.Name); err != nil {
|
||||
if err := DBQueryRow("SELECT id_theme, name FROM themes WHERE id_theme=?", id).Scan(&t.Id, &t.Name); err != nil {
|
||||
return t, err
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ func CreateTheme(name string) (Theme, error) {
|
|||
}
|
||||
|
||||
func (t Theme) Update() (int64, error) {
|
||||
if res, err := DBExec("UPDATE themes SET name = ? WHERE id_team = ?", t.Name, t.id); err != nil {
|
||||
if res, err := DBExec("UPDATE themes SET name = ? WHERE id_team = ?", t.Name, t.Id); err != nil {
|
||||
return 0, err
|
||||
} else if nb, err := res.RowsAffected(); err != nil {
|
||||
return 0, err
|
||||
|
|
@ -59,7 +59,7 @@ func (t Theme) Update() (int64, error) {
|
|||
}
|
||||
|
||||
func (t Theme) Delete() (int64, error) {
|
||||
if res, err := DBExec("DELETE FROM themes WHERE id_theme = ?", t.id); err != nil {
|
||||
if res, err := DBExec("DELETE FROM themes WHERE id_theme = ?", t.Id); err != nil {
|
||||
return 0, err
|
||||
} else if nb, err := res.RowsAffected(); err != nil {
|
||||
return 0, err
|
||||
|
|
|
|||
Reference in a new issue