更新方法升级
This commit is contained in:
@@ -60,7 +60,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpPost]
|
||||
public async Task<Result> Page(QueryPageCondition queryCondition)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.CommonPage(queryCondition));
|
||||
return Result.Success().SetData(await _repository.CommonPageAsync(queryCondition));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,7 +84,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpPut]
|
||||
public async Task<Result> Update(T entity)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.UpdateAsync(entity));
|
||||
return Result.Success().SetStatus(await _repository.UpdateIgnoreNullAsync(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -96,7 +96,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpDelete]
|
||||
public async Task<Result> DeleteList(List<long> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.DeleteByLogic(ids));
|
||||
return Result.Success().SetStatus(await _repository.DeleteByLogicAsync(ids));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -15,8 +15,9 @@ namespace Yi.Framework.Repository
|
||||
{
|
||||
public Task<T> InsertReturnEntityAsync(T entity);
|
||||
public Task<List<S>> StoreAsync<S>(string storeName, object para);
|
||||
public Task<PageModel<List<T>>> CommonPage(QueryPageCondition pars);
|
||||
public Task<PageModel<List<T>>> CommonPageAsync(QueryPageCondition pars);
|
||||
public Task<List<T>> GetListAsync(QueryCondition pars);
|
||||
public Task<bool> DeleteByLogic(List<long> ids);
|
||||
public Task<bool> DeleteByLogicAsync(List<long> ids);
|
||||
public Task<bool> UpdateIgnoreNullAsync(T entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,22 @@ namespace Yi.Framework.Repository
|
||||
return await Db.Insertable(entity).ExecuteReturnEntityAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新忽略空值
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateIgnoreNullAsync(T entity)
|
||||
{
|
||||
return await Db.Updateable(entity).IgnoreColumns(true).ExecuteCommandAsync()>0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑多删除
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DeleteByLogic(List<long> ids)
|
||||
public async Task<bool> DeleteByLogicAsync(List<long> ids)
|
||||
{
|
||||
var entitys = await Db.Queryable<T>().Where(u => ids.Contains(u.Id)).ToListAsync();
|
||||
entitys.ForEach(u=>u.IsDeleted=true);
|
||||
@@ -74,7 +85,7 @@ namespace Yi.Framework.Repository
|
||||
/// 仓储扩展方法:单表查询通用分页
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<PageModel<List<T>>> CommonPage(QueryPageCondition pars)
|
||||
public async Task<PageModel<List<T>>> CommonPageAsync(QueryPageCondition pars)
|
||||
{
|
||||
RefAsync<int> tolCount = 0;
|
||||
var result = await QueryConditionHandler(new QueryCondition() {OrderBys=pars.OrderBys,Parameters=pars.Parameters } ).ToPageListAsync(pars.Index, pars.Size, tolCount);
|
||||
|
||||
Reference in New Issue
Block a user