Ejemplo n.º 1
0
        public IActionResult RankList(string type, int count)
        {
            int rankType = 0;

            switch (type)
            {
            case "todayRank":
            {
                rankType = 1;
                break;
            }

            case "totalRank":
            {
                rankType = 2;
                break;
            }

            default:
            {
                return(WriteFail("排行类型错误"));
            }
            }
            var userId    = (int)this.UserInfo.UserId;
            var cacheType = $"{type}&{userId}";

            var data = DataCacheManager.GetItem <string, HallRankList>(cacheType);

            if (data != null)
            {
                return(Json(data));
            }

            DataSet ds = null;

            Core.DBTools.Data.DataProcedureHelper.WEB_GetRankList(userId, count, rankType, out ds);

            if (ds.Tables.Count <= 0)
            {
                return(WriteFail("没有获取到排行榜数据"));
            }
            var tb = ds.Tables[0];

            data = HallRankList.ParseDataTable(tb);
            //缓存五分钟
            this.DataCacheManager.SetItem(cacheType, data, (5 * 60));

            return(Json(data));
        }