|
|
@ -74,17 +74,23 @@ namespace Wood.Service.Controllers |
|
|
|
/// </summary>
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPut("{id}")] |
|
|
|
public async virtual Task<IActionResult> Update(long UId, T entity) |
|
|
|
[HttpPut] |
|
|
|
[Route("Update/{UId}")] |
|
|
|
public async virtual Task<IActionResult> Update(T entity) |
|
|
|
{ |
|
|
|
var _first = await _repository.GetByIdAsync(UId); |
|
|
|
if (entity.UId == 0) |
|
|
|
{ |
|
|
|
throw new Exception("更新时,实体主键UId不能为空或0"); |
|
|
|
} |
|
|
|
var _first = await _repository.GetByIdAsync(entity.UId); |
|
|
|
if (_first == null) |
|
|
|
{ |
|
|
|
throw new Exception($"NormalBaseController.Update报错:根据UId{entity.UId}没有找到记录"); |
|
|
|
return new JsonResult(new { Code = 400, Message = "修改失败!" }); |
|
|
|
} |
|
|
|
EntityMapper.Trans(_first, entity, "UId"); |
|
|
|
|
|
|
|
await _repository.UpdateAsync(entity); |
|
|
|
await _repository.UpdateAsync(_first); |
|
|
|
return new JsonResult(new { Code = 200, Message = "修改成功!" }); |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
@ -313,6 +319,7 @@ namespace Wood.Service.Controllers |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
throw new Exception("NormalBaseController.Import报错:" + ex.Message); |
|
|
|
// await _logger.AddError(ex.Message, TaskName);
|
|
|
|
return new JsonResult(new { Code = 400, Message = "导入失败!" }); |
|
|
|
} |
|
|
|