46 lines
913 B
Go
46 lines
913 B
Go
|
package orm
|
||
|
|
||
|
import (
|
||
|
"github.com/jinzhu/gorm"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type Answer struct {
|
||
|
gorm.Model
|
||
|
|
||
|
Text string
|
||
|
Correct bool
|
||
|
|
||
|
QuestionID uint
|
||
|
}
|
||
|
|
||
|
func (a *Answer) GetID() uint { return a.ID }
|
||
|
|
||
|
func (a *Answer) String() string {
|
||
|
return a.Text
|
||
|
}
|
||
|
|
||
|
func (a *Answer) Create(args map[string]string, r *http.Request) (interface{}, error) {
|
||
|
return nil, nil
|
||
|
}
|
||
|
|
||
|
func (a *Answer) Read(args map[string]string, r *http.Request) (interface{}, error) {
|
||
|
return nil, nil
|
||
|
}
|
||
|
|
||
|
func (a *Answer) ReadAll(args map[string]string, r *http.Request) (interface{}, error) {
|
||
|
var questions []*Question
|
||
|
if err := DB().Order("created_at").Find(&questions).Error; err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return questions, nil
|
||
|
}
|
||
|
|
||
|
func (a *Answer) Update(args map[string]string, r *http.Request) (interface{}, error) {
|
||
|
return nil, nil
|
||
|
}
|
||
|
|
||
|
func (a *Answer) Delete(args map[string]string, r *http.Request) (interface{}, error) {
|
||
|
return nil, nil
|
||
|
}
|