service.go 624 B

1234567891011121314151617181920212223242526272829303132333435
  1. package service
  2. import (
  3. "github.com/pkg/errors"
  4. "gorm.io/gorm"
  5. "kpt.notice/apiserver/config"
  6. "kpt.notice/apiserver/dao"
  7. "kpt.notice/apiserver/model"
  8. )
  9. var svc *Service
  10. type Service struct {
  11. DB *gorm.DB
  12. Con *config.Config
  13. }
  14. func New(c *config.Config) (s *Service) {
  15. dao := dao.New(c)
  16. s = &Service{
  17. DB: dao.DB,
  18. Con: c,
  19. }
  20. svc = s
  21. JobInit()
  22. return
  23. }
  24. func (svc *Service) QuerySysPastureUrl(con *model.SysPastureUrl) (result model.SysPastureUrl, err error) {
  25. if err = svc.DB.Table("sys_pasture_url").Where(con).First(&result).Error; err != nil {
  26. err = errors.Wrap(err, "service.QueryDB")
  27. }
  28. return
  29. }