You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
594 B
42 lines
594 B
package manager |
|
|
|
import ( |
|
"context" |
|
|
|
"github.com/jinzhu/gorm" |
|
"go-common/app/admin/main/videoup/conf" |
|
"go-common/library/database/orm" |
|
) |
|
|
|
// Dao is redis dao. |
|
type Dao struct { |
|
c *conf.Config |
|
// db |
|
OverseaDB *gorm.DB |
|
} |
|
|
|
var ( |
|
d *Dao |
|
) |
|
|
|
// New new a dao. |
|
func New(c *conf.Config) (d *Dao) { |
|
d = &Dao{ |
|
c: c, |
|
OverseaDB: orm.NewMySQL(c.DB.Oversea), |
|
} |
|
return d |
|
} |
|
|
|
// Close close. |
|
func (d *Dao) Close() { |
|
if d.OverseaDB != nil { |
|
d.OverseaDB.Close() |
|
} |
|
} |
|
|
|
// Ping ping cpdb |
|
func (d *Dao) Ping(c context.Context) (err error) { |
|
err = d.OverseaDB.DB().PingContext(c) |
|
return |
|
}
|
|
|