query.go 651 B

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