From 5eef918d2779271af896ae6f746664d70d21056a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=90=A6=E6=B6=9B?= Date: Thu, 16 Mar 2023 15:49:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90fix=20sonar=E3=80=91GatewayRouters?= =?UTF-8?q?Configuration=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/GatewayRoutersConfiguration.java | 55 ++++++++++--------- .../src/main/resources/bootstrap.yml | 3 + 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/jero-boot/jero-cloud-module/jero-cloud-gateway/src/main/java/com/jero/config/GatewayRoutersConfiguration.java b/jero-boot/jero-cloud-module/jero-cloud-gateway/src/main/java/com/jero/config/GatewayRoutersConfiguration.java index 3c2868b9..9c57f391 100644 --- a/jero-boot/jero-cloud-module/jero-cloud-gateway/src/main/java/com/jero/config/GatewayRoutersConfiguration.java +++ b/jero-boot/jero-cloud-module/jero-cloud-gateway/src/main/java/com/jero/config/GatewayRoutersConfiguration.java @@ -36,45 +36,55 @@ public class GatewayRoutersConfiguration { public static String ROUTE_GROUP; - public static String USERNAME; - - public static String PASSWORD; - /** * 路由配置文件数据获取方式yml,nacos,database */ public static String DATA_TYPE; @Value("${spring.cloud.nacos.discovery.server-addr}") - public static void setServerAddr(String serverAddr) { - SERVER_ADDR = serverAddr; + public void setServerAddr(String serverAddr) { + synchronized (GatewayRoutersConfiguration.class){ + if(SERVER_ADDR == null){ + SERVER_ADDR = serverAddr; + } + } } @Value("${spring.cloud.nacos.discovery.namespace}") - public static void setNamespace(String namespace) { - NAMESPACE = namespace; + public void setNamespace(String namespace) { + synchronized (GatewayRoutersConfiguration.class){ + if(NAMESPACE == null){ + NAMESPACE = namespace; + } + } } @Value("${jero.route.config.data-id:#{null}}") - public static void setRouteDataId(String dataId) { - DATA_ID = dataId + ".json"; + public void setRouteDataId(String dataId) { + synchronized (GatewayRoutersConfiguration.class){ + if(DATA_ID == null){ + DATA_ID = dataId + ".json"; + } + } } @Value("${jero.route.config.group:DEFAULT_GROUP:#{null}}") - public static void setRouteGroup(String routeGroup) { - ROUTE_GROUP = routeGroup; + public void setRouteGroup(String routeGroup) { + synchronized (GatewayRoutersConfiguration.class){ + if(ROUTE_GROUP == null){ + ROUTE_GROUP = routeGroup; + } + } } @Value("${jero.route.config.data-type}") - public static void setDataType(String dataType) { DATA_TYPE = dataType; } + public void setDataType(String dataType) { + synchronized (GatewayRoutersConfiguration.class){ + if(DATA_TYPE == null){ + DATA_TYPE = dataType; + } + } - @Value("${spring.cloud.nacos.config.username}") - public static void setUsername(String username) { - USERNAME = username; - } - @Value("${spring.cloud.nacos.config.password}") - public static void setPassword(String password) { - PASSWORD = password; } @@ -89,11 +99,6 @@ public class GatewayRoutersConfiguration { } - /** - * 映射接口文档默认地址(通过9999端口直接访问) - * @param indexHtml - * @return - */ @Bean public RouterFunction indexRouter(@Value("classpath:/META-INF/resources/doc.html") final org.springframework.core.io.Resource indexHtml) { return route(GET("/"), request -> ok().contentType(MediaType.TEXT_HTML).syncBody(indexHtml)); diff --git a/jero-boot/jero-cloud-module/jero-cloud-gateway/src/main/resources/bootstrap.yml b/jero-boot/jero-cloud-module/jero-cloud-gateway/src/main/resources/bootstrap.yml index 1255c25a..336a8cf2 100644 --- a/jero-boot/jero-cloud-module/jero-cloud-gateway/src/main/resources/bootstrap.yml +++ b/jero-boot/jero-cloud-module/jero-cloud-gateway/src/main/resources/bootstrap.yml @@ -42,3 +42,6 @@ jero: fileSuffixLimits: 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin # 跨站白名单 whiteUrls: + route: + config: + data-type: yml From 6b641cc1b927bfcd4b0dd88bc4f1c9c48ddbae98 Mon Sep 17 00:00:00 2001 From: caozhen <18736171426@139.com> Date: Thu, 16 Mar 2023 16:00:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B2=A1=E5=AF=BC=E5=85=A5=E8=A1=A8?= =?UTF-8?q?=E5=A4=87=E6=B3=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../database/DbReadTableUtil.java | 50 ++++++++++++++++++- .../impl/OnlCgformHeadServiceImpl.java | 10 +++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater-core/src/main/java/com/jero/codegenerate/database/DbReadTableUtil.java b/jero-boot/jero-boot-base/jero-boot-base-generater-core/src/main/java/com/jero/codegenerate/database/DbReadTableUtil.java index 4f079a4a..c144097e 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-generater-core/src/main/java/com/jero/codegenerate/database/DbReadTableUtil.java +++ b/jero-boot/jero-boot-base/jero-boot-base-generater-core/src/main/java/com/jero/codegenerate/database/DbReadTableUtil.java @@ -19,8 +19,10 @@ import org.apache.commons.lang.StringUtils; import com.jero.codegenerate.database.util.CodeStringUtils; import com.jero.codegenerate.generate.pojo.ColumnVo; import com.jero.codegenerate.generate.util.TableConvert; +import org.springframework.stereotype.Component; @Slf4j +@Component public class DbReadTableUtil { private static Connection connection; @@ -32,7 +34,6 @@ public class DbReadTableUtil { private static final String CONNECT_DATABASE_NAME = " connect databaseName : "; private static final String COLUMN_GET_FIELD_NAME = "columnt.getFieldName() -------------"; - public static void main(String[] args) throws SQLException { try { List list = listColumns("demo"); @@ -526,4 +527,51 @@ public class DbReadTableUtil { return value; } + + //获取当前使用数据库名 + public String database() throws Exception { + Class.forName(com.jero.codegenerate.properties.CodeConfigProperties.driverName); + connection = DriverManager.getConnection(com.jero.codegenerate.properties.CodeConfigProperties.databaseUrl, com.jero.codegenerate.properties.CodeConfigProperties.username, com.jero.codegenerate.properties.CodeConfigProperties.password); + statement = connection.createStatement(1005, 1007); + String sqlStr = "select database()"; + ResultSet resultSet = statement.executeQuery(sqlStr); + while(resultSet.next()) { + String name = resultSet.getString(1); + this.release(connection,statement); + return name; + } + this.release(connection,statement); + return ""; + } + + //通过表名获取表备注 + public String remarks(String a) throws Exception { + String database = this.database(); + + Class.forName(com.jero.codegenerate.properties.CodeConfigProperties.driverName); + connection = DriverManager.getConnection(com.jero.codegenerate.properties.CodeConfigProperties.databaseUrl, com.jero.codegenerate.properties.CodeConfigProperties.username, com.jero.codegenerate.properties.CodeConfigProperties.password); + statement = connection.createStatement(1005, 1007); + + String sqlStr = "SELECT table_comment FROM information_schema.TABLES WHERE table_schema = " + "'"+database+"'" + " AND table_name = " + "'"+a+"'"; + ResultSet resultSet = statement.executeQuery(sqlStr); + while(resultSet.next()) { + String name = resultSet.getString(1); + this.release(connection,statement); + return name; + } + this.release(connection,statement); + return ""; + } + + //释放连接资源 + public void release(Connection connection, Statement statement) throws Exception { + if (statement != null) { + statement.close(); + statement = null; + } + if (connection != null) { + connection.close(); + connection = null; + } + } } diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/cgform/service/impl/OnlCgformHeadServiceImpl.java b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/cgform/service/impl/OnlCgformHeadServiceImpl.java index 652b2294..f83e3974 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/cgform/service/impl/OnlCgformHeadServiceImpl.java +++ b/jero-boot/jero-boot-base/jero-boot-base-generater/src/main/java/com/jero/generater/modules/online/cgform/service/impl/OnlCgformHeadServiceImpl.java @@ -89,6 +89,8 @@ public class OnlCgformHeadServiceImpl extends ServiceImpl Date: Thu, 16 Mar 2023 16:16:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90fix=20bug=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E3=80=91=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E5=99=A8=EF=BC=8C?= =?UTF-8?q?put=E3=80=81delete=E6=94=B9=E4=B8=BApost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jero-web/src/components/onlineForm/onlineForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jero-web/src/components/onlineForm/onlineForm.js b/jero-web/src/components/onlineForm/onlineForm.js index f2b77bbe..4535a342 100644 --- a/jero-web/src/components/onlineForm/onlineForm.js +++ b/jero-web/src/components/onlineForm/onlineForm.js @@ -8099,7 +8099,7 @@ return Object(r["a"])({ url: e, method: "post", - params: t + data: t }) }