dao.go 489 B

12345678910111213141516171819202122232425262728293031323334
  1. package material
  2. import (
  3. "context"
  4. "go-common/app/interface/main/creative/conf"
  5. "go-common/library/database/sql"
  6. )
  7. // Dao is archive dao.
  8. type Dao struct {
  9. // config
  10. c *conf.Config
  11. db *sql.DB
  12. }
  13. // New init api url
  14. func New(c *conf.Config) (d *Dao) {
  15. d = &Dao{
  16. c: c,
  17. db: sql.NewMySQL(c.DB.Creative),
  18. }
  19. return
  20. }
  21. // Ping fn
  22. func (d *Dao) Ping(c context.Context) (err error) {
  23. return d.db.Ping(c)
  24. }
  25. // Close fn
  26. func (d *Dao) Close() (err error) {
  27. return d.db.Close()
  28. }