favorite.go 487 B

123456789101112131415161718192021222324
  1. package dao
  2. import (
  3. "fmt"
  4. "github.com/RaymondCode/simple-demo/entities"
  5. "strconv"
  6. )
  7. func GetFavoriteVideoList(idList []string) []entities.Video {
  8. var videoIdList []int64
  9. for i := 0; i < len(idList); i++ {
  10. val, _ := strconv.ParseInt(idList[i], 10, 64)
  11. videoIdList = append(videoIdList, val)
  12. }
  13. var temp []entities.Video
  14. Db.Table("video").Where("id In ?", videoIdList).Debug().Find(&temp)
  15. for i := 0; i < len(temp); i++ {
  16. fmt.Printf("%+d\n", temp[i])
  17. }
  18. return temp
  19. }