Create & Init Project...
This commit is contained in:
33
app/admin/main/space/dao/dao.go
Normal file
33
app/admin/main/space/dao/dao.go
Normal file
@ -0,0 +1,33 @@
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user