theme: new function for getting just the ID of the theme, not all the Theme

This commit is contained in:
nemunaire 2016-01-25 03:08:27 +01:00
commit 9c1f6c4ab8

View file

@ -15,7 +15,7 @@ type Exercice struct {
VideoURI string `json:"videoURI"`
}
func GetExercice(id int) (Exercice, error) {
func GetExercice(id int64) (Exercice, error) {
var e Exercice
if err := DBQueryRow("SELECT id_exercice, title, statement, hint, depend, gain, video_uri FROM exercices WHERE id_exercice = ?", id).Scan(&e.Id, &e.Title, &e.Statement, &e.Hint, &e.Depend, &e.Gain, &e.VideoURI); err != nil {
return Exercice{}, err
@ -107,12 +107,20 @@ func (e Exercice) Update() (int64, error) {
}
}
func (e Exercice) GetTheme() (Theme, error) {
func (e Exercice) GetThemeId() (int, error) {
var tid int
if err := DBQueryRow("SELECT id_theme FROM exercices WHERE id_exercice=?", e.Id).Scan(&tid); err != nil {
return Theme{}, err
return 0, err
}
return tid, nil
}
func (e Exercice) GetTheme() (Theme, error) {
if tid, err := e.GetThemeId(); err != nil {
return Theme{}, err
} else {
return GetTheme(tid)
}
return GetTheme(tid)
}
func (e Exercice) Delete() (int64, error) {