collectionInfo.go 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package model
  2. import (
  3. MC "app.yhyue.com/moapp/jybase/common"
  4. ME "app.yhyue.com/moapp/jybase/encrypt"
  5. "jyBXBase/rpc/bxbase"
  6. IC "jyBXBase/rpc/init"
  7. "strings"
  8. )
  9. //是否收藏
  10. func MakeCollection(userId string, list []*bxbase.NewestList) {
  11. if list == nil || len(list) == 0 {
  12. return
  13. }
  14. param := []interface{}{userId}
  15. wh := []string{}
  16. for _, v := range list {
  17. array := ME.DecodeArticleId2ByCheck(v.Id)
  18. if len(array) == 1 && array[0] != "" {
  19. param = append(param, array[0])
  20. wh = append(wh, "?")
  21. }
  22. }
  23. if len(wh) > 0 {
  24. result := IC.MainMysql.SelectBySql(`select bid from bdcollection where userid=? and bid in (`+strings.Join(wh, ",")+`)`, param...)
  25. bid_map := map[string]bool{}
  26. if result != nil {
  27. for _, v := range *result {
  28. bid_map[ME.EncodeArticleId2ByCheck(MC.ObjToString(v["bid"]))] = true
  29. }
  30. }
  31. for _, v := range list {
  32. if !IC.C.FileSignBool {
  33. v.FileExists = false
  34. }
  35. if bid_map[v.Id] {
  36. v.IsCol = true
  37. }
  38. }
  39. }
  40. }