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.
40 lines
623 B
40 lines
623 B
package income |
|
|
|
import ( |
|
"context" |
|
|
|
"go-common/app/admin/main/growup/conf" |
|
"go-common/library/database/sql" |
|
) |
|
|
|
// Dao dao |
|
type Dao struct { |
|
c *conf.Config |
|
db *sql.DB |
|
} |
|
|
|
// New fn |
|
func New(c *conf.Config) (d *Dao) { |
|
d = &Dao{ |
|
c: c, |
|
db: sql.NewMySQL(c.ORM.Allowance), |
|
} |
|
return d |
|
} |
|
|
|
// Ping ping health. |
|
func (d *Dao) Ping(c context.Context) (err error) { |
|
return d.db.Ping(c) |
|
} |
|
|
|
// Close close connections of mc, redis, db. |
|
func (d *Dao) Close() { |
|
if d.db != nil { |
|
d.db.Close() |
|
} |
|
} |
|
|
|
// BeginTran begin transcation |
|
func (d *Dao) BeginTran(c context.Context) (tx *sql.Tx, err error) { |
|
return d.db.Begin(c) |
|
}
|
|
|