撤销修改

parent 4c175756
......@@ -459,12 +459,12 @@ public class SwaggerMapParamConfig {
));
break;
case "returnChromosome":
properties.put("sceneId", new StringSchema().description("场景ID").example("B571EF6682DB463AB2977B1055A74112"));
case "revert":
properties.put("sceneId", new StringSchema().description("场景ID").example("FAADE046165147629931D5EA6A9015E8"));
examples.put("回退版本示例", createExample(
"回退到上一个版本",
"{\n" +
" \"sceneId\": \"B571EF6682DB463AB2977B1055A74112\"\n" +
" \"sceneId\": \"FAADE046165147629931D5EA6A9015E8\"\n" +
"}"
));
break;
......@@ -552,7 +552,7 @@ public class SwaggerMapParamConfig {
return "修改时间配置请求参数";
case "updateConfig":
return "更新APS时间配置请求参数";
case "returnChromosome":
case "revert":
return "回退版本请求参数";
default:
return "请求参数";
......
......@@ -882,9 +882,9 @@ public class ResourceGanttController {
* @param params 参数Map
* @return 染色体对象
*/
@PostMapping("/returnChromosome")
@Operation(summary = "回退版本", description = "回退到上一个版本")
public R<String> returnChromosome(@RequestBody Map<String, Object> params) {
@PostMapping("/revert")
@Operation(summary = "撤销操作", description = "撤销操作")
public R<String> revert(@RequestBody Map<String, Object> params) {
String sceneId = ParamValidator.getString(params, "sceneId", "场景ID不能为空");
if (sceneId == null ) {
......@@ -892,7 +892,7 @@ public class ResourceGanttController {
}
Chromosome result = planResultService.moveChromosome(sceneId, 0);
return R.ok("回退成功");
return R.ok("撤销成功");
}
......
......@@ -220,16 +220,16 @@ public class SceneService {
int prevVersion = sceneChromsome.getVersion() - 1;
if (prevVersion == 0) {
throw new RuntimeException("当前已是第一个版本");
throw new RuntimeException("无法撤销,当前已是第一个版本");
}
sceneChromsome.setVersion(prevVersion);
redisUtils.set("SceneId."+sceneId,sceneChromsome);
Chromosome chromosome = loadChromosomeFromFile(sceneId);
System.out.println("会退的版本为"+sceneChromsome.getVersion());
if (chromosome == null) {
sceneChromsome.setVersion(sceneChromsome.getVersion() + 1);
redisUtils.set("SceneId."+sceneId,sceneChromsome);
throw new RuntimeException("回退失败,未找到上一个版本");
throw new RuntimeException("撤销操作失败,未找到上一个版本");
}
return chromosome;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment