viper-app/cmd/inits/db.go

69 lines
1.0 KiB
Go
Raw Normal View History

package inits
import (
"demo-server/internal/dao"
)
var (
d *daoPolymer
)
func getDaoPolymer() dao.Interface {
return d
}
type daoPolymer struct {
}
func initDaoPolymer() {
d = &daoPolymer{
//cli: cli,
//group: group.New(cli),
//agent: instance.New(cli),
//log: log.New(cli),
}
}
//func (d *daoPolymer) GetGroupDao() group.Dao {
// return d.group
//}
//
//func (d *daoPolymer) GetInstanceDao() instance.Dao {
// return d.agent
//}
//
//func (d *daoPolymer) GetLogDao() log.Dao {
// return d.log
//}
// 初始化数据库,通过 getDaoPolymer 得到聚合体
func initDB() (err error) {
//cfg := config.Get()
//
//if cfg == nil || cfg.DB == nil {
// return ErrorInitFundamental
//}
//
//var (
// cli *db.Cli
// cfgDB = cfg.DB
//)
//
//if cli, err = db.New(cfgDB); err != nil {
// return
//}
//
//initDaoPolymer(cli)
return
}
func initDBTables() (err error) {
//orm := d.cli.Orm()
//err = orm.Exec(model.DBSQLInit).Error
//if config.Get().DB.Type == model.DBTypeSQLITE {
// orm.Exec(model.DBSQLConfigSQLite)
//}
return
}