fic: Add Order, Help and Type values in struct

This commit is contained in:
nemunaire 2021-08-30 18:33:14 +02:00
commit 74e8c3801a
16 changed files with 134 additions and 110 deletions

View file

@ -4,9 +4,9 @@ import ()
// FlagChoice represents a choice a respond to a classic flag
type FlagChoice struct {
Id int64 `json:"id"`
Id int `json:"id"`
// IdFlag is the identifier of the underlying flag
IdFlag int64 `json:"idFlag"`
IdFlag int `json:"idFlag"`
// Label is the title of the choice as displayed to players
Label string `json:"label"`
// Value is the raw content that'll be written as response if this choice is selected
@ -40,7 +40,7 @@ func (f FlagKey) GetChoices() ([]FlagChoice, error) {
}
// GetChoice returns a choice for the given Flag.
func (f FlagKey) GetChoice(id int64) (c FlagChoice, err error) {
func (f FlagKey) GetChoice(id int) (c FlagChoice, err error) {
if errr := DBQueryRow("SELECT id_choice, id_flag, label, response FROM flag_choices WHERE id_choice = ?", id).Scan(&c.Id, &c.IdFlag, &c.Label, &c.Value); errr != nil {
return c, errr
}
@ -52,7 +52,8 @@ func (f FlagKey) AddChoice(c FlagChoice) (FlagChoice, error) {
if res, err := DBExec("INSERT INTO flag_choices (id_flag, label, response) VALUES (?, ?, ?)", f.Id, c.Label, c.Value); err != nil {
return c, err
} else {
c.Id, err = res.LastInsertId()
cid, err := res.LastInsertId()
c.Id = int(cid)
return c, err
}
}