service.go 600 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/ep/melloi/conf"
  5. "go-common/app/admin/ep/melloi/dao"
  6. "github.com/jinzhu/gorm"
  7. "github.com/robfig/cron"
  8. )
  9. // Service struct
  10. type Service struct {
  11. c *conf.Config
  12. dao *dao.Dao
  13. DB *gorm.DB
  14. cron *cron.Cron
  15. }
  16. // New init
  17. func New(c *conf.Config) (s *Service) {
  18. s = &Service{
  19. c: c,
  20. dao: dao.New(c),
  21. cron: cron.New(),
  22. }
  23. s.cron.Start()
  24. return s
  25. }
  26. // Close Service
  27. func (s *Service) Close() {
  28. s.dao.Close()
  29. }
  30. //Ping test interface
  31. func (s *Service) Ping(c context.Context) (err error) {
  32. err = s.dao.Ping(c)
  33. return
  34. }