query.go 970 B

123456789101112131415161718192021222324252627282930313233
  1. package smart_report_resource
  2. import (
  3. "hongze/hongze_yb/global"
  4. )
  5. // GetResourceItemById
  6. // @Description: 根据资源id获取信息
  7. // @author: Roc
  8. // @datetime 2024-06-21 16:59:23
  9. // @param resourceId int
  10. // @return item *SmartReportResource
  11. // @return err error
  12. func GetResourceItemById(resourceId int) (item *SmartReportResource, err error) {
  13. err = global.MYSQL["rddp"].Model(SmartReportResource{}).
  14. Select("*").
  15. Where("resource_id = ? ", resourceId).First(&item).Error
  16. return
  17. }
  18. // GetResourceItemListByIdList
  19. // @Description: 根据资源id列表获取信息列表
  20. // @author: Roc
  21. // @datetime 2024-06-21 17:00:31
  22. // @param resourceIdList []int
  23. // @return items []*SmartReportResource
  24. // @return err error
  25. func GetResourceItemListByIdList(resourceIdList []int) (items []*SmartReportResource, err error) {
  26. err = global.MYSQL["rddp"].Model(SmartReportResource{}).
  27. Select("*").
  28. Where("resource_id in (?) ", resourceIdList).Find(&items).Error
  29. return
  30. }