提交 e0f6b694 authored 作者: mry's avatar mry

fix(web): 修改了部分bug

上级 b6fff3b6
......@@ -13,6 +13,7 @@ import org.matrix.database.vo.CommonResultObj;
import org.matrix.database.vo.MoveAction;
import org.matrix.exception.GlobalException;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
......@@ -125,6 +126,7 @@ public class MoveController {
*/
@ApiOperation(value = "修改行为以及动作")
@PutMapping
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<CommonResultObj<MoveAction>> updateMoveAction(@RequestBody MoveAction moveAction) {
Boolean update = Optional.of(moveService.updateById(moveAction.getMove()))
.orElseThrow(GlobalException::new);
......@@ -136,8 +138,8 @@ public class MoveController {
action -> action.setMoveId(id)
);
Boolean saveOrUpdate = Optional.of(actionService.saveOrUpdateBatch(moveAction.getAction()))
.orElseThrow(() -> new GlobalException("修改失败"));
return update && saveOrUpdate
.orElseThrow(() -> new GlobalException("失败"));
return update
? CommonResult.success(moveAction, "修改成功")
: CommonResult.failed(moveAction, "修改失败");
}
......
......@@ -14,6 +14,7 @@ import org.matrix.database.vo.MoveAction;
import org.matrix.database.vo.TestCaseData;
import org.matrix.exception.GlobalException;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
......@@ -127,6 +128,7 @@ public class TestCaseController {
*/
@ApiOperation(value = "修改用例以及数据组")
@PutMapping
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<CommonResultObj<TestCaseData>> updateTestCaseData(@RequestBody TestCaseData testCaseData) {
Boolean update = Optional.of(testCaseService.updateById(testCaseData.getTestCase()))
.orElseThrow(GlobalException::new);
......@@ -139,7 +141,7 @@ public class TestCaseController {
.orElseThrow(GlobalException::new);
Boolean saveOrUpdate = Optional.of(testDataService.saveOrUpdateBatch(testCaseData.getTestData()))
.orElseThrow(() -> new GlobalException("失败"));
return update && saveOrUpdate
return update
? CommonResult.success(testCaseData, "修改成功")
: CommonResult.failed(testCaseData, "修改失败");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论