dao.go 391 B

12345678910111213141516171819202122232425262728
  1. package manager
  2. import (
  3. "go-common/app/service/main/resource/conf"
  4. "go-common/library/database/sql"
  5. )
  6. //Dao manager dao
  7. type Dao struct {
  8. db *sql.DB
  9. c *conf.Config
  10. }
  11. //New new manager dao
  12. func New(c *conf.Config) (d *Dao) {
  13. d = &Dao{
  14. c: c,
  15. db: sql.NewMySQL(c.DB.Manager),
  16. }
  17. return
  18. }
  19. // Close close db resource.
  20. func (d *Dao) Close() {
  21. if d.db != nil {
  22. d.db.Close()
  23. }
  24. }