feat: 19 张表 DAO 与建表初始化
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type adminUserDao struct{ common.BaseDao }
|
||||
|
||||
var AdminUser = &adminUserDao{BaseDao: common.BaseDao{Table: consts.TableAdminUser}}
|
||||
|
||||
func (d *adminUserDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS admin_user (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username TEXT UNIQUE NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
status INTEGER NOT NULL DEFAULT 1,
|
||||
created_at DATETIME
|
||||
);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type badgeDao struct{ common.BaseDao }
|
||||
|
||||
var Badge = &badgeDao{BaseDao: common.BaseDao{Table: consts.TableBadge}}
|
||||
|
||||
func (d *badgeDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS badge (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
icon TEXT,
|
||||
cond_type INTEGER NOT NULL,
|
||||
cond_value INTEGER NOT NULL,
|
||||
status INTEGER NOT NULL DEFAULT 1
|
||||
);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type chapterReviewDao struct{ common.BaseDao }
|
||||
|
||||
var ChapterReview = &chapterReviewDao{BaseDao: common.BaseDao{Table: consts.TableChapterReview}}
|
||||
|
||||
func (d *chapterReviewDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS chapter_review (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
child_id INTEGER NOT NULL,
|
||||
strategy_id INTEGER NOT NULL,
|
||||
level_ids TEXT NOT NULL,
|
||||
status INTEGER NOT NULL DEFAULT 1,
|
||||
created_at DATETIME,
|
||||
UNIQUE(child_id, strategy_id)
|
||||
);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type childDao struct{ common.BaseDao }
|
||||
|
||||
var Child = &childDao{BaseDao: common.BaseDao{Table: consts.TableChild}}
|
||||
|
||||
func (d *childDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS child (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
parent_id INTEGER NOT NULL,
|
||||
nickname TEXT,
|
||||
avatar TEXT,
|
||||
age_group TEXT NOT NULL DEFAULT '4-6',
|
||||
points INTEGER NOT NULL DEFAULT 0,
|
||||
daily_limit_minutes INTEGER NOT NULL DEFAULT 0,
|
||||
status INTEGER NOT NULL DEFAULT 1,
|
||||
created_at DATETIME,
|
||||
updated_at DATETIME
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_child_parent ON child(parent_id);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type elementDao struct{ common.BaseDao }
|
||||
|
||||
var Element = &elementDao{BaseDao: common.BaseDao{Table: consts.TableElement}}
|
||||
|
||||
func (d *elementDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS element (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
e_type INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
image TEXT,
|
||||
audio TEXT,
|
||||
description TEXT,
|
||||
status INTEGER NOT NULL DEFAULT 1,
|
||||
sort_order INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_element_type ON element(e_type);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type levelDao struct{ common.BaseDao }
|
||||
|
||||
var Level = &levelDao{BaseDao: common.BaseDao{Table: consts.TableLevel}}
|
||||
|
||||
func (d *levelDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS level (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
strategy_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
scene_id INTEGER,
|
||||
scene_content TEXT NOT NULL,
|
||||
scene_image TEXT,
|
||||
scene_audio TEXT,
|
||||
age_group TEXT NOT NULL DEFAULT '4-6',
|
||||
content_version INTEGER NOT NULL DEFAULT 1,
|
||||
sort_order INTEGER NOT NULL,
|
||||
status INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_level_strategy ON level(strategy_id, sort_order);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type lifeTaskDao struct{ common.BaseDao }
|
||||
|
||||
var LifeTask = &lifeTaskDao{BaseDao: common.BaseDao{Table: consts.TableLifeTask}}
|
||||
|
||||
func (d *lifeTaskDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS life_task (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
strategy_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
guide TEXT NOT NULL,
|
||||
reward_points INTEGER NOT NULL DEFAULT 20,
|
||||
status INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_life_task_strategy ON life_task(strategy_id);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type lifeTaskLogDao struct{ common.BaseDao }
|
||||
|
||||
var LifeTaskLog = &lifeTaskLogDao{BaseDao: common.BaseDao{Table: consts.TableLifeTaskLog}}
|
||||
|
||||
func (d *lifeTaskLogDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS life_task_log (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
child_id INTEGER NOT NULL,
|
||||
task_id INTEGER NOT NULL,
|
||||
status INTEGER NOT NULL DEFAULT 1,
|
||||
confirm_photo TEXT,
|
||||
confirmed_at DATETIME,
|
||||
created_at DATETIME,
|
||||
UNIQUE(child_id, task_id)
|
||||
);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type nodeOptionDao struct{ common.BaseDao }
|
||||
|
||||
var NodeOption = &nodeOptionDao{BaseDao: common.BaseDao{Table: consts.TableNodeOption}}
|
||||
|
||||
func (d *nodeOptionDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS node_option (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
node_id INTEGER NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
prop_id INTEGER,
|
||||
audio TEXT,
|
||||
next_node_id INTEGER,
|
||||
feedback TEXT NOT NULL,
|
||||
feedback_audio TEXT,
|
||||
sort_order INTEGER NOT NULL DEFAULT 1,
|
||||
status INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_option_node ON node_option(node_id);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type parentDao struct{ common.BaseDao }
|
||||
|
||||
var Parent = &parentDao{BaseDao: common.BaseDao{Table: consts.TableParent}}
|
||||
|
||||
func (d *parentDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS parent (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
openid TEXT UNIQUE,
|
||||
phone TEXT UNIQUE,
|
||||
password TEXT,
|
||||
nickname TEXT,
|
||||
avatar TEXT,
|
||||
status INTEGER NOT NULL DEFAULT 1,
|
||||
created_at DATETIME,
|
||||
updated_at DATETIME
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_parent_openid ON parent(openid);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type pointLogDao struct{ common.BaseDao }
|
||||
|
||||
var PointLog = &pointLogDao{BaseDao: common.BaseDao{Table: consts.TablePointLog}}
|
||||
|
||||
func (d *pointLogDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS point_log (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
change INTEGER NOT NULL,
|
||||
reason_type INTEGER NOT NULL,
|
||||
ref_id INTEGER,
|
||||
balance_after INTEGER NOT NULL,
|
||||
created_at DATETIME
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_point_log_user ON point_log(user_id, created_at);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type prizeDao struct{ common.BaseDao }
|
||||
|
||||
var Prize = &prizeDao{BaseDao: common.BaseDao{Table: consts.TablePrize}}
|
||||
|
||||
func (d *prizeDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS prize (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
icon TEXT,
|
||||
p_type INTEGER NOT NULL DEFAULT 1,
|
||||
points_cost INTEGER NOT NULL,
|
||||
stock INTEGER NOT NULL DEFAULT 0,
|
||||
status INTEGER NOT NULL DEFAULT 1,
|
||||
sort_order INTEGER NOT NULL DEFAULT 1
|
||||
);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type redemptionDao struct{ common.BaseDao }
|
||||
|
||||
var Redemption = &redemptionDao{BaseDao: common.BaseDao{Table: consts.TableRedemption}}
|
||||
|
||||
func (d *redemptionDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS redemption (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
prize_id INTEGER NOT NULL,
|
||||
points_cost INTEGER NOT NULL,
|
||||
status INTEGER NOT NULL DEFAULT 1,
|
||||
code TEXT,
|
||||
created_at DATETIME,
|
||||
updated_at DATETIME
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_redemption_user ON redemption(user_id, created_at);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type sceneNodeDao struct{ common.BaseDao }
|
||||
|
||||
var SceneNode = &sceneNodeDao{BaseDao: common.BaseDao{Table: consts.TableSceneNode}}
|
||||
|
||||
func (d *sceneNodeDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS scene_node (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
level_id INTEGER NOT NULL,
|
||||
title TEXT,
|
||||
character_id INTEGER,
|
||||
content TEXT NOT NULL,
|
||||
image TEXT,
|
||||
audio TEXT,
|
||||
node_type INTEGER NOT NULL DEFAULT 1,
|
||||
interaction_type INTEGER NOT NULL DEFAULT 1,
|
||||
config TEXT,
|
||||
result_type INTEGER NOT NULL DEFAULT 0,
|
||||
is_entry INTEGER NOT NULL DEFAULT 0,
|
||||
sort_order INTEGER NOT NULL DEFAULT 1,
|
||||
status INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_node_level ON scene_node(level_id);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type strategyDao struct{ common.BaseDao }
|
||||
|
||||
var Strategy = &strategyDao{BaseDao: common.BaseDao{Table: consts.TableStrategy}}
|
||||
|
||||
func (d *strategyDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS strategy (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
pinyin TEXT NOT NULL,
|
||||
group_no INTEGER NOT NULL,
|
||||
group_name TEXT NOT NULL,
|
||||
meaning TEXT NOT NULL,
|
||||
teach_content TEXT,
|
||||
teach_image TEXT,
|
||||
teach_audio TEXT,
|
||||
summary_q TEXT,
|
||||
summary_options TEXT,
|
||||
summary_audio TEXT,
|
||||
icon TEXT,
|
||||
sort_order INTEGER NOT NULL,
|
||||
unlock_before INTEGER,
|
||||
status INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_strategy_group ON strategy(group_no, sort_order);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type userBadgeDao struct{ common.BaseDao }
|
||||
|
||||
var UserBadge = &userBadgeDao{BaseDao: common.BaseDao{Table: consts.TableUserBadge}}
|
||||
|
||||
func (d *userBadgeDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS user_badge (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
badge_id INTEGER NOT NULL,
|
||||
earned_at DATETIME,
|
||||
UNIQUE(user_id, badge_id)
|
||||
);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type userCollectionDao struct{ common.BaseDao }
|
||||
|
||||
var UserCollection = &userCollectionDao{BaseDao: common.BaseDao{Table: consts.TableUserCollection}}
|
||||
|
||||
func (d *userCollectionDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS user_collection (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
strategy_id INTEGER NOT NULL,
|
||||
unlocked_at DATETIME,
|
||||
UNIQUE(user_id, strategy_id)
|
||||
);`)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
"36wisdom/biz/consts"
|
||||
"36wisdom/common"
|
||||
)
|
||||
|
||||
type userRouteLogDao struct{ common.BaseDao }
|
||||
|
||||
var UserRouteLog = &userRouteLogDao{BaseDao: common.BaseDao{Table: consts.TableUserRouteLog}}
|
||||
|
||||
func (d *userRouteLogDao) Init(ctx context.Context) error {
|
||||
_, err := g.DB().Exec(ctx, `
|
||||
CREATE TABLE IF NOT EXISTS user_route_log (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
child_id INTEGER NOT NULL,
|
||||
level_id INTEGER NOT NULL,
|
||||
node_id INTEGER NOT NULL,
|
||||
option_id INTEGER NOT NULL DEFAULT 0,
|
||||
result_type INTEGER NOT NULL DEFAULT 0,
|
||||
created_at DATETIME
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_route_log_child ON user_route_log(child_id, level_id, created_at);`)
|
||||
return err
|
||||
}
|
||||
+35
-2
@@ -1,7 +1,40 @@
|
||||
package dao
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
|
||||
// InitTables 创建全部业务表与索引;具体建表在 biz/dao 各文件 init 中按依赖序接入。
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type tableInitializer func(ctx context.Context) error
|
||||
|
||||
var tableInitializers = []tableInitializer{
|
||||
Parent.Init,
|
||||
Child.Init,
|
||||
Strategy.Init,
|
||||
Level.Init,
|
||||
SceneNode.Init,
|
||||
NodeOption.Init,
|
||||
Element.Init,
|
||||
UserProgress.Init,
|
||||
ChapterReview.Init,
|
||||
UserRouteLog.Init,
|
||||
UserCollection.Init,
|
||||
Badge.Init,
|
||||
UserBadge.Init,
|
||||
PointLog.Init,
|
||||
Prize.Init,
|
||||
Redemption.Init,
|
||||
AdminUser.Init,
|
||||
LifeTask.Init,
|
||||
LifeTaskLog.Init,
|
||||
}
|
||||
|
||||
// InitTables 创建全部业务表与索引(IF NOT EXISTS 幂等)。
|
||||
func InitTables(ctx context.Context) {
|
||||
for _, init := range tableInitializers {
|
||||
if err := init(ctx); err != nil {
|
||||
g.Log().Fatal(ctx, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ logger:
|
||||
level: "info"
|
||||
database:
|
||||
type: "sqlite"
|
||||
link: "data/36wisdom.db"
|
||||
link: "sqlite::@file(data/36wisdom.db)"
|
||||
cache:
|
||||
ttl: 300
|
||||
maxSize: 10000
|
||||
|
||||
Reference in New Issue
Block a user