package model import ( "app.yhyue.com/moapp/jybase/common" "app.yhyue.com/moapp/jybase/encrypt" IC "jyBXSubscribe/rpc/init" "jyBXSubscribe/rpc/type/bxsubscribe" "log" ) func ScreeningList(userid string) *bxsubscribe.DeriveRes { qy := map[string]interface{}{ "s_userid": userid, "filterSave": 1, } data := new(bxsubscribe.DeriveRes) allData, ok := IC.Mgo.Find("export_search", qy, `{"comeintime":-1}`, "", false, -1, -1) if ok && allData != nil && len(*allData) > 0 { for _, v := range *allData { region, _ := v["region"].([]interface{}) area, _ := v["area"].([]interface{}) winner, _ := v["winner"].([]interface{}) industry, _ := v["industry"].([]interface{}) buyer, _ := v["buyer"].([]interface{}) buyerclass, _ := v["buyerclass"].([]interface{}) city, _ := v["city"].([]interface{}) dataOne := bxsubscribe.Derive{ XId: encrypt.SE.Encode2Hex(common.InterfaceToStr(v["_id"])), Region: common.ObjArrToStringArr(region), Area: common.ObjArrToStringArr(area), Maxprice: common.InterfaceToStr(v["maxprice"]), Winner: common.ObjArrToStringArr(winner), Industry: common.ObjArrToStringArr(industry), Minprice: common.InterfaceToStr(v["minprice"]), Buyer: common.ObjArrToStringArr(buyer), Buyerclass: common.ObjArrToStringArr(buyerclass), SelectType: common.InterfaceToStr(v["selectType"]), Subtype: common.InterfaceToStr(v["subtype"]), City: common.ObjArrToStringArr(city), } keyWord1, _ := v["keywords"].([]interface{}) keyWord := common.ObjArrToMapArr(keyWord1) var keys []*bxsubscribe.KeyWord for _, v1 := range keyWord { key := bxsubscribe.KeyWord{ Keyword: common.InterfaceToStr(v1["keyword"]), } appended1, _ := v1["appended"].([]interface{}) appended := common.ObjArrToStringArr(appended1) if len(appended) > 0 { key.Appended = appended } exclude1, _ := v1["exclude"].([]interface{}) exclude := common.ObjArrToStringArr(exclude1) if len(exclude) > 0 { key.Exclude = exclude } keys = append(keys, &key) } if len(keyWord) > 0 { dataOne.Keywords = keys } data.Data = append(data.Data, &dataOne) } } return data } func ScreeningDelete(infoId string) *bxsubscribe.StatusResp { id := encrypt.SE.Decode4Hex(infoId) qy := map[string]interface{}{ "filterSave": -1, } data := new(bxsubscribe.StatusResp) if !IC.Mgo.UpdateById("export_search", id, qy) { log.Printf("删除自主导出筛选条件失败:%s", infoId) data.ErrorCode = -1 data.ErrorMsg = "删除自主导出筛选条件失败" } return data }