split checker from token-validator
This commit is contained in:
parent
685dc0b0ea
commit
0c661f36f6
20 changed files with 634 additions and 748 deletions
36
libadlin/ping.go
Normal file
36
libadlin/ping.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package adlin
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Pong struct {
|
||||
Date time.Time
|
||||
State bool
|
||||
}
|
||||
|
||||
func (s Student) LastPongs() (pongs []Pong, err error) {
|
||||
if rows, errr := DBQuery("SELECT time, state FROM student_pong WHERE id_student = ? ORDER BY time DESC", s.Id); errr != nil {
|
||||
return nil, errr
|
||||
} else {
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var p Pong
|
||||
if err = rows.Scan(&p.Date, &p.State); err != nil {
|
||||
return
|
||||
}
|
||||
pongs = append(pongs, p)
|
||||
}
|
||||
if err = rows.Err(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Student) OnPong(state bool) (err error) {
|
||||
_, err = DBExec("INSERT INTO student_pong (id_student, time, state) VALUES (?, ?, ?)", s.Id, time.Now(), state)
|
||||
return
|
||||
}
|
||||
Reference in a new issue