using Newtonsoft.Json; namespace Gs.Toolbox; public class ReturnDto { public ReturnDto() { RtnData = default; RtnCode = ReturnCode.Default; RtnMsg = string.Empty; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = "RtnCode")] public ReturnCode RtnCode { set; get; } [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "RtnData")] public T RtnData { set; get; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, PropertyName = "RtnMsg")] public string RtnMsg { get; set; } /// /// 快速返回数据 /// /// /// /// public static ReturnDto QuickReturn(T t, ReturnCode code, string msg) { var result = new ReturnDto(); result.RtnData = t; result.RtnCode = code; result.RtnMsg = msg; return result; } } public enum ReturnCode { Default = -100, //默认 Unauthorized = -101, //非法调用 Exception = -102, //系统代码异常 Success = 1 //成功 } /// /// 分页列表 /// /// public class PageList { public PageList(List items, int totalCount, int everyPageSize) { total = totalCount; list = items; this.everyPageSize = everyPageSize; pages = (int)Math.Ceiling((decimal)totalCount / everyPageSize); } public PageList() { } /// /// 列表 /// public List list { get; set; } /// /// 总页数 /// public int pages { get; set; } /// /// 总记录数 /// public int total { get; set; } /// /// 每页大小 /// public int everyPageSize { get; set; } /// /// 扩展用,单文本,比如金额合计等其它项目 /// public string? extendText { get; set; } /// /// 扩展用,列表 /// public List? extendList { get; set; } } /// /// 查询实体 /// public class PageQuery { /// /// 当前页 /// public int currentPage { get; set; } /// /// 每页大小 /// public int everyPageSize { get; set; } /// /// 排序名 /// public string sortName { get; set; } /// /// 排序方式 /// public string sortOrder { get; set; } /// /// 查询关键字 /// public string keyWord { get; set; } /// /// 查询表达式 and开头 /// public string keyWhere { get; set; } /// /// 一个辅助用的关键字,比如用户选择状态 /// public string keyType { get; set; } }