theme: new function for getting just the ID of the theme, not all the Theme
This commit is contained in:
parent
2ff39500b0
commit
9c1f6c4ab8
1 changed files with 11 additions and 3 deletions
|
|
@ -15,7 +15,7 @@ type Exercice struct {
|
||||||
VideoURI string `json:"videoURI"`
|
VideoURI string `json:"videoURI"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetExercice(id int) (Exercice, error) {
|
func GetExercice(id int64) (Exercice, error) {
|
||||||
var e Exercice
|
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 {
|
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
|
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
|
var tid int
|
||||||
if err := DBQueryRow("SELECT id_theme FROM exercices WHERE id_exercice=?", e.Id).Scan(&tid); err != nil {
|
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) {
|
func (e Exercice) Delete() (int64, error) {
|
||||||
|
|
|
||||||
Reference in a new issue