Files
36Wisdom/biz/dao/dao_element.go
T

35 lines
905 B
Go

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,
name_pinyin TEXT,
image TEXT,
audio TEXT,
description TEXT,
description_pinyin 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);`)
common.EnsureColumn(ctx, consts.TableElement, "name_pinyin", "TEXT")
common.EnsureColumn(ctx, consts.TableElement, "description_pinyin", "TEXT")
return err
}