增加字段

This commit is contained in:
mxd 2020-12-01 23:34:00 +08:00
parent 4542fa5453
commit 52e1e5fdb2
3 changed files with 40 additions and 6 deletions

View File

@ -14,9 +14,11 @@ insert into magic_group select md5(uuid()),api_group_name,'1',api_group_prefix,'
ALTER TABLE `magic_api_info` ADD COLUMN `api_group_id` varchar(32) NULL COMMENT '分组ID' AFTER `api_name`;
ALTER TABLE `magic_api_info` CHANGE COLUMN `api_output` `api_response_body` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '输出结果' AFTER `api_group_id`, ADD COLUMN `api_response_header` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '输出Header' AFTER `api_response_body`;
ALTER TABLE `magic_api_info` ADD COLUMN `api_description` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '接口描述' AFTER `api_response_header`;
ALTER TABLE `magic_api_info` ADD COLUMN `api_request_body` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求体' AFTER `api_group_id`, ADD COLUMN `api_request_header` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求Header' AFTER `api_request_body`;
ALTER TABLE `magic_api_info_his` ADD COLUMN `api_group_id` varchar(32) NULL COMMENT '分组ID' AFTER `api_name`;
ALTER TABLE `magic_api_info_his` CHANGE COLUMN `api_output` `api_response_body` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '输出结果' AFTER `api_group_id`, ADD COLUMN `api_response_header` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '输出Header' AFTER `api_response_body`;
ALTER TABLE `magic_api_info_his` ADD COLUMN `api_description` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '接口描述' AFTER `api_response_header`;
ALTER TABLE `magic_api_info_his` ADD COLUMN `api_request_body` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求体' AFTER `api_group_id`, ADD COLUMN `api_request_header` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求Header' AFTER `api_request_body`;
-- 赋值api_group_id字段
UPDATE magic_api_info mai JOIN magic_group mg ON mg.group_name = mai.api_group_name AND mg.group_path = mai.api_group_prefix SET mai.api_group_id = mg.id;

View File

@ -52,6 +52,16 @@ public class ApiInfo {
*/
private String option;
/**
* 请求体
*/
private String requestBody;
/**
* 请求头
*/
private String requestHeader;
/**
* 输出结果
*/
@ -124,6 +134,23 @@ public class ApiInfo {
return responseBody;
}
public String getRequestBody() {
return requestBody;
}
public void setRequestBody(String requestBody) {
this.requestBody = requestBody;
}
public String getRequestHeader() {
return requestHeader;
}
public void setRequestHeader(String requestHeader) {
this.requestHeader = requestHeader;
}
public void setResponseBody(String responseBody) {
this.responseBody = responseBody;
}
@ -193,12 +220,15 @@ public class ApiInfo {
Objects.equals(groupId, apiInfo.groupId) &&
Objects.equals(parameter, apiInfo.parameter) &&
Objects.equals(option, apiInfo.option) &&
Objects.equals(requestBody, apiInfo.requestBody) &&
Objects.equals(requestHeader, apiInfo.requestHeader) &&
Objects.equals(responseBody, apiInfo.responseBody) &&
Objects.equals(responseHeader, apiInfo.responseHeader);
Objects.equals(responseHeader, apiInfo.responseHeader) &&
Objects.equals(description, apiInfo.description);
}
@Override
public int hashCode() {
return Objects.hash(id, method, path, script, name, groupId, parameter, option, responseBody, responseHeader);
return Objects.hash(id, method, path, script, name, groupId, parameter, option, requestBody, requestHeader, responseBody, responseHeader, description);
}
}

View File

@ -19,6 +19,8 @@ public class DefaultApiServiceProvider extends BeanPropertyRowMapper<ApiInfo> im
private final String SCRIPT_COLUMNS = "api_script,\n" +
"api_parameter,\n" +
"api_request_header,\n" +
"api_request_body,\n" +
"api_response_body,\n" +
"api_response_header,\n" +
"api_option\n";
@ -82,14 +84,14 @@ public class DefaultApiServiceProvider extends BeanPropertyRowMapper<ApiInfo> im
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_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;
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_request_header,api_request_body,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.getRequestHeader(), info.getRequestBody(),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_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;
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_request_header = ?,api_request_body = ?,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.getRequestHeader(), info.getRequestBody(), info.getResponseBody(), info.getResponseHeader(), System.currentTimeMillis(), info.getId()) > 0;
}
@Override