Refactor flags
Both QCM and Key are Flag
This commit is contained in:
parent
e029ec5414
commit
a66d6885e7
13 changed files with 318 additions and 249 deletions
|
@ -272,8 +272,12 @@ func (f EFile) GetOrigin() string {
|
|||
}
|
||||
|
||||
// AddDepend insert a new dependency to a given flag.
|
||||
func (f EFile) AddDepend(k Flag) (err error) {
|
||||
_, err = DBExec("INSERT INTO exercice_files_deps (id_file, id_flag) VALUES (?, ?)", f.Id, k.Id)
|
||||
func (f EFile) AddDepend(j Flag) (err error) {
|
||||
if k, ok := j.(FlagKey); ok {
|
||||
_, err = DBExec("INSERT INTO exercice_files_deps (id_file, id_flag) VALUES (?, ?)", f.Id, k.Id)
|
||||
} else {
|
||||
err = errors.New("Dependancy type not implemented for this file.")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -290,7 +294,7 @@ func (f EFile) GetDepends() ([]Flag, error) {
|
|||
if err := rows.Scan(&d); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
deps = append(deps, Flag{d, f.IdExercice, "", "", false, nil, []byte{}, 0})
|
||||
deps = append(deps, FlagKey{d, f.IdExercice, "", "", false, nil, []byte{}, 0})
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
|
|
Reference in a new issue