Пример #1
0
        /// <summary>
        /// 获取开通城市的省市区
        /// 窦海超
        /// 2015年3月19日 17:09:53
        /// </summary>
        /// <param name="version">当前版本号</param>
        /// <param name="isResultData">是否返回所有数据,因为APP端调用时如果是最新则不需要返回AreaModelList的值</param>
        /// <returns></returns>
        public Model.Common.ResultModel <Model.DomainModel.Area.AreaModelList> GetOpenCity(string version, bool isResultData = true)
        {
            AreaModelList areaList = new AreaModelList();
            var           redis    = new ETS.NoSql.RedisCache.RedisCache();
            string        key      = RedissCacheKey.Ets_Service_Provider_Common_GetOpenCity_New;

            //if (Config.ApiVersion == version)
            //{
            //    //如果配置开通城市版本相同,则返回空数据
            //    return ResultModel<AreaModelList>.Conclude(ETS.Enums.CityStatus.Newest, null);
            //}
            string strAreaList = redis.Get <string>(key);

            if (!string.IsNullOrEmpty(strAreaList))
            {
                areaList = JsonHelper.JsonConvertToObject <AreaModelList>(strAreaList);
            }
            if (areaList.AreaModels == null || areaList.AreaModels.Count <= 0)
            {
                IList <AreaModel> list = dao.GetOpenCitySql();
                areaList            = new AreaModelList();
                areaList.AreaModels = list;
                //areaList.Version = Config.ApiVersion;
                if (list != null)
                {
                    redis.Set(key, JsonHelper.JsonConvertToString(areaList));
                    //redis.Set(key, areaList);
                }
            }
            areaList.Version = Config.ApiVersion;
            if (Config.ApiVersion == version && !isResultData)
            {
                areaList.AreaModels = null;
                return(ResultModel <AreaModelList> .Conclude(ETS.Enums.CityStatus.UnNewest, areaList));
            }
            return(ResultModel <AreaModelList> .Conclude(ETS.Enums.CityStatus.Newest, areaList));
        }