// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
namespace Admin.NET.Core;
///
/// 实体操作基服务
///
///
public class BaseService : IDynamicApiController where TEntity : class, new()
{
private readonly SqlSugarRepository _rep;
public BaseService(SqlSugarRepository rep)
{
_rep = rep;
}
///
/// 获取实体详情
///
///
///
[DisplayName("获取实体详情")]
public virtual async Task GetDetail(long id)
{
return await _rep.GetByIdAsync(id);
}
///
/// 获取实体集合
///
///
[DisplayName("获取实体集合")]
public virtual async Task> GetList()
{
return await _rep.GetListAsync();
}
/////
///// 获取实体分页
/////
/////
/////
//[ApiDescriptionSettings(Name = "Page")]
//[DisplayName("获取实体分页")]
//public async Task> GetPage([FromQuery] BasePageInput input)
//{
// return await _rep.AsQueryable().ToPagedListAsync(input.Page, input.PageSize);
//}
///
/// 增加实体
///
///
///
[ApiDescriptionSettings(Name = "Add"), HttpPost]
[DisplayName("增加实体")]
public virtual async Task Add(TEntity entity)
{
return await _rep.InsertAsync(entity);
}
///
/// 更新实体
///
///
///
[ApiDescriptionSettings(Name = "Update"), HttpPost]
[DisplayName("更新实体")]
public virtual async Task Update(TEntity entity)
{
return await _rep.UpdateAsync(entity);
}
///
/// 删除实体
///
///
///
[ApiDescriptionSettings(Name = "Delete"), HttpPost]
[DisplayName("删除实体")]
public virtual async Task Delete(long id)
{
return await _rep.DeleteByIdAsync(id);
}
}