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.
37 lines
634 B
37 lines
634 B
package operation |
|
|
|
import ( |
|
"context" |
|
|
|
"go-common/app/interface/main/web-show/conf" |
|
xsql "go-common/library/database/sql" |
|
"go-common/library/log" |
|
"go-common/library/stat/prom" |
|
) |
|
|
|
// Dao struct |
|
type Dao struct { |
|
db *xsql.DB |
|
} |
|
|
|
// PromError err |
|
func PromError(name string, format string, args ...interface{}) { |
|
prom.BusinessErrCount.Incr(name) |
|
log.Error(format, args...) |
|
} |
|
|
|
// New Conf |
|
func New(c *conf.Config) (dao *Dao) { |
|
dao = &Dao{db: xsql.NewMySQL(c.MySQL.Operation)} |
|
return |
|
} |
|
|
|
// Close Dao |
|
func (dao *Dao) Close() { |
|
dao.db.Close() |
|
} |
|
|
|
// Ping Dao |
|
func (dao *Dao) Ping(c context.Context) error { |
|
return dao.db.Ping(c) |
|
}
|
|
|