query.go 914 B

12345678910111213141516171819202122
  1. package yb_activity_remind
  2. import "hongze/hongze_yb/global"
  3. type UserRemind struct {
  4. ActivityRemindID int `json:"activityRemindId"`
  5. UserId int `json:"userId"`
  6. ActivityId int `json:"activityId"`
  7. }
  8. // RemindExist 根据用户ID和活动ID获取提醒信息
  9. func RemindExist(userId, activityId int) (remind *YbActivityRemind, err error) {
  10. err = global.DEFAULT_MYSQL.Table("yb_activity_remind").Where("user_id = ? AND activity_id = ?", userId, activityId).First(&remind).Error
  11. return
  12. }
  13. // GetRemindsByUserIdAndActivityIds 根据用户ID和活动IDs获取提醒信息
  14. func GetRemindsByUserIdAndActivityIds(userId int, activityIds []int) (reminds []UserRemind, err error) {
  15. fields := []string{"activity_remind_id", "user_id", "activity_id"}
  16. err = global.DEFAULT_MYSQL.Model(YbActivityRemind{}).Select(fields).Where("user_id = ? AND activity_id IN (?)", userId, activityIds).Scan(&reminds).Error
  17. return
  18. }