开始业务模块

This commit is contained in:
橙子
2023-01-25 17:48:48 +08:00
parent 80723496d0
commit 99787950a8
60 changed files with 773 additions and 60 deletions

View File

@@ -82,6 +82,12 @@ namespace Yi.Framework.Ddd.Services
return Task.CompletedTask;
}
protected virtual Task<TEntity> MapToEntityAsync(TUpdateInput updateInput)
{
var entity = _mapper.Map<TEntity>(updateInput);
return Task.FromResult(entity);
}
/// <summary>
/// 增
/// </summary>
@@ -125,12 +131,14 @@ namespace Yi.Framework.Ddd.Services
{
throw new ArgumentNullException(nameof(id));
}
var entity = await _repository.GetByIdAsync(id);
var entity = await MapToEntityAsync(input);
entity.Id = id;
await _repository.UpdateIgnoreNullAsync(entity);
await MapToEntityAsync(input, entity);
await _repository.UpdateAsync(entity);
var newEntity = await _repository.GetByIdAsync(id);
return await MapToGetOutputDtoAsync(entity);
return await MapToGetOutputDtoAsync(newEntity);
}
}
}