dao.go 439 B

12345678910111213141516171819202122232425262728
  1. package result
  2. import (
  3. "context"
  4. "go-common/app/job/main/archive/conf"
  5. "go-common/library/database/sql"
  6. )
  7. // Dao is redis dao.
  8. type Dao struct {
  9. c *conf.Config
  10. db *sql.DB
  11. }
  12. // New is new redis dao.
  13. func New(c *conf.Config) (d *Dao) {
  14. d = &Dao{
  15. c: c,
  16. db: sql.NewMySQL(c.DB.Result),
  17. }
  18. return d
  19. }
  20. // BeginTran begin transcation.
  21. func (d *Dao) BeginTran(c context.Context) (tx *sql.Tx, err error) {
  22. return d.db.Begin(c)
  23. }