31 lines
759 B
Go
31 lines
759 B
Go
package dao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
|
"36wisdom/biz/consts"
|
|
"36wisdom/common"
|
|
)
|
|
|
|
type userProgressDao struct{ common.BaseDao }
|
|
|
|
var UserProgress = &userProgressDao{BaseDao: common.BaseDao{Table: consts.TableUserProgress}}
|
|
|
|
func (d *userProgressDao) Init(ctx context.Context) error {
|
|
_, err := g.DB().Exec(ctx, `
|
|
CREATE TABLE IF NOT EXISTS user_progress (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
child_id INTEGER NOT NULL,
|
|
level_id INTEGER NOT NULL,
|
|
stars INTEGER NOT NULL DEFAULT 0,
|
|
score INTEGER NOT NULL DEFAULT 0,
|
|
perfect INTEGER NOT NULL DEFAULT 0,
|
|
content_version INTEGER NOT NULL DEFAULT 1,
|
|
completed_at DATETIME,
|
|
UNIQUE(child_id, level_id)
|
|
);`)
|
|
return err
|
|
}
|