package report_view_log

import "hongze/hongze_yb/global"

// GetByReportIdsAndUserIdAndTime 根据用户id和 报告id，创建时间筛选出用户已经浏览过的记录
func GetByReportIdsAndUserIdAndTime(reportIds []int, userId uint64, createTime string) (repIds []int, err error)   {
	var viewLog []*ReportViewLog
	err = global.MYSQL["rddp"].Model(ReportViewLog{}).Where("report_id in (?) and user_id = ? and create_time > ?", reportIds, userId, createTime).Scan(&viewLog).Error
	if err != nil {
		return
	}

	if len(viewLog) > 0 {
		for _, v := range viewLog {
			repIds = append(repIds, v.ReportId)
		}
	}
	return
}
