Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
8dc2431e
Unverified
Commit
8dc2431e
authored
Nov 09, 2023
by
ZackYoung
Committed by
GitHub
Nov 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix_h2_init (#2511)
parent
4cad347b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
92 additions
and
45 deletions
+92
-45
WebExceptionHandler.java
...dmin/src/main/java/org/dinky/aop/WebExceptionHandler.java
+2
-4
AppConfig.java
dinky-admin/src/main/java/org/dinky/configure/AppConfig.java
+0
-31
DatabasePopulatorUtils.java
...ramework/jdbc/datasource/init/DatabasePopulatorUtils.java
+80
-0
application-h2.yml
dinky-admin/src/main/resources/application-h2.yml
+3
-3
db-h2-ddl.sql
dinky-admin/src/main/resources/db/db-h2-ddl.sql
+0
-0
UDFManageMapper.xml
dinky-admin/src/main/resources/mapper/UDFManageMapper.xml
+2
-2
DirConstant.java
...on/src/main/java/org/dinky/data/constant/DirConstant.java
+2
-2
VariableManager.java
...tor/src/main/java/org/dinky/executor/VariableManager.java
+1
-1
pom.xml
pom.xml
+2
-2
No files found.
dinky-admin/src/main/java/org/dinky/aop/WebExceptionHandler.java
View file @
8dc2431e
...
@@ -39,10 +39,9 @@ import org.springframework.validation.BindingResult;
...
@@ -39,10 +39,9 @@ import org.springframework.validation.BindingResult;
import
org.springframework.validation.FieldError
;
import
org.springframework.validation.FieldError
;
import
org.springframework.validation.ObjectError
;
import
org.springframework.validation.ObjectError
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
...
@@ -55,8 +54,7 @@ import cn.hutool.core.util.StrUtil;
...
@@ -55,8 +54,7 @@ import cn.hutool.core.util.StrUtil;
*
*
* @since 2022/2/2 22:22
* @since 2022/2/2 22:22
*/
*/
@ControllerAdvice
@RestControllerAdvice
@ResponseBody
public
class
WebExceptionHandler
{
public
class
WebExceptionHandler
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
WebExceptionHandler
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
WebExceptionHandler
.
class
);
...
...
dinky-admin/src/main/java/org/dinky/configure/AppConfig.java
View file @
8dc2431e
...
@@ -72,37 +72,6 @@ public class AppConfig implements WebMvcConfigurer {
...
@@ -72,37 +72,6 @@ public class AppConfig implements WebMvcConfigurer {
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
localeChangeInterceptor
());
registry
.
addInterceptor
(
localeChangeInterceptor
());
// 注册Sa-Token的路由拦截器
// 注册Sa-Token的路由拦截器
// registry.addInterceptor(new SaInterceptor(handle -> {
// // 根据路由划分模块,不同模块不同鉴权
// SaRouter.match("/api/alertGroup/**", r ->
// StpUtil.checkPermission("alertGroup"));
// SaRouter.match("/api/alertHistory/**", r ->
// StpUtil.checkPermission("alertHistory"));
// SaRouter.match("/api/alertInstance/**", r ->
// StpUtil.checkPermission("alertInstance"));
// SaRouter.match("/api/catalogue/**", r ->
// StpUtil.checkPermission("catalogue"));
// SaRouter.match("/api/clusterConfiguration/**", r ->
// StpUtil.checkPermission("clusterConfiguration"));
// SaRouter.match("/api/cluster/**", r ->
// StpUtil.checkPermission("clusterInstance"));
// SaRouter.match("/api/database/**", r ->
// StpUtil.checkPermission("database"));
// SaRouter.match("/api/document/**", r ->
// StpUtil.checkPermission("document"));
// SaRouter.match("/api/fragment/**", r ->
// StpUtil.checkPermission("fragment"));
// SaRouter.match("/api/git/**", r -> StpUtil.checkPermission("git"));
// SaRouter.match("/api/history/**", r ->
// StpUtil.checkPermission("history"));
//
// }))
// .addPathPatterns("/api/**")
// .excludePathPatterns("/api/login")
// .excludePathPatterns("/druid/**")
// .excludePathPatterns("/openapi/**");
registry
.
addInterceptor
(
new
SaInterceptor
(
handler
->
StpUtil
.
checkLogin
()))
registry
.
addInterceptor
(
new
SaInterceptor
(
handler
->
StpUtil
.
checkLogin
()))
.
addPathPatterns
(
"/api/**"
)
.
addPathPatterns
(
"/api/**"
)
.
excludePathPatterns
(
.
excludePathPatterns
(
...
...
dinky-admin/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java
0 → 100644
View file @
8dc2431e
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
springframework
.
jdbc
.
datasource
.
init
;
import
java.sql.Connection
;
import
javax.sql.DataSource
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.jdbc.datasource.DataSourceUtils
;
import
org.springframework.util.Assert
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.db.Db
;
/**
* Utility methods for executing a {@link DatabasePopulator}.
*
* @author Juergen Hoeller
* @author Oliver Gierke
* @author Sam Brannen
* @since 3.1
*/
public
abstract
class
DatabasePopulatorUtils
{
private
static
boolean
isInit
=
true
;
/**
* Execute the given {@link DatabasePopulator} against the given {@link DataSource}.
* <p>As of Spring Framework 5.3.11, the {@link Connection} for the supplied
* {@code DataSource} will be {@linkplain Connection#commit() committed} if
* it is not configured for {@link Connection#getAutoCommit() auto-commit} and
* is not {@linkplain DataSourceUtils#isConnectionTransactional transactional}.
*
* @param populator the {@code DatabasePopulator} to execute
* @param dataSource the {@code DataSource} to execute against
* @throws DataAccessException if an error occurs, specifically a {@link ScriptException}
* @see DataSourceUtils#isConnectionTransactional(Connection, DataSource)
*/
public
static
void
execute
(
DatabasePopulator
populator
,
DataSource
dataSource
)
throws
DataAccessException
{
Assert
.
notNull
(
populator
,
"DatabasePopulator must not be null"
);
Assert
.
notNull
(
dataSource
,
"DataSource must not be null"
);
try
{
// Override this method and do not run it if the table exists(重写此方法,如果有表存在,则不运行)
if
(
isInit
&&
CollUtil
.
isNotEmpty
(
Db
.
use
(
dataSource
).
query
(
"show tables"
)))
{
return
;
}
isInit
=
false
;
Connection
connection
=
DataSourceUtils
.
getConnection
(
dataSource
);
try
{
populator
.
populate
(
connection
);
if
(!
connection
.
getAutoCommit
()
&&
!
DataSourceUtils
.
isConnectionTransactional
(
connection
,
dataSource
))
{
connection
.
commit
();
}
}
finally
{
DataSourceUtils
.
releaseConnection
(
connection
,
dataSource
);
}
}
catch
(
ScriptException
ex
)
{
throw
ex
;
}
catch
(
Throwable
ex
)
{
throw
new
UncategorizedScriptException
(
"Failed to execute database script"
,
ex
);
}
}
}
dinky-admin/src/main/resources/application-h2.yml
View file @
8dc2431e
...
@@ -31,5 +31,5 @@ spring:
...
@@ -31,5 +31,5 @@ spring:
sql
:
sql
:
init
:
init
:
schema-locations
:
classpath:db/db-h2-ddl.sql
schema-locations
:
classpath:db/db-h2-ddl.sql
mode
:
always
data-locations
:
classpath:db/db-h2-dml.sql
data-locations
:
classpath:db/db-h2-dml.sql
mode
:
always
\ No newline at end of file
\ No newline at end of file
dinky-admin/src/main/resources/db/db-h2-ddl.sql
View file @
8dc2431e
This diff is collapsed.
Click to expand it.
dinky-admin/src/main/resources/mapper/UDFManageMapper.xml
View file @
8dc2431e
...
@@ -21,10 +21,10 @@
...
@@ -21,10 +21,10 @@
<mapper
namespace=
"org.dinky.mapper.UDFManageMapper"
>
<mapper
namespace=
"org.dinky.mapper.UDFManageMapper"
>
<select
id=
"selectAll"
resultType=
"org.dinky.data.vo.UDFManageVO"
>
<select
id=
"selectAll"
resultType=
"org.dinky.data.vo.UDFManageVO"
>
select u.*,
"develop"
source,t.dialect,null file_name from
select u.*,
'develop'
source,t.dialect,null file_name from
dinky_udf_manage u LEFT JOIN dinky_task t on t.id=u.task_id WHERE resources_id is null
dinky_udf_manage u LEFT JOIN dinky_task t on t.id=u.task_id WHERE resources_id is null
union ALL
union ALL
select u.*,
"resources"
source,null dialect,t.full_name from
select u.*,
'resources'
source,null dialect,t.full_name from
dinky_udf_manage u LEFT JOIN dinky_resources t on t.id=u.resources_id WHERE u.task_id is null
dinky_udf_manage u LEFT JOIN dinky_resources t on t.id=u.resources_id WHERE u.task_id is null
</select>
</select>
</mapper>
</mapper>
dinky-common/src/main/java/org/dinky/data/constant/DirConstant.java
View file @
8dc2431e
...
@@ -21,7 +21,7 @@ package org.dinky.data.constant;
...
@@ -21,7 +21,7 @@ package org.dinky.data.constant;
import
java.io.File
;
import
java.io.File
;
import
cn.hutool.
core.io.File
Util
;
import
cn.hutool.
system.System
Util
;
/**
/**
* DirConstant
* DirConstant
...
@@ -31,7 +31,7 @@ import cn.hutool.core.io.FileUtil;
...
@@ -31,7 +31,7 @@ import cn.hutool.core.io.FileUtil;
public
class
DirConstant
{
public
class
DirConstant
{
public
static
final
String
FILE_SEPARATOR
=
File
.
separator
;
public
static
final
String
FILE_SEPARATOR
=
File
.
separator
;
public
static
final
String
ROOT_PATH
=
FileUtil
.
getUserHomeDir
().
getAbsolutePath
(
);
public
static
final
String
ROOT_PATH
=
System
.
getProperty
(
SystemUtil
.
USER_DIR
);
public
static
final
String
LOG_DIR_PATH
=
ROOT_PATH
+
FILE_SEPARATOR
+
"logs"
;
public
static
final
String
LOG_DIR_PATH
=
ROOT_PATH
+
FILE_SEPARATOR
+
"logs"
;
public
static
final
String
ROOT_LOG_PATH
=
LOG_DIR_PATH
+
FILE_SEPARATOR
+
"dinky.log"
;
public
static
final
String
ROOT_LOG_PATH
=
LOG_DIR_PATH
+
FILE_SEPARATOR
+
"dinky.log"
;
}
}
dinky-executor/src/main/java/org/dinky/executor/VariableManager.java
View file @
8dc2431e
...
@@ -146,7 +146,7 @@ public final class VariableManager {
...
@@ -146,7 +146,7 @@ public final class VariableManager {
return
variables
.
get
(
variableName
);
return
variables
.
get
(
variableName
);
}
}
// use jexl to parse variable value
// use jexl to parse variable value
return
ENGINE
.
eval
(
variableName
,
ENGINE_CONTEXT
);
return
ENGINE
.
eval
(
variableName
,
ENGINE_CONTEXT
,
null
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
CatalogException
(
format
(
"The variable of sql %s does not exist."
,
variableName
));
throw
new
CatalogException
(
format
(
"The variable of sql %s does not exist."
,
variableName
));
}
}
...
...
pom.xml
View file @
8dc2431e
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
<hamcrest.version>
1.3
</hamcrest.version>
<hamcrest.version>
1.3
</hamcrest.version>
<hibernate-validator.version>
6.2.0.Final
</hibernate-validator.version>
<hibernate-validator.version>
6.2.0.Final
</hibernate-validator.version>
<httpclient.version>
4.5.13
</httpclient.version>
<httpclient.version>
4.5.13
</httpclient.version>
<hutool.version>
5.8.
11
</hutool.version>
<hutool.version>
5.8.
22
</hutool.version>
<jackson.version>
2.14.1
</jackson.version>
<jackson.version>
2.14.1
</jackson.version>
<jakarta.ws.rs-api.version>
2.1.6
</jakarta.ws.rs-api.version>
<jakarta.ws.rs-api.version>
2.1.6
</jakarta.ws.rs-api.version>
<jasypt.version>
1.9.3
</jasypt.version>
<jasypt.version>
1.9.3
</jasypt.version>
...
@@ -108,7 +108,7 @@
...
@@ -108,7 +108,7 @@
<protobuf-java.version>
2.5.0
</protobuf-java.version>
<protobuf-java.version>
2.5.0
</protobuf-java.version>
<reflections.version>
0.10.2
</reflections.version>
<reflections.version>
0.10.2
</reflections.version>
<revision>
1.0.0-SNAPSHOT
</revision>
<revision>
1.0.0-SNAPSHOT
</revision>
<sa-token.version>
1.3
6
.0
</sa-token.version>
<sa-token.version>
1.3
7
.0
</sa-token.version>
<scala.binary.version>
2.12
</scala.binary.version>
<scala.binary.version>
2.12
</scala.binary.version>
<scala.version>
2.12.10
</scala.version>
<scala.version>
2.12.10
</scala.version>
<!-- `provided` for product environment ,`compile` for dev environment -->
<!-- `provided` for product environment ,`compile` for dev environment -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment