41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
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,
|
|
text_pinyin TEXT,
|
|
prop_id INTEGER,
|
|
audio TEXT,
|
|
next_node_id INTEGER,
|
|
feedback TEXT NOT NULL,
|
|
feedback_pinyin TEXT,
|
|
feedback_pros TEXT, -- 对比点评:好处
|
|
feedback_cons TEXT, -- 对比点评:不足/错过的更好选择
|
|
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);`)
|
|
common.EnsureColumn(ctx, consts.TableNodeOption, "text_pinyin", "TEXT")
|
|
common.EnsureColumn(ctx, consts.TableNodeOption, "feedback_pinyin", "TEXT")
|
|
common.EnsureColumn(ctx, consts.TableNodeOption, "feedback_pros", "TEXT")
|
|
common.EnsureColumn(ctx, consts.TableNodeOption, "feedback_cons", "TEXT")
|
|
return err
|
|
}
|