public IEnumerable <HouseInfo> SearchHouses(HouseSearchCondition condition) { if (string.IsNullOrEmpty(condition.Source)) { var houseList = new List <HouseInfo>(); // 因为会走几个表,默认每个表取N条 var houseSources = GetCityHouseSources(condition.CityName); var limitCount = condition.HouseCount / houseSources.Count; foreach (var houseSource in houseSources) { //建荣家园数据质量比较差,默认不出 if (houseSource == ConstConfigurationName.CCBHouse) { continue; } condition.Source = houseSource; condition.HouseCount = limitCount; houseList.AddRange(Search(condition)); } return(houseList.OrderByDescending(h => h.PubTime)); } else { return(Search(condition)); } }
public IEnumerable <HouseInfo> Search(HouseSearchCondition condition) { string redisKey = condition.RedisKey; var houses = new List <HouseInfo>(); if (!condition.Refresh) { houses = redisService.ReadSearchCache(redisKey); if (houses != null && houses.Count > 0) { return(houses); } } using (IDbConnection dbConnection = GetConnection()) { dbConnection.Open(); houses = dbConnection.Query <HouseInfo>(condition.QueryText, condition).ToList(); if (houses != null && houses.Count > 0) { redisService.WriteSearchCache(redisKey, houses); } return(houses); } }