新框架PC后端代码(祈禧6月初版本)
南骏 池
3 天以前 72449a1b8699b65712e57fba8abce5a8240e9465
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using Newtonsoft.Json;
 
namespace Gs.Toolbox;
 
public class ReturnDto<T>
{
    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; }
 
 
    /// <summary>
    ///     快速返回数据
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="t"></param>
    /// <returns></returns>
    public static ReturnDto<T> QuickReturn<T>(T t, ReturnCode code,
        string msg)
    {
        var result = new ReturnDto<T>();
        result.RtnData = t;
        result.RtnCode = code;
        result.RtnMsg = msg;
        return result;
    }
}
 
public enum ReturnCode
{
    Default = -100, //默认
    Unauthorized = -101, //非法调用
    Exception = -102, //系统代码异常
    Success = 1 //成功
}
 
/// <summary>
///     分页列表
/// </summary>
/// <typeparam name="t"></typeparam>
public class PageList<t>
{
    public PageList(List<t> items, int totalCount, int everyPageSize)
    {
        total = totalCount;
        list = items;
        this.everyPageSize = everyPageSize;
        pages = (int)Math.Ceiling((decimal)totalCount / everyPageSize);
    }
 
    public PageList()
    {
    }
 
    /// <summary>
    ///     列表
    /// </summary>
    public List<t> list { get; set; }
 
    /// <summary>
    ///     总页数
    /// </summary>
    public int pages { get; set; }
 
    /// <summary>
    ///     总记录数
    /// </summary>
    public int total { get; set; }
 
    /// <summary>
    ///     每页大小
    /// </summary>
    public int everyPageSize { get; set; }
 
    /// <summary>
    ///     扩展用,单文本,比如金额合计等其它项目
    /// </summary>
    public string? extendText { get; set; }
 
    /// <summary>
    ///     扩展用,列表
    /// </summary>
    public List<dynamic>? extendList { get; set; }
}
 
/// <summary>
///     查询实体
/// </summary>
public class PageQuery
{
    /// <summary>
    ///     当前页
    /// </summary>
    public int currentPage { get; set; }
 
    /// <summary>
    ///     每页大小
    /// </summary>
    public int everyPageSize { get; set; }
 
    /// <summary>
    ///     排序名
    /// </summary>
    public string sortName { get; set; }
 
    /// <summary>
    ///     排序方式
    /// </summary>
    public string sortOrder { get; set; }
 
    /// <summary>
    ///     查询关键字
    /// </summary>
    public string keyWord { get; set; }
 
    /// <summary>
    ///     查询表达式 and开头
    /// </summary>
    public string keyWhere { get; set; }
 
 
    /// <summary>
    /// 一个辅助用的关键字,比如用户选择状态
    /// </summary>
    public string keyType { get; set; }
   
}