|
|
@ -19,6 +19,7 @@ using TaskManager.Contracts.Dtos; |
|
|
|
using TaskManager.Entity; |
|
|
|
using TaskManager.EntityFramework; |
|
|
|
using TaskManager.EntityFramework.Repository; |
|
|
|
using Wood.Util; |
|
|
|
using Wood.Util.Filters; |
|
|
|
using static Dapper.SqlMapper; |
|
|
|
|
|
|
@ -242,14 +243,19 @@ namespace TaskManager.Controllers |
|
|
|
[HttpPut("{id}")] |
|
|
|
public async Task<IActionResult> Update(T entity) |
|
|
|
{ |
|
|
|
if (entity.UId == 0) |
|
|
|
{ |
|
|
|
throw new Exception("更新时,实体主键UId不能为空或0"); |
|
|
|
} |
|
|
|
var _first = await _repository.GetByIdAsync(entity.UId); |
|
|
|
if (_first == null) |
|
|
|
{ |
|
|
|
throw new Exception($"CheryRecurringJobInputPageController.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 = "修改成功!" }); |
|
|
|
} |
|
|
|
|
|
|
|