diff --git a/README.md b/README.md
index 952bf2cc..585a61d6 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ magic-api 是一个基于Java的接口快速开发框架,编写接口将通过
org.ssssssss
magic-api-spring-boot-starter
- 1.4.2
+ 1.4.3
```
## 修改application.properties
diff --git a/magic-api-spring-boot-starter/pom.xml b/magic-api-spring-boot-starter/pom.xml
index 8ba610b9..fc9ba7ba 100644
--- a/magic-api-spring-boot-starter/pom.xml
+++ b/magic-api-spring-boot-starter/pom.xml
@@ -6,7 +6,7 @@
org.ssssssss
magic-api-parent
- 1.4.2
+ 1.4.3
magic-api-spring-boot-starter
jar
diff --git a/magic-api/pom.xml b/magic-api/pom.xml
index 89de7fda..c4c20240 100644
--- a/magic-api/pom.xml
+++ b/magic-api/pom.xml
@@ -6,7 +6,7 @@
org.ssssssss
magic-api-parent
- 1.4.2
+ 1.4.3
magic-api
jar
diff --git a/magic-api/src/main/java/org/ssssssss/magicapi/adapter/DialectAdapter.java b/magic-api/src/main/java/org/ssssssss/magicapi/adapter/DialectAdapter.java
index f226ef43..bed03be5 100644
--- a/magic-api/src/main/java/org/ssssssss/magicapi/adapter/DialectAdapter.java
+++ b/magic-api/src/main/java/org/ssssssss/magicapi/adapter/DialectAdapter.java
@@ -28,7 +28,7 @@ public DialectAdapter() {
}
public void add(Dialect dialect) {
- this.dialectList.add(dialect);
+ this.dialectList.add(0, dialect);
}
public Dialect getDialectFromConnection(Connection connection) {
diff --git a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicAPIController.java b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicAPIController.java
index e001b137..33e529c3 100644
--- a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicAPIController.java
+++ b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicAPIController.java
@@ -1,5 +1,6 @@
package org.ssssssss.magicapi.controller;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -8,6 +9,7 @@
import org.ssssssss.magicapi.interceptor.Authorization;
import org.ssssssss.magicapi.model.ApiInfo;
import org.ssssssss.magicapi.model.Backup;
+import org.ssssssss.magicapi.model.Constants;
import org.ssssssss.magicapi.model.JsonBean;
import javax.servlet.http.HttpServletRequest;
@@ -33,7 +35,9 @@ public MagicAPIController(MagicConfiguration configuration) {
@ResponseBody
@Valid(readonly = false)
public JsonBean delete(HttpServletRequest request, String id) {
- isTrue(allowVisit(request, Authorization.DELETE, getApiInfo(id)), PERMISSION_INVALID);
+ ApiInfo apiInfo = getApiInfo(id);
+ isTrue(allowVisit(request, Authorization.DELETE, apiInfo), PERMISSION_INVALID);
+ isTrue(!Constants.LOCK.equals(apiInfo.getLock()), RESOURCE_LOCKED);
return new JsonBean<>(magicAPIService.deleteApi(id));
}
@@ -102,6 +106,7 @@ public JsonBean apiMove(HttpServletRequest request, String id, String g
// 新的分组ID
apiInfo.setGroupId(groupId);
isTrue(allowVisit(request, Authorization.SAVE, apiInfo), PERMISSION_INVALID);
+ isTrue(!Constants.LOCK.equals(apiInfo.getLock()), RESOURCE_LOCKED);
return new JsonBean<>(magicAPIService.moveApi(id, groupId));
}
@@ -113,10 +118,36 @@ public JsonBean apiMove(HttpServletRequest request, String id, String g
@Valid(readonly = false)
public JsonBean save(HttpServletRequest request, @RequestBody ApiInfo info) {
isTrue(allowVisit(request, Authorization.SAVE, info), PERMISSION_INVALID);
+ if (StringUtils.isNotBlank(info.getId())) {
+ ApiInfo oldInfo = getApiInfo(info.getId());
+ isTrue(!Constants.LOCK.equals(oldInfo.getLock()), RESOURCE_LOCKED);
+ }
return new JsonBean<>(magicAPIService.saveApi(info));
}
- private ApiInfo getApiInfo(String id){
+ /**
+ * 锁定接口
+ */
+ @RequestMapping("/lock")
+ @ResponseBody
+ @Valid(readonly = false)
+ public JsonBean lock(HttpServletRequest request, String id) {
+ isTrue(allowVisit(request, Authorization.LOCK, getApiInfo(id)), PERMISSION_INVALID);
+ return new JsonBean<>(magicAPIService.lockApi(id));
+ }
+
+ /**
+ * 解锁接口
+ */
+ @RequestMapping("/unlock")
+ @ResponseBody
+ @Valid(readonly = false)
+ public JsonBean unlock(HttpServletRequest request, String id) {
+ isTrue(allowVisit(request, Authorization.UNLOCK, getApiInfo(id)), PERMISSION_INVALID);
+ return new JsonBean<>(magicAPIService.unlockApi(id));
+ }
+
+ private ApiInfo getApiInfo(String id) {
ApiInfo apiInfo = magicAPIService.getApiInfo(id);
notNull(apiInfo, API_NOT_FOUND);
return apiInfo;
diff --git a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicDebugHandler.java b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicDebugHandler.java
index 71b3e75d..e74a04c8 100644
--- a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicDebugHandler.java
+++ b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicDebugHandler.java
@@ -1,8 +1,8 @@
package org.ssssssss.magicapi.controller;
+import org.apache.commons.lang3.StringUtils;
import org.ssssssss.magicapi.config.Message;
import org.ssssssss.magicapi.config.MessageType;
-import org.ssssssss.magicapi.config.WebSocketSessionManager;
import org.ssssssss.magicapi.model.MagicConsoleSession;
import org.ssssssss.script.MagicScriptDebugContext;
@@ -40,10 +40,13 @@ public boolean setBreakPoint(MagicConsoleSession session, String breakpoints) {
* 当本机没有该Session时,通知其他机器处理
*/
@Message(MessageType.RESUME_BREAKPOINT)
- public boolean resumeBreakpoint(MagicConsoleSession session, String stepInto) {
+ public boolean resumeBreakpoint(MagicConsoleSession session, String stepInto, String breakpoints) {
MagicScriptDebugContext context = session.getMagicScriptDebugContext();
if (context != null) {
context.setStepInto("1".equals(stepInto));
+ if(StringUtils.isNotBlank(breakpoints)){
+ context.setBreakpoints(Stream.of(breakpoints.split("\\|")).map(Integer::valueOf).collect(Collectors.toList()));
+ }
try {
context.singal();
} catch (InterruptedException ignored) {
diff --git a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicFunctionController.java b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicFunctionController.java
index 93498bd6..70c4ee8a 100644
--- a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicFunctionController.java
+++ b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicFunctionController.java
@@ -1,5 +1,6 @@
package org.ssssssss.magicapi.controller;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -7,6 +8,7 @@
import org.ssssssss.magicapi.config.Valid;
import org.ssssssss.magicapi.interceptor.Authorization;
import org.ssssssss.magicapi.model.Backup;
+import org.ssssssss.magicapi.model.Constants;
import org.ssssssss.magicapi.model.FunctionInfo;
import org.ssssssss.magicapi.model.JsonBean;
@@ -63,6 +65,7 @@ public JsonBean move(HttpServletRequest request, String id, String grou
FunctionInfo functionInfo = getFunctionInfo(id);
functionInfo.setGroupId(groupId);
isTrue(allowVisit(request, Authorization.SAVE, functionInfo), PERMISSION_INVALID);
+ isTrue(!Constants.LOCK.equals(functionInfo.getLock()), RESOURCE_LOCKED);
return new JsonBean<>(magicAPIService.moveFunction(id, groupId));
}
@@ -72,6 +75,10 @@ public JsonBean move(HttpServletRequest request, String id, String grou
@Valid(readonly = false)
public JsonBean save(HttpServletRequest request, @RequestBody FunctionInfo functionInfo) {
isTrue(allowVisit(request, Authorization.SAVE, functionInfo), PERMISSION_INVALID);
+ if (StringUtils.isNotBlank(functionInfo.getId())) {
+ FunctionInfo oldInfo = getFunctionInfo(functionInfo.getId());
+ isTrue(!Constants.LOCK.equals(oldInfo.getLock()), RESOURCE_LOCKED);
+ }
return new JsonBean<>(magicAPIService.saveFunction(functionInfo));
}
@@ -79,10 +86,34 @@ public JsonBean save(HttpServletRequest request, @RequestBody FunctionIn
@ResponseBody
@Valid(readonly = false)
public JsonBean delete(HttpServletRequest request, String id) {
- isTrue(allowVisit(request, Authorization.DELETE, getFunctionInfo(id)), PERMISSION_INVALID);
+ FunctionInfo info = getFunctionInfo(id);
+ isTrue(allowVisit(request, Authorization.DELETE, info), PERMISSION_INVALID);
+ isTrue(!Constants.LOCK.equals(info.getLock()), RESOURCE_LOCKED);
return new JsonBean<>(magicAPIService.deleteFunction(id));
}
+ /**
+ * 锁定函数
+ */
+ @RequestMapping("/function/lock")
+ @ResponseBody
+ @Valid(readonly = false)
+ public JsonBean lock(HttpServletRequest request, String id) {
+ isTrue(allowVisit(request, Authorization.LOCK, getFunctionInfo(id)), PERMISSION_INVALID);
+ return new JsonBean<>(magicAPIService.lockFunction(id));
+ }
+
+ /**
+ * 解锁函数
+ */
+ @RequestMapping("/function/unlock")
+ @ResponseBody
+ @Valid(readonly = false)
+ public JsonBean unlock(HttpServletRequest request, String id) {
+ isTrue(allowVisit(request, Authorization.UNLOCK, getFunctionInfo(id)), PERMISSION_INVALID);
+ return new JsonBean<>(magicAPIService.unlockFunction(id));
+ }
+
public FunctionInfo getFunctionInfo(String id) {
FunctionInfo functionInfo = magicAPIService.getFunctionInfo(id);
notNull(functionInfo, FUNCTION_NOT_FOUND);
diff --git a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicGroupController.java b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicGroupController.java
index fb7637c0..babaca32 100644
--- a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicGroupController.java
+++ b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicGroupController.java
@@ -70,4 +70,22 @@ public JsonBean createGroup(HttpServletRequest request, @RequestBody Gro
isTrue(allowVisit(request, Authorization.SAVE, group), PERMISSION_INVALID);
return new JsonBean<>(magicAPIService.createGroup(group));
}
+
+ /**
+ * 复制分组
+ */
+ @RequestMapping("/group/copy")
+ @ResponseBody
+ @Valid(readonly = false)
+ public JsonBean copyGroup(HttpServletRequest request, String src, String target) {
+ Group group = magicAPIService.getGroup(src);
+ notNull(group, GROUP_NOT_FOUND);
+ if(!"0".equals(target)){
+ Group targetGroup = magicAPIService.getGroup(target);
+ notNull(targetGroup, GROUP_NOT_FOUND);
+ isTrue(allowVisit(request, Authorization.SAVE, targetGroup), PERMISSION_INVALID);
+ }
+ isTrue(allowVisit(request, Authorization.VIEW, group), PERMISSION_INVALID);
+ return new JsonBean<>(magicAPIService.copyGroup(src, target));
+ }
}
diff --git a/magic-api/src/main/java/org/ssssssss/magicapi/controller/RequestHandler.java b/magic-api/src/main/java/org/ssssssss/magicapi/controller/RequestHandler.java
index d4f3ff91..79c77f87 100644
--- a/magic-api/src/main/java/org/ssssssss/magicapi/controller/RequestHandler.java
+++ b/magic-api/src/main/java/org/ssssssss/magicapi/controller/RequestHandler.java
@@ -340,7 +340,7 @@ private MagicScriptContext createMagicScriptContext(RequestEntity requestEntity,
debugContext.setCallback(variables -> {
List