package service import ( "github.com/pkg/errors" "gorm.io/gorm" "kpt.notice/apiserver/config" "kpt.notice/apiserver/dao" "kpt.notice/apiserver/model" ) var svc *Service type Service struct { DB *gorm.DB Con *config.Config } func New(c *config.Config) (s *Service) { dao := dao.New(c) s = &Service{ DB: dao.DB, Con: c, } svc = s JobInit() return } // func (svc *Service) QueryDB(tname string, condition map[string]interface{}, result interface{}) (err error) { // if err = svc.DB.Table(tname).Where(condition).Find(result).Error; err != nil { // err = errors.Wrap(err, "service.QueryDB") // } // return // } func (svc *Service) QuerySysPastureUrl(con *model.SysPastureUrl) (result model.SysPastureUrl, err error) { if err = svc.DB.Table("sys_pasture_url").Where(con).First(&result).Error; err != nil { err = errors.Wrap(err, "service.QueryDB") } return }