ZhiYeJianKang_PeiXun/Song.ViewData/ListResult.cs
2025-02-20 15:41:53 +08:00

54 lines
1.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Song.ViewData
{
/// <summary>
/// 当请求的Song.ViewData方法是列表时尤其是分页数据时用该方法“包装”
/// 不管是服务端还是客户端,都要用此方法“包装”
/// </summary>
public class ListResult : DataResult
{
/// <summary>
/// 数据项的总数
/// </summary>
public int Total { get; set; }
/// <summary>
/// 当前页的数据项个数
/// </summary>
public int Size { get; set; }
/// <summary>
/// 总页数
/// </summary>
public int TotalPages
{
get
{
return (int)Math.Ceiling((double)Total / (double)Size);
}
}
/// <summary>
/// 当前页的索引起始为1
/// </summary>
public int Index { get; set; }
public ListResult()
{
}
/// <summary>
/// 构造方法
/// </summary>
/// <param name="obj"></param>
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;
}
}
}