using Rhea.Common; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Management; using System.Text; using System.Threading.Tasks; using Tiger.Model; namespace Tiger.IBusiness { /// /// 数据库操作基础类 /// public interface IDbBase { #region 添加操作 /// /// 把单个实体往数据库添加一行数据 /// /// /// 实体 /// 是否以异步方式执行 /// public Task> AddAsync(T entity, bool isAsync = true) where T : class, new(); /// /// 把实体List往数据库批量添加数据 /// /// /// 实体List /// 是否以异步方式执行 /// public Task> AddListAsync(List list, bool isAsync = true) where T : class, new(); #endregion #region 保存操作 /// /// 把单个实体往数据库保存一行数据,如果存在就更新,不存在就插入 /// /// /// 实体 /// 是否以异步方式执行 /// public Task> SaveAsync(T entity, bool isAsync = true) where T : class, new(); /// /// 把实体List往数据库批量保存数据,如果存在就更新,不存在就插入 /// /// /// 实体List /// 是否以异步方式执行 /// public Task> SaveListAsync(List list, bool isAsync = true) where T : class, new(); /// /// 把单个实体往数据库保存一行数据,如果存在就更新,不存在就插入 /// /// /// 实体 /// 是否以异步方式执行 /// public Task> StorageableAsync(T entity, bool isAsync = true) where T : class, new(); /// /// 把实体List往数据库批量保存数据,如果存在就更新,不存在就插入 /// /// /// 实体List /// 是否以异步方式执行 /// public Task> StorageableListAsync(List list, bool isAsync = true) where T : class, new(); #endregion #region 修改操作 /// /// 从数据库中修改单个实体 /// /// /// 实体 /// 是否以异步方式执行 /// public Task UpdateAsync(T entity, bool isAsync = true) where T : class, new(); /// /// 根据实体List在数据库批量修改数据 /// /// /// 实体List /// 是否以异步方式执行 /// public Task UpdateAsync(List list, bool isAsync = true) where T : class, new(); /// /// 按UpdaterAble<T>对象从数据库中修改多个实体的某些字段 /// /// /// 实体List /// 是否以异步方式执行 /// public Task UpdateAsync(UpdateAble updater, bool isAsync = true) where T : class, new(); #endregion #region 删除操作 /// /// 从数据库中删除多个实体 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// 实体的主键ID数组 /// 是否以异步方式执行 /// public Task DeleteAsync(T newEntity, string[] primaryKeys, bool isAsync = true) where T : class, new(); /// /// 从数据库中删除单个实体 /// /// /// 实体 /// 是否以异步方式执行 /// public Task DeleteAsync(T entity, bool isAsync = true) where T : class, new(); /// /// 从数据库中删除实体List /// /// /// 实体List /// 是否以异步方式执行 /// public Task DeleteAsync(List list, bool isAsync = true) where T : class, new(); /// /// 根据Where语句删除满足条件的数据 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// Where语句 /// 是否以异步方式执行 /// public Task DeleteAsync(T newEntity, string where, bool isAsync = true) where T : class, new(); #endregion #region 查询操作 /// /// 从数据库中查询实体 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// 是否以异步方式执行 /// public Task>> QueryAsync(T newEntity, bool isAsync = true, bool needInclude = false); /// /// 根据Where语句从数据库中查询实体 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// Where语句 /// 是否以异步方式执行 /// public Task>> QueryAsync(T newEntity, string where, bool isAsync = true, bool needInclude = false) where T : class, new(); /// /// 按PageAble<T>对象返回实体当前Page的数据 /// /// /// 分页的参数实体 /// 是否以异步方式执行 /// public Task>> QueryAsync(PageAble page, bool isAsync = true, bool needInclude = false); /// /// 分页直接返回PageAble<T> /// /// /// /// /// public Task>> QueryPageAsync(PageAble page, bool isAsync = true, bool needInclude = false); /// /// 按QueryAble<T>对象从数据库查询满足条件的数据 /// /// /// QueryAble的参数实体 /// 是否以异步方式执行 /// public Task>> QueryAsync(QueryAble query, bool isAsync = true, bool needInclude = false); /// /// 根据SQL语句从数据库中查询实体 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// SQL语句 /// 是否以异步方式执行 /// public Task>> QuerySqlAsync(T newEntity, string sqlcmd, bool isAsync = true, bool needInclude = false) where T : class, new(); /// /// 根据SQL语句从数据库中查询并按PageAble<T>对象返回当前Page的数据 /// /// /// 分页的参数实体 /// 是否以异步方式执行 /// public Task>> QuerySqlAsync(PageAble page, bool isAsync = true, bool needInclude = false) where T : class, new(); /// /// 从数据库中查询实体 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// 授权查询配置项 /// 是否以异步方式执行 /// public Task>> QueryByAuthAsync(T newEntity, AuthOption options, bool isAsync = true, bool needInclude = false) where T : iTableHasAuth, new(); /// /// 根据Where语句从数据库中查询实体 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// Where语句 /// 授权查询配置项 /// 是否以异步方式执行 /// public Task>> QueryByAuthAsync(T newEntity, string where, AuthOption options, bool isAsync = true, bool needInclude = false) where T : iTableHasAuth, new(); /// /// 按PageAble<T>对象返回实体当前Page的数据 /// /// /// 分页的参数实体 /// 授权查询配置项 /// 是否以异步方式执行 /// public Task>> QueryByAuthAsync(PageAble page, AuthOption options, bool isAsync = true, bool needInclude = false) where T : iTableHasAuth, new(); /// /// 分页直接返回PageAble<T> /// /// /// /// 授权查询配置项 /// /// public Task>> QueryByAuthPageAsync(PageAble page, AuthOption options, bool isAsync = true, bool needInclude = false) where T : iTableHasAuth, new(); /// /// 按QueryAble<T>对象从数据库查询满足条件的数据 /// /// /// QueryAble的参数实体 /// 授权查询配置项 /// 是否以异步方式执行 /// public Task>> QueryByAuthAsync(QueryAble query, AuthOption options, bool isAsync = true, bool needInclude = false) where T : iTableHasAuth, new(); #endregion #region 查询 Count /// /// 根据Where语句查询满足条件的实体的Count数量 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// Where语句 /// 是否以异步方式执行 /// public Task CountAsync(T newEntity, string where, bool isAsync = true); /// /// 根据Where语句查询满足条件的实体的Count数量 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// Where语句 /// 授权查询配置项 /// 是否以异步方式执行 /// public Task CountByAuthAsync(T newEntity, string where, AuthOption options, bool isAsync = true) where T : iTableHasAuth, new(); #endregion #region 查询 Exist /// /// 根据Where语句查询满足条件的Data实体是否存在 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// Where语句 /// 是否以异步方式执行 /// public Task IsExistAsync(T newEntity, string where, bool isAsync = true); /// /// 根据Where语句查询满足条件的Data实体是否存在 /// /// /// 固定用法:通过ApiAction.NewDataEntity()创建ApiAction中指定类型对象 /// Where语句 /// 授权查询配置项 /// 是否以异步方式执行 /// public Task IsExistByAuthAsync(T newEntity, string where, AuthOption options, bool isAsync = true) where T : iTableHasAuth, new(); #endregion #region 执行SQL /// /// 执行SQL语句返回影响行数 /// /// 要执行的SQL语句 /// SQL语句的参数 /// 是否以异步方式执行 /// public Task ExecuteSqlCommandAsync(string sqlcmd, List parameters, bool isAsync = true); /// /// 执行SQL语句返回影响行数 /// /// 要执行的SQL语句 /// SQL语句的参数 /// 是否以异步方式执行 /// public Task ExecuteSqlCommandAsync(string sqlcmd, bool isAsync = true, params SugarParameter[] parameters); /// /// 异步方式执行SQL语句返回影响行数 /// /// 要执行的SQL语句 /// SQL语句的参数 /// public Task ExecuteSqlCommandAsync(string sqlcmd, params SugarParameter[] parameters); #endregion #region 先删除后新增 public Task AddAfterDeleteAsync(QueryAble query) where T : class, new(); #endregion } }