query.go 625 B

12345678910111213141516171819
  1. package report_view_log
  2. import "hongze/hongze_yb/global"
  3. // GetByReportIdsAndUserIdAndTime 根据用户id和 报告id,创建时间筛选出用户已经浏览过的记录
  4. func GetByReportIdsAndUserIdAndTime(reportIds []int, userId uint64, createTime string) (repIds []int, err error) {
  5. var viewLog []*ReportViewLog
  6. err = global.MYSQL["rddp"].Model(ReportViewLog{}).Where("report_id in (?) and user_id = ? and create_time > ?", reportIds, userId, createTime).Scan(&viewLog).Error
  7. if err != nil {
  8. return
  9. }
  10. if len(viewLog) > 0 {
  11. for _, v := range viewLog {
  12. repIds = append(repIds, v.ReportId)
  13. }
  14. }
  15. return
  16. }