package dao import ( "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" "gorm.io/gorm" "hilo/app/service/mgr/internal/conf" "hilo/common/mysql" ) // ProviderSet is dao providers. var ProviderSet = wire.NewSet(NewDao) // Dao . type Dao struct { // TODO wrapped database client DB *gorm.DB } // NewDao . func NewDao(c *conf.Data) (*Dao, func(), error) { db := mysql.NewDB(c.Mysql) cleanup := func() { d, _ := db.DB() d.Close() log.Debug("close data resources") } return &Dao{ DB: db, }, cleanup, nil }