service.go 510 B

123456789101112131415161718192021222324252627282930313233
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/main/open/conf"
  5. "go-common/app/admin/main/open/dao"
  6. )
  7. // Service biz service def.
  8. type Service struct {
  9. c *conf.Config
  10. dao *dao.Dao
  11. }
  12. // New new a Service and return.
  13. func New(c *conf.Config) (s *Service) {
  14. s = &Service{
  15. c: c,
  16. dao: dao.New(c),
  17. }
  18. return s
  19. }
  20. // Ping check dao health.
  21. func (s *Service) Ping(c context.Context) (err error) {
  22. return s.dao.Ping(c)
  23. }
  24. // Close close all dao.
  25. func (s *Service) Close() {
  26. s.dao.Close()
  27. }