query.go 970 B

123456789101112131415161718192021222324252627282930
  1. package research_report
  2. import (
  3. "errors"
  4. "hongze/hongze_yb/global"
  5. "hongze/hongze_yb/utils"
  6. )
  7. // GetByResearchReportId 根据id获取信息
  8. func GetByResearchReportId(researchReportId uint64) (item *ResearchReport, err error) {
  9. err = global.DEFAULT_MYSQL.Where("research_report_id = ? ", researchReportId).First(&item).Error
  10. return
  11. }
  12. // GetByWhereMap 根据查询条件map获取信息
  13. func GetByWhereMap(where map[string]interface{}) (item *ResearchReport, err error) {
  14. cond, whereVal, buildErr := utils.WhereBuild(where)
  15. if buildErr != nil {
  16. err = errors.New("系统异常,生成查询语句失败")
  17. return
  18. }
  19. err = global.DEFAULT_MYSQL.Where(cond, whereVal...).First(&item).Error
  20. return
  21. }
  22. // GetListByResearchReportIds 根据ids获取报告集合
  23. func GetListByResearchReportIds(ids []int) (list []*ResearchReport, err error) {
  24. err = global.DEFAULT_MYSQL.Model(ResearchReport{}).Where("research_report_id IN (?)", ids).Scan(&list).Error
  25. return
  26. }