CSharp.Template/YuanXuan.IM.Core/Interfaces/IBaseService.cs

35 lines
1.9 KiB
C#

using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using YuanXuan.IM.Common.Entities;
using YuanXuan.IM.Common.Request;
namespace YuanXuan.IM.Core.Interfaces
{
public interface IBaseService<TEntity> where TEntity : BaseEntity, new()
{
Task<bool> CreateAsync(TEntity entity);
Task<bool> CreateAsync(List<TEntity> entity);
Task<long> InsertReturnBigIdentityAsync(TEntity entity);
Task<long> CreateReturnSnowflakeIdAsync(TEntity entity);
Task<List<long>> CreateReturnSnowflakeIdAsync(List<TEntity> entity);
Task<bool> DeleteByIdsAsync(params dynamic[] ids);
Task<bool> DeleteByIdsAsync(params long[] ids);
Task<TEntity> GetByIdAsync(long id);
Task<TEntity> GetFirstAsync(System.Linq.Expressions.Expression<Func<TEntity, bool>> whereExpression);
Task<List<TEntity>> GetListAsync(System.Linq.Expressions.Expression<Func<TEntity, bool>> whereExpression = null);
Task<PageResponse<TEntity>> GetPageListAsync(PageRequest pagination, Expression<Func<TEntity, bool>> whereExpression = null);
Task<PageResponse<TEntity>> GetPageListAsync<T>(PageRequest pagination, Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression = null, OrderByType orderByType = OrderByType.Asc);
Task<PageResponse<T>> GetPageListAsync<T>(PageRequest pagination, Expression<Func<TEntity, bool>> whereExpression = null);
Task<TEntity> GetSingleAsync(System.Linq.Expressions.Expression<Func<TEntity, bool>> whereExpression);
Task<bool> UpdateAsync(TEntity entity);
Task<bool> UpdateAsync(List<TEntity> entity);
Task<bool> UpdateColumsAsync(Expression<Func<TEntity, TEntity>> columns, Expression<Func<TEntity, bool>> whereExpression);
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> whereExpression);
}
}