func (u *User) GetLessonStudy(less *contents.Lesson) int64 { if s, ok := u.lessonStudy[less.FullId()]; ok { return s } u.SetLessonStudy(less, LS_NOT_AVAILABLE) return LS_NOT_AVAILABLE }
func (u *User) SetLessonStudy(less *contents.Lesson, status int64) { id := less.FullId() if v, ok := u.lessonStudy[id]; !ok || v != status { if el, _ := u.DBQueryFetchOne("SELECT status FROM lesson_study WHERE id = ?", id); el != nil { u.DBQuery("UPDATE lesson_study SET status = ? WHERE id = ?", status, id) } else { u.DBQuery("INSERT INTO lesson_study(id, status) VALUES(?, ?)", id, status) } } u.lessonStudy[id] = status }