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.
33 lines
463 B
33 lines
463 B
package dao |
|
|
|
import ( |
|
"context" |
|
|
|
"go-common/app/infra/databus/conf" |
|
"go-common/library/database/sql" |
|
) |
|
|
|
// Dao mysql struct |
|
type Dao struct { |
|
db *sql.DB |
|
} |
|
|
|
// New new a Dao and return |
|
func New(c *conf.Config) (d *Dao) { |
|
d = &Dao{ |
|
db: sql.NewMySQL(c.MySQL), |
|
} |
|
return |
|
} |
|
|
|
// Ping ping mysql |
|
func (d *Dao) Ping(c context.Context) error { |
|
return d.db.Ping(c) |
|
} |
|
|
|
// Close release mysql connection |
|
func (d *Dao) Close() { |
|
if d.db != nil { |
|
d.db.Close() |
|
} |
|
}
|
|
|