go-common/app/admin/main/space/dao/dao.go

34 lines
431 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package dao
import (
"context"
"go-common/app/admin/main/space/conf"
"go-common/library/database/orm"
"github.com/jinzhu/gorm"
)
// Dao .
type Dao struct {
c *conf.Config
DB *gorm.DB
}
// New .
func New(c *conf.Config) (d *Dao) {
d = &Dao{
// conf
c: c,
// db
DB: orm.NewMySQL(c.ORM),
}
d.DB.LogMode(true)
return
}
// Ping .
func (d *Dao) Ping(c context.Context) error {
return d.DB.DB().PingContext(c)
}