WYB
2021-03-22 91b8cdad021ab052e4991f3d41834a6f0ddc36b8
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
using JiepeiWMS.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Threading.Tasks;
 
namespace JiepeiWMS.IServices.BASE
{
    public interface IBaseServices<TEntity> where TEntity : class
    {
 
        Task<TEntity> QueryById(object objId);
        Task<TEntity> QueryById(object objId, bool blnUseCache = false);
        Task<List<TEntity>> QueryByIDs(object[] lstIds);
 
        Task<int> Add(TEntity model);
 
 
        /// <summary>
        /// 返回一个模型
        /// </summary>
        /// <param name="departId"></param>
        /// <returns></returns>
        Task<TEntity> GetModel(Expression<Func<TEntity, bool>> where);
 
        Task<int> Add(List<TEntity> listEntity);
 
        Task<bool> DeleteById(object id);
 
        Task<bool> Delete(TEntity model);
 
        Task<bool> DeleteByIds(object[] ids);
 
        Task<bool> Update(params TEntity[] models);
        Task<bool> Update(TEntity entity, string strWhere);
 
        Task<bool> Update(object operateAnonymousObjects);
 
        Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = "");
 
        Task<List<TEntity>> Query();
        Task<List<TEntity>> Query(string strWhere);
        Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression);
        Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);
        Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
        Task<List<TEntity>> Query(string strWhere, string strOrderByFileds);
        Task<List<TEntity>> QuerySql(string strSql, SugarParameter[] parameters = null);
        Task<DataTable> QueryTable(string strSql, SugarParameter[] parameters = null);
 
        /// <summary>
        /// 根据sql语句查询DataSet集合
        /// </summary>
        /// <param name="strSql">完整的sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>DataTable</returns>
        Task<DataSet> QueryTableSet(string strSql, SugarParameter[] parameters = null);
 
        Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);
        Task<List<TEntity>> Query(string strWhere, int intTop, string strOrderByFileds);
 
        Task<List<TEntity>> Query(
            Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);
        Task<List<TEntity>> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);
 
 
        Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);
        #region 2表关联查询
        Task<PageModel<T>> QueryPage<T, T2>(Expression<Func<T, T2, object[]>> joinExpression,
            Expression<Func<T, T2, T>> selectExpression,
            Expression<Func<T, T2, bool>> whereExpression,
            int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new();
        #endregion
        #region 5表关联查询
        Task<PageModel<TResult>> QueryPage<T, T2, T3, T4, T5, TResult>(
                    Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression,
                    Expression<Func<T, T2, T3, T4, T5, TResult>> selectExpression,
                    Expression<Func<T, T2, T3, T4, T5, bool>> whereExpression,
                    int intPageIndex = 1,
                    int intPageSize = 20,
                    string strOrderByFileds = null);
        #endregion
        #region 6表关联查询
        /// <summary>
        /// 六表联合查询-分页
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体1</typeparam>
        /// <typeparam name="T3">实体1</typeparam>
        /// <typeparam name="T4">实体1</typeparam>
        /// <typeparam name="T5">实体1</typeparam>
        /// <typeparam name="T6">实体1</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="JoinExpression">关联表达式</param>
        /// <param name="SelectExpression">返回表达式</param>
        /// <param name="WhereExpression">查询表达式</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页大小</param>
        /// <param name="OrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryPage<T, T2, T3, T4, T5, T6, TResult>(
            Expression<Func<T, T2, T3, T4, T5, T6, object[]>> JoinExpression,
            Expression<Func<T, T2, T3, T4, T5, T6, TResult>> SelectExpression,
            Expression<Func<T, T2, T3, T4, T5, T6, bool>> WhereExpression,
            int PageIndex = 1,
            int PageSize = 20,
            string OrderByFileds = null);
        #endregion
        /// <summary>
        /// 两表联合查询-分页
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体1</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式</param>
        /// <param name="selectExpression">返回表达式</param>
        /// <param name="whereExpression">查询表达式</param>
        /// <param name="intPageIndex">页码</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryTabsPage<T, T2, TResult>(
            Expression<Func<T, T2, object[]>> joinExpression,
            Expression<Func<T, T2, TResult>> selectExpression,
            Expression<Func<TResult, bool>> whereExpression,
            int intPageIndex = 1,
            int intPageSize = 20,
            string strOrderByFileds = null);
 
        /// <summary>
        ///  三表联合查询-分页
        /// </summary>
        /// <typeparam name="T">实体</typeparam>
        /// <typeparam name="T2">实体</typeparam>
        /// <typeparam name="T3">实体</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式</param>
        /// <param name="selectExpression">返回表达式</param>
        /// <param name="whereExpression">查询表达式</param>
        /// <param name="intPageIndex">页码</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryTabsPage<T, T2, T3, TResult>(
              Expression<Func<T, T2, T3, object[]>> joinExpression,
              Expression<Func<T, T2, T3, TResult>> selectExpression,
              Expression<Func<TResult, bool>> whereExpression,
              int intPageIndex = 1,
              int intPageSize = 20,
              string strOrderByFileds = null);
        /// <summary>
        /// 四表联合查询-分页
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体1</typeparam>
        /// <typeparam name="T3">实体1</typeparam>
        /// <typeparam name="T4">实体1</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式</param>
        /// <param name="selectExpression">返回表达式</param>
        /// <param name="whereExpression">查询表达式</param>
        /// <param name="intPageIndex">页码</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryTabsPage<T, T2, T3, T4, TResult>(
           Expression<Func<T, T2, T3, T4, object[]>> joinExpression,
           Expression<Func<T, T2, T3, T4, TResult>> selectExpression,
           Expression<Func<TResult, bool>> whereExpression,
           int intPageIndex = 1,
           int intPageSize = 20,
           string strOrderByFileds = null);
        /// <summary>
        /// 五表联合查询-分页
        /// </summary>
        /// <typeparam name="T">实体1</typeparam>
        /// <typeparam name="T2">实体1</typeparam>
        /// <typeparam name="T3">实体1</typeparam>
        /// <typeparam name="T4">实体1</typeparam>
        /// <typeparam name="T5">实体1</typeparam>
        /// <typeparam name="TResult">返回对象</typeparam>
        /// <param name="joinExpression">关联表达式</param>
        /// <param name="selectExpression">返回表达式</param>
        /// <param name="whereExpression">查询表达式</param>
        /// <param name="intPageIndex">页码</param>
        /// <param name="intPageSize">页大小</param>
        /// <param name="strOrderByFileds">排序字段</param>
        /// <returns></returns>
        Task<PageModel<TResult>> QueryTabsPage<T, T2, T3, T4, T5, TResult>(
                    Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression,
                    Expression<Func<T, T2, T3, T4, T5, TResult>> selectExpression,
                    Expression<Func<TResult, bool>> whereExpression,
                    int intPageIndex = 1,
                    int intPageSize = 20,
                    string strOrderByFileds = null);
 
        Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(
            Expression<Func<T, T2, T3, object[]>> joinExpression,
            Expression<Func<T, T2, T3, TResult>> selectExpression,
            Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new();
 
        /// <summary>
        /// 更新关联表信息(存在则保留,不存在则新增,符合删除条件则删除,且FieldNames中未指定的字段必须为存在默认值)
        /// </summary>
        /// <param name="TableName">关联表表名</param>
        /// <param name="FieldNames">字段名列表,例如:[UserId(用户Id),RoleId(角色Id)...]</param>
        /// <param name="Values">值列表:[{UserId:1,RoleId:2,...},{UserId:1,RoleId:3,...},{UserId:1,RoleId:5,...}]</param>
        /// <param name="DelWhereFieldNames">字段名列表,例如:[UserId(用户Id)...]</param>
        /// <param name="DelWhereValues">值列表:[{UserId:1,...},{UserId:2,...}]</param>
        /// <returns>错误信息,空则成功</returns>
        string UpdateJoinInfo(string TableName, IList<string> FieldNames, IList<object> Values, IList<string> DelWhereFieldNames = null, IList<object> DelWhereValues = null);
    }
 
}