package research_report

import (
	"errors"
	"hongze/hongze_yb/global"
	"hongze/hongze_yb/utils"
)

// GetByResearchReportId 根据id获取信息
func GetByResearchReportId(researchReportId uint64) (item *ResearchReport, err error) {
	err = global.DEFAULT_MYSQL.Where("research_report_id = ? ", researchReportId).First(&item).Error
	return
}

// GetByWhereMap 根据查询条件map获取信息
func GetByWhereMap(where map[string]interface{}) (item *ResearchReport, err error) {
	cond, whereVal, buildErr := utils.WhereBuild(where)
	if buildErr != nil {
		err = errors.New("系统异常，生成查询语句失败")
		return
	}
	err = global.DEFAULT_MYSQL.Where(cond, whereVal...).First(&item).Error
	return
}

// GetListByResearchReportIds 根据ids获取报告集合
func GetListByResearchReportIds(ids []int) (list []*ResearchReport, err error) {
	err = global.DEFAULT_MYSQL.Model(ResearchReport{}).Where("research_report_id IN (?)", ids).Scan(&list).Error
	return
}
