using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Song.ViewData { /// /// 当请求的Song.ViewData方法是列表时,尤其是分页数据时,用该方法“包装” /// 不管是服务端还是客户端,都要用此方法“包装” /// public class ListResult : DataResult { /// /// 数据项的总数 /// public int Total { get; set; } /// /// 当前页的数据项个数 /// public int Size { get; set; } /// /// 总页数 /// public int TotalPages { get { return (int)Math.Ceiling((double)Total / (double)Size); } } /// /// 当前页的索引,起始为1 /// public int Index { get; set; } public ListResult() { } /// /// 构造方法 /// /// public ListResult(object obj) { this.Result = obj; Success = true; State = 1; DateTime = DateTime.Now; Timestamp = (long)(DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1))).TotalMilliseconds; } } }