Jelajahi Sumber

修改保存接口

mxd 4 tahun lalu
induk
melakukan
4542fa5453

+ 13 - 0
src/main/java/org/ssssssss/magicapi/model/ApiInfo.java

@@ -62,6 +62,11 @@ public class ApiInfo {
 	 */
 	private String responseHeader;
 
+	/**
+	 * 接口描述
+	 */
+	private String description;
+
 	/**
 	 * 接口选项json->map
 	 */
@@ -147,6 +152,14 @@ public class ApiInfo {
 		this.optionMap = optionMap;
 	}
 
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
 	public String getOption() {
 		return option;
 	}

+ 8 - 7
src/main/java/org/ssssssss/magicapi/provider/impl/DefaultApiServiceProvider.java

@@ -14,6 +14,7 @@ public class DefaultApiServiceProvider extends BeanPropertyRowMapper<ApiInfo> im
 			"api_name,\n" +
 			"api_group_id,\n" +
 			"api_path,\n" +
+			"api_description,\n" +
 			"api_method";
 
 	private final String SCRIPT_COLUMNS = "api_script,\n" +
@@ -72,23 +73,23 @@ public class DefaultApiServiceProvider extends BeanPropertyRowMapper<ApiInfo> im
 		return template.queryForObject(exists, Integer.class, method, path, groupId) > 0;
 	}
 
-	public boolean existsWithoutId(String groupPrefix, String method, String path, String id) {
-		String existsWithoutId = "select count(*) from magic_api_info where api_method = ? and api_path = ? and api_group_prefix = ? and id !=?";
-		return template.queryForObject(existsWithoutId, Integer.class, method, path, groupPrefix, id) > 0;
+	public boolean existsWithoutId(String groupId, String method, String path, String id) {
+		String existsWithoutId = "select count(*) from magic_api_info where api_method = ? and api_path = ? and api_group_id = ? and id !=?";
+		return template.queryForObject(existsWithoutId, Integer.class, method, path, groupId, id) > 0;
 	}
 
 	public boolean insert(ApiInfo info) {
 		info.setId(UUID.randomUUID().toString().replace("-", ""));
 		wrap(info);
 		long time = System.currentTimeMillis();
-		String insert = "insert into magic_api_info(id,api_method,api_path,api_script,api_name,api_group_id,api_parameter,api_option,api_response_body,api_response_header,api_create_time,api_update_time) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
-		return template.update(insert, info.getId(), info.getMethod(), info.getPath(), info.getScript(), info.getName(), info.getGroupId(), info.getParameter(), info.getOption(), info.getResponseBody(), info.getResponseHeader(), time, time) > 0;
+		String insert = "insert into magic_api_info(id,api_method,api_path,api_script,api_name,api_group_id,api_parameter,api_description,api_option,api_response_body,api_response_header,api_create_time,api_update_time) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+		return template.update(insert, info.getId(), info.getMethod(), info.getPath(), info.getScript(), info.getName(), info.getGroupId(), info.getParameter(), info.getDescription(), info.getOption(), info.getResponseBody(), info.getResponseHeader(), time, time) > 0;
 	}
 
 	public boolean update(ApiInfo info) {
 		wrap(info);
-		String update = "update magic_api_info set api_method = ?,api_path = ?,api_script = ?,api_name = ?,api_group_id = ?,api_parameter = ?,api_option = ?,api_response_body = ?,api_response_header = ?,api_update_time = ? where id = ?";
-		return template.update(update, info.getMethod(), info.getPath(), info.getScript(), info.getName(), info.getGroupId(), info.getParameter(), info.getOption(), info.getResponseBody(), info.getResponseHeader(), System.currentTimeMillis(), info.getId()) > 0;
+		String update = "update magic_api_info set api_method = ?,api_path = ?,api_script = ?,api_name = ?,api_group_id = ?,api_description = ?,api_parameter = ?,api_option = ?,api_response_body = ?,api_response_header = ?,api_update_time = ? where id = ?";
+		return template.update(update, info.getMethod(), info.getPath(), info.getScript(), info.getName(), info.getGroupId(), info.getDescription(), info.getParameter(), info.getOption(), info.getResponseBody(), info.getResponseHeader(), System.currentTimeMillis(), info.getId()) > 0;
 	}
 
 	@Override