From 128e163688215ab7b3b939d2003b7a7fbb14bf3e Mon Sep 17 00:00:00 2001 From: Peanut Date: Sat, 23 May 2026 18:40:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20OpenAPI=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=90=8D=E5=A4=A7=E5=B0=8F=E5=86=99=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=BB=BA=E8=A1=A8?= =?UTF-8?q?=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-single/create_api_tables.sql | 34 +++++++++++++++++++ .../service/impl/ApiEndpointServiceImpl.java | 5 +-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 backend-single/create_api_tables.sql diff --git a/backend-single/create_api_tables.sql b/backend-single/create_api_tables.sql new file mode 100644 index 0000000..ec61a94 --- /dev/null +++ b/backend-single/create_api_tables.sql @@ -0,0 +1,34 @@ +CREATE TABLE IF NOT EXISTS emotion_museum.api_endpoint ( + id VARCHAR(64) PRIMARY KEY, + path VARCHAR(500) NOT NULL, + method VARCHAR(10) NOT NULL, + operation_id VARCHAR(200), + summary VARCHAR(500), + description TEXT, + tags VARCHAR(500), + deprecated TINYINT(1) DEFAULT 0, + request_schema JSON, + response_schema JSON, + create_by VARCHAR(64), + create_time DATETIME DEFAULT CURRENT_TIMESTAMP, + update_by VARCHAR(64), + update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + is_deleted TINYINT(1) DEFAULT 0, + remarks VARCHAR(500), + UNIQUE INDEX idx_operation_id (operation_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS emotion_museum.api_param ( + id VARCHAR(64) PRIMARY KEY, + endpoint_id VARCHAR(64) NOT NULL, + param_type VARCHAR(20) NOT NULL, + name VARCHAR(100) NOT NULL, + required TINYINT(1) DEFAULT 0, + param_type_def VARCHAR(50), + description VARCHAR(500), + default_value VARCHAR(200), + enum_values JSON, + example VARCHAR(500), + INDEX idx_endpoint (endpoint_id), + FOREIGN KEY (endpoint_id) REFERENCES emotion_museum.api_endpoint(id) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/backend-single/src/main/java/com/emotion/service/impl/ApiEndpointServiceImpl.java b/backend-single/src/main/java/com/emotion/service/impl/ApiEndpointServiceImpl.java index 5a3266a..22584ab 100644 --- a/backend-single/src/main/java/com/emotion/service/impl/ApiEndpointServiceImpl.java +++ b/backend-single/src/main/java/com/emotion/service/impl/ApiEndpointServiceImpl.java @@ -137,11 +137,12 @@ public class ApiEndpointServiceImpl implements ApiEndpointService { JsonNode methods = pathEntry.getValue(); for (Iterator it = methods.fieldNames(); it.hasNext(); ) { - String method = it.next().toUpperCase(); + String methodKey = it.next(); + String method = methodKey.toUpperCase(); // Skip non-HTTP-method keys (e.g., summary, description at path level) if (!isHttpMethod(method)) continue; - JsonNode endpointNode = methods.get(method); + JsonNode endpointNode = methods.get(methodKey); String operationId = endpointNode.path("operationId").asText(); if (operationId.isEmpty()) continue;