derivedFiltering.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package model
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. IC "jyBXSubscribe/rpc/init"
  6. "jyBXSubscribe/rpc/type/bxsubscribe"
  7. "log"
  8. )
  9. func ScreeningList(userid string) *bxsubscribe.DeriveRes {
  10. qy := map[string]interface{}{
  11. "s_userid": userid,
  12. "filterSave": 1,
  13. }
  14. data := new(bxsubscribe.DeriveRes)
  15. allData, ok := IC.Mgo.Find("export_search", qy, `{"comeintime":-1}`, "", false, -1, -1)
  16. if ok && allData != nil && len(*allData) > 0 {
  17. for _, v := range *allData {
  18. region, _ := v["region"].([]interface{})
  19. area, _ := v["area"].([]interface{})
  20. winner, _ := v["winner"].([]interface{})
  21. industry, _ := v["industry"].([]interface{})
  22. buyer, _ := v["buyer"].([]interface{})
  23. buyerclass, _ := v["buyerclass"].([]interface{})
  24. city, _ := v["city"].([]interface{})
  25. dataOne := bxsubscribe.Derive{
  26. XId: encrypt.SE.Encode2Hex(common.InterfaceToStr(v["_id"])),
  27. Region: common.ObjArrToStringArr(region),
  28. Area: common.ObjArrToStringArr(area),
  29. Maxprice: common.InterfaceToStr(v["maxprice"]),
  30. Winner: common.ObjArrToStringArr(winner),
  31. Industry: common.ObjArrToStringArr(industry),
  32. Minprice: common.InterfaceToStr(v["minprice"]),
  33. Buyer: common.ObjArrToStringArr(buyer),
  34. Buyerclass: common.ObjArrToStringArr(buyerclass),
  35. SelectType: common.InterfaceToStr(v["selectType"]),
  36. Subtype: common.InterfaceToStr(v["subtype"]),
  37. City: common.ObjArrToStringArr(city),
  38. }
  39. keyWord1, _ := v["keywords"].([]interface{})
  40. keyWord := common.ObjArrToMapArr(keyWord1)
  41. var keys []*bxsubscribe.KeyWord
  42. for _, v1 := range keyWord {
  43. key := bxsubscribe.KeyWord{
  44. Keyword: common.InterfaceToStr(v1["keyword"]),
  45. }
  46. appended1, _ := v1["appended"].([]interface{})
  47. appended := common.ObjArrToStringArr(appended1)
  48. if len(appended) > 0 {
  49. key.Appended = appended
  50. }
  51. exclude1, _ := v1["exclude"].([]interface{})
  52. exclude := common.ObjArrToStringArr(exclude1)
  53. if len(exclude) > 0 {
  54. key.Exclude = exclude
  55. }
  56. keys = append(keys, &key)
  57. }
  58. if len(keyWord) > 0 {
  59. dataOne.Keywords = keys
  60. }
  61. data.Data = append(data.Data, &dataOne)
  62. }
  63. }
  64. return data
  65. }
  66. func ScreeningDelete(infoId string) *bxsubscribe.StatusResp {
  67. id := encrypt.SE.Decode4Hex(infoId)
  68. qy := map[string]interface{}{
  69. "filterSave": -1,
  70. }
  71. data := new(bxsubscribe.StatusResp)
  72. if !IC.Mgo.UpdateById("export_search", id, qy) {
  73. log.Printf("删除自主导出筛选条件失败:%s", infoId)
  74. data.ErrorCode = -1
  75. data.ErrorMsg = "删除自主导出筛选条件失败"
  76. }
  77. return data
  78. }