Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
test
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
邬友楠
test
Commits
265886b4
Commit
265886b4
authored
Dec 23, 2019
by
雍欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
多数据库支持
parent
1efc746e
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
315 additions
and
196 deletions
+315
-196
Dialect.java
...u-data/src/main/java/com/huigou/data/dialect/Dialect.java
+1
-1
SQLQueryImpl.java
...src/main/java/com/huigou/data/jdbc/impl/SQLQueryImpl.java
+1
-1
QueryXmlLoadInterface.java
...ain/java/com/huigou/data/query/QueryXmlLoadInterface.java
+1
-1
QueryXmlModel.java
...ta/src/main/java/com/huigou/data/query/QueryXmlModel.java
+38
-10
SQLExecutor.java
...data/src/main/java/com/huigou/data/query/SQLExecutor.java
+73
-49
SQLExecutorDaoImpl.java
...m/huigou/data/query/executor/impl/SQLExecutorDaoImpl.java
+3
-0
pom.xml
huigou-uasp/pom.xml
+2
-2
QueryXmlManager.java
...ava/com/huigou/uasp/bmp/common/query/QueryXmlManager.java
+62
-19
pom.xml
huigou-xt/pom.xml
+8
-2
application.properties
huigou-xt/src/main/resources/application.properties
+8
-15
spring-dataSource.xml
...xt/src/main/resources/config/spring/spring-dataSource.xml
+36
-29
spring-log-dataSource.xml
...rc/main/resources/config/spring/spring-log-dataSource.xml
+21
-9
spring-system.xml
huigou-xt/src/main/resources/config/spring/spring-system.xml
+61
-58
No files found.
huigou-data/src/main/java/com/huigou/data/dialect/Dialect.java
View file @
265886b4
...
@@ -280,7 +280,7 @@ public enum Dialect {
...
@@ -280,7 +280,7 @@ public enum Dialect {
* @return String
* @return String
*/
*/
public
static
String
getTotalSql
(
String
sql
)
{
public
static
String
getTotalSql
(
String
sql
)
{
return
"select count(0) from ("
+
sql
+
")"
;
return
"select count(0) from ("
+
sql
+
")
__t__
"
;
}
}
/**
/**
...
...
huigou-data/src/main/java/com/huigou/data/jdbc/impl/SQLQueryImpl.java
View file @
265886b4
...
@@ -163,7 +163,7 @@ public class SQLQueryImpl implements SQLQuery {
...
@@ -163,7 +163,7 @@ public class SQLQueryImpl implements SQLQuery {
if
(!
StringUtil
.
isBlank
(
queryModel
.
getManageType
()))
{
if
(!
StringUtil
.
isBlank
(
queryModel
.
getManageType
()))
{
sb
.
append
(
sql
);
sb
.
append
(
sql
);
}
else
{
}
else
{
sb
.
append
(
"select * from ("
).
append
(
sql
).
append
(
")"
);
sb
.
append
(
"select * from ("
).
append
(
sql
).
append
(
")
__t__
"
);
sb
.
append
(
" where 1=1 "
);
sb
.
append
(
" where 1=1 "
);
}
}
sb
.
append
(
queryModel
.
parseSortFields
());
sb
.
append
(
queryModel
.
parseSortFields
());
...
...
huigou-data/src/main/java/com/huigou/data/query/QueryXmlLoadInterface.java
View file @
265886b4
...
@@ -3,5 +3,5 @@ package com.huigou.data.query;
...
@@ -3,5 +3,5 @@ package com.huigou.data.query;
import
com.huigou.exception.ResourceLoadException
;
import
com.huigou.exception.ResourceLoadException
;
public
interface
QueryXmlLoadInterface
{
public
interface
QueryXmlLoadInterface
{
public
QueryXmlModel
loadConfigFile
(
String
path
)
throws
ResourceLoadException
;
QueryXmlModel
loadConfigFile
(
String
path
)
throws
ResourceLoadException
;
}
}
huigou-data/src/main/java/com/huigou/data/query/QueryXmlModel.java
View file @
265886b4
package
com
.
huigou
.
data
.
query
;
package
com
.
huigou
.
data
.
query
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.huigou.uasp.bmp.query.QueryDocument.Query
;
import
com.huigou.uasp.bmp.query.QueryDocument.Query
;
import
com.huigou.uasp.bmp.query.QueryMappingsDocument.QueryMappings
;
import
com.huigou.uasp.bmp.query.QueryMappingsDocument.QueryMappings
;
import
com.huigou.util.ConfigFileVersion
;
import
com.huigou.util.ConfigFileVersion
;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* 查询模型管理类
* 查询模型管理类
*/
*/
...
@@ -23,7 +26,11 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
...
@@ -23,7 +26,11 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
/**
/**
* 实体对象
* 实体对象
*/
*/
private
Map
<
String
,
Query
>
querys
;
private
final
Map
<
String
,
Query
>
querys
;
/**
* @since 1.1.3
*/
private
final
Map
<
String
,
Query
>
dialectQuerys
;
/**
/**
* 版本
* 版本
...
@@ -32,10 +39,18 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
...
@@ -32,10 +39,18 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
private
String
configFilePath
;
private
String
configFilePath
;
public
QueryXmlModel
(
QueryMappings
queryMappings
)
{
public
QueryXmlModel
(
QueryMappings
queryMappings
,
QueryMappings
dialectQueryMappings
)
{
querys
=
new
HashMap
<
String
,
Query
>(
queryMappings
.
getQueryArray
().
length
);
if
(
queryMappings
!=
null
)
{
for
(
Query
query
:
queryMappings
.
getQueryArray
())
{
querys
=
Arrays
.
stream
(
queryMappings
.
getQueryArray
())
querys
.
put
(
query
.
getName
(),
query
);
.
collect
(
Collectors
.
toMap
(
Query:
:
getName
,
query
->
query
));
}
else
{
querys
=
Collections
.
emptyMap
();
}
if
(
dialectQueryMappings
!=
null
)
{
dialectQuerys
=
Arrays
.
stream
(
dialectQueryMappings
.
getQueryArray
())
.
collect
(
Collectors
.
toMap
(
Query:
:
getName
,
query
->
query
));
}
else
{
dialectQuerys
=
Collections
.
emptyMap
();
}
}
}
}
...
@@ -51,8 +66,20 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
...
@@ -51,8 +66,20 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
return
querys
;
return
querys
;
}
}
/**
* @since 1.1.3
*/
public
Map
<
String
,
Query
>
getDialectQuerys
()
{
return
dialectQuerys
;
}
public
Query
getQuery
(
String
name
)
{
public
Query
getQuery
(
String
name
)
{
return
querys
.
get
(
name
);
// 优先从方言中获取
Query
query
=
dialectQuerys
.
get
(
name
);
if
(
query
==
null
)
{
query
=
querys
.
get
(
name
);
}
return
query
;
}
}
public
void
setVersion
(
Long
version
)
{
public
void
setVersion
(
Long
version
)
{
...
@@ -64,6 +91,7 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
...
@@ -64,6 +91,7 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
return
version
;
return
version
;
}
}
@Override
public
String
getFilePath
()
{
public
String
getFilePath
()
{
return
configFilePath
;
return
configFilePath
;
}
}
...
...
huigou-data/src/main/java/com/huigou/data/query/SQLExecutor.java
View file @
265886b4
...
@@ -35,10 +35,10 @@ import com.huigou.util.Util;
...
@@ -35,10 +35,10 @@ import com.huigou.util.Util;
/**
/**
* SQL执行对象
* SQL执行对象
*
*
* @author xx
* @author xx
* @date 2017-1-26 上午09:39:34
* @version V1.0
* @version V1.0
* @date 2017-1-26 上午09:39:34
*/
*/
public
class
SQLExecutor
extends
SQLModel
{
public
class
SQLExecutor
extends
SQLModel
{
...
@@ -80,6 +80,13 @@ public class SQLExecutor extends SQLModel {
...
@@ -80,6 +80,13 @@ public class SQLExecutor extends SQLModel {
*/
*/
private
List
<
String
>
conditionIn
;
private
List
<
String
>
conditionIn
;
/**
* NOT IN 参数名称
*
* @since 1.1.3
*/
private
List
<
String
>
conditionNotIn
=
new
ArrayList
<>(
1
);
/**
/**
* LIKE 参数名称
* LIKE 参数名称
*/
*/
...
@@ -129,6 +136,12 @@ public class SQLExecutor extends SQLModel {
...
@@ -129,6 +136,12 @@ public class SQLExecutor extends SQLModel {
}
}
}
}
public
void
addConditionNotIn
(
String
name
)
{
if
(
name
!=
null
)
{
conditionNotIn
.
add
(
name
);
}
}
public
void
addConditionHalfLike
(
String
name
)
{
public
void
addConditionHalfLike
(
String
name
)
{
if
(
name
!=
null
)
{
if
(
name
!=
null
)
{
conditionHalfLike
.
add
(
name
);
conditionHalfLike
.
add
(
name
);
...
@@ -153,7 +166,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -153,7 +166,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 得到参数数组
* 得到参数数组
*
*
* @param map
* @param map
* @return
* @return
* @throws ApplicationException
* @throws ApplicationException
...
@@ -177,7 +190,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -177,7 +190,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 得到Map参数
* 得到Map参数
*
*
* @param map
* @param map
* @return
* @return
* @throws ApplicationException
* @throws ApplicationException
...
@@ -202,7 +215,8 @@ public class SQLExecutor extends SQLModel {
...
@@ -202,7 +215,8 @@ public class SQLExecutor extends SQLModel {
obj
=
ClassHelper
.
convert
(
obj
,
String
.
class
);
obj
=
ClassHelper
.
convert
(
obj
,
String
.
class
);
obj
=
obj
+
"%"
;
obj
=
obj
+
"%"
;
}
}
if
(
isIn
(
name
))
{
// 是in查询默认添加()
// 是in查询默认添加()
if
(
isIn
(
name
)
||
isNotIn
(
name
))
{
StringBuffer
inSql
=
new
StringBuffer
(
"("
);
StringBuffer
inSql
=
new
StringBuffer
(
"("
);
String
[]
vals
=
obj
.
toString
().
split
(
","
);
String
[]
vals
=
obj
.
toString
().
split
(
","
);
int
vi
=
vals
.
length
;
int
vi
=
vals
.
length
;
...
@@ -231,7 +245,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -231,7 +245,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 判断是否是LIKE查询
* 判断是否是LIKE查询
*
*
* @param name
* @param name
* @return
* @return
*/
*/
...
@@ -244,7 +258,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -244,7 +258,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 判断是否是HALF LIKE查询
* 判断是否是HALF LIKE查询
*
*
* @param name
* @param name
* @return
* @return
*/
*/
...
@@ -257,7 +271,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -257,7 +271,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 判断是否是in查询
* 判断是否是in查询
*
*
* @param name
* @param name
* @return
* @return
*/
*/
...
@@ -268,6 +282,13 @@ public class SQLExecutor extends SQLModel {
...
@@ -268,6 +282,13 @@ public class SQLExecutor extends SQLModel {
return
false
;
return
false
;
}
}
/**
* @since 1.1.3
*/
private
boolean
isNotIn
(
String
name
)
{
return
conditionNotIn
.
contains
(
name
);
}
/**
/**
* 构建查询sql
* 构建查询sql
*/
*/
...
@@ -284,7 +305,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -284,7 +305,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 判断 param中是否有值
* 判断 param中是否有值
*
*
* @param name
* @param name
* @return
* @return
*/
*/
...
@@ -298,7 +319,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -298,7 +319,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 处理条件表达式
* 处理条件表达式
*
*
* @param symbol
* @param symbol
* @param name
* @param name
*/
*/
...
@@ -313,11 +334,14 @@ public class SQLExecutor extends SQLModel {
...
@@ -313,11 +334,14 @@ public class SQLExecutor extends SQLModel {
if
(
symbol
.
equalsIgnoreCase
(
"IN"
))
{
if
(
symbol
.
equalsIgnoreCase
(
"IN"
))
{
this
.
addConditionIn
(
name
);
this
.
addConditionIn
(
name
);
}
}
if
(
"not in"
.
equalsIgnoreCase
(
symbol
))
{
this
.
addConditionNotIn
(
name
);
}
}
}
/**
/**
* 解析条件sql
* 解析条件sql
*
*
* @param condition
* @param condition
*/
*/
public
void
buildSqlCondition
(
ConditionModel
condition
)
{
public
void
buildSqlCondition
(
ConditionModel
condition
)
{
...
@@ -335,7 +359,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -335,7 +359,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 解析条件 高级自定义查询
* 解析条件 高级自定义查询
*
*
* @param dataFilterGroup
* @param dataFilterGroup
*/
*/
public
void
buildSqlDataFilterGroup
(
DataFilterGroup
dataFilterGroup
)
{
public
void
buildSqlDataFilterGroup
(
DataFilterGroup
dataFilterGroup
)
{
...
@@ -350,7 +374,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -350,7 +374,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 递归解析高级自定义查询分组
* 递归解析高级自定义查询分组
*
*
* @param group
* @param group
* @return
* @return
*/
*/
...
@@ -390,7 +414,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -390,7 +414,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 解析高级自定义查询条件
* 解析高级自定义查询条件
*
*
* @param rule
* @param rule
* @return
* @return
*/
*/
...
@@ -427,7 +451,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -427,7 +451,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 解析权限控制sql
* 解析权限控制sql
*
*
* @param group
* @param group
*/
*/
public
void
buildSqlPermissions
(
PermissionGroup
group
)
{
public
void
buildSqlPermissions
(
PermissionGroup
group
)
{
...
@@ -450,7 +474,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -450,7 +474,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 按数据管理权限编码重新构建权限组
* 按数据管理权限编码重新构建权限组
*
*
* @param group
* @param group
*/
*/
private
void
buildPermissionGroups
(
PermissionGroup
group
)
{
private
void
buildPermissionGroups
(
PermissionGroup
group
)
{
...
@@ -492,7 +516,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -492,7 +516,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 解析数据管理权限分组
* 解析数据管理权限分组
*
*
* @param group
* @param group
* @return
* @return
*/
*/
...
@@ -515,7 +539,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -515,7 +539,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 按权限组组合条件SQL
* 按权限组组合条件SQL
*
*
* @param group
* @param group
* @return
* @return
*/
*/
...
@@ -549,7 +573,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -549,7 +573,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 按具体权限栏目组合SQL
* 按具体权限栏目组合SQL
*
*
* @param models
* @param models
* @param resourceGroup
* @param resourceGroup
* @return
* @return
...
@@ -575,31 +599,31 @@ public class SQLExecutor extends SQLModel {
...
@@ -575,31 +599,31 @@ public class SQLExecutor extends SQLModel {
permission
.
setName
(
permissionKind
.
toString
());
permission
.
setName
(
permissionKind
.
toString
());
}
}
switch
(
permissionKind
)
{
switch
(
permissionKind
)
{
case
PERSON_ID:
case
PERSON_ID:
case
PSM_ID:
case
PSM_ID:
case
DEPT_ID:
case
DEPT_ID:
case
ORGAN_ID:
case
ORGAN_ID:
if
(
permission
.
isAppendCondition
())
{
if
(
permission
.
isAppendCondition
())
{
conditions
.
add
(
permission
.
formatCondition
());
conditions
.
add
(
permission
.
formatCondition
());
}
}
try
{
try
{
// 从当前登录用户中获取对应参数
// 从当前登录用户中获取对应参数
this
.
putParam
(
permission
.
getName
(),
ClassHelper
.
getProperty
(
this
.
getOperator
(),
permissionKind
.
getPropertyName
()));
this
.
putParam
(
permission
.
getName
(),
ClassHelper
.
getProperty
(
this
.
getOperator
(),
permissionKind
.
getPropertyName
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ResourceLoadException
(
String
.
format
(
"权限解析[%s]取值错误:%s"
,
permission
.
getName
(),
e
.
getMessage
()));
throw
new
ResourceLoadException
(
String
.
format
(
"权限解析[%s]取值错误:%s"
,
permission
.
getName
(),
e
.
getMessage
()));
}
}
break
;
break
;
case
FULL_ID:
case
FULL_ID:
conditions
.
add
(
this
.
parseFullIdManageType
(
permission
,
permissionLenght
));
conditions
.
add
(
this
.
parseFullIdManageType
(
permission
,
permissionLenght
));
break
;
break
;
case
DEFINE:
case
DEFINE:
conditions
.
add
(
this
.
parseDefineFunction
(
permission
));
conditions
.
add
(
this
.
parseDefineFunction
(
permission
));
break
;
break
;
case
DATA:
case
DATA:
conditions
.
add
(
this
.
parseDataManagement
(
permission
,
resourceGroup
));
conditions
.
add
(
this
.
parseDataManagement
(
permission
,
resourceGroup
));
break
;
break
;
default
:
default
:
throw
new
ResourceLoadException
(
String
.
format
(
"[%s]错误的数据权限类型"
,
permission
.
getName
()));
throw
new
ResourceLoadException
(
String
.
format
(
"[%s]错误的数据权限类型"
,
permission
.
getName
()));
}
}
this
.
formatSymbol
(
permission
.
getSymbol
(),
permission
.
getParamName
());
this
.
formatSymbol
(
permission
.
getSymbol
(),
permission
.
getParamName
());
this
.
putParamTypes
(
permission
.
getType
(),
permission
.
getParamName
());
this
.
putParamTypes
(
permission
.
getType
(),
permission
.
getParamName
());
...
@@ -609,7 +633,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -609,7 +633,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 解析通过业务管理权限组合fullId的查询SQL
* 解析通过业务管理权限组合fullId的查询SQL
*
*
* @param permission
* @param permission
* @param conditions
* @param conditions
* @param conditionLenght
* @param conditionLenght
...
@@ -655,7 +679,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -655,7 +679,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 解析自定义函数 组合SQL
* 解析自定义函数 组合SQL
*
*
* @param permission
* @param permission
* @param conditions
* @param conditions
* @param conditionLenght
* @param conditionLenght
...
@@ -722,7 +746,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -722,7 +746,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 执行表达式并进行类型转换
* 执行表达式并进行类型转换
*
*
* @param expr
* @param expr
* @return
* @return
*/
*/
...
@@ -754,7 +778,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -754,7 +778,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 数据管理权限解析
* 数据管理权限解析
*
*
* @param permission
* @param permission
* @param conditions
* @param conditions
* @param permissionLenght
* @param permissionLenght
...
@@ -809,7 +833,7 @@ public class SQLExecutor extends SQLModel {
...
@@ -809,7 +833,7 @@ public class SQLExecutor extends SQLModel {
/**
/**
* 使用OR组合条件
* 使用OR组合条件
*
*
* @param conditions
* @param conditions
* @return
* @return
*/
*/
...
...
huigou-data/src/main/java/com/huigou/data/query/executor/impl/SQLExecutorDaoImpl.java
View file @
265886b4
...
@@ -42,10 +42,12 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao {
...
@@ -42,10 +42,12 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao {
this
.
queryXmlManager
=
queryXmlManager
;
this
.
queryXmlManager
=
queryXmlManager
;
}
}
@Override
public
SQLBuilder
getSqlBuilder
()
{
public
SQLBuilder
getSqlBuilder
()
{
return
sqlBuilder
;
return
sqlBuilder
;
}
}
@Override
public
SQLQuery
getSqlQuery
()
{
public
SQLQuery
getSqlQuery
()
{
return
sqlQuery
;
return
sqlQuery
;
}
}
...
@@ -54,6 +56,7 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao {
...
@@ -54,6 +56,7 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao {
return
queryXmlManager
.
loadConfigFile
(
modelFilePath
);
return
queryXmlManager
.
loadConfigFile
(
modelFilePath
);
}
}
@Override
public
QueryDescriptor
getQuery
(
String
queryFilePath
,
String
queryName
)
{
public
QueryDescriptor
getQuery
(
String
queryFilePath
,
String
queryName
)
{
QueryXmlModel
model
=
getQueryXmlModel
(
queryFilePath
);
QueryXmlModel
model
=
getQueryXmlModel
(
queryFilePath
);
QueryDescriptor
queryDescriptor
=
new
QueryDescriptor
(
model
.
getQuery
(
queryName
));
QueryDescriptor
queryDescriptor
=
new
QueryDescriptor
(
model
.
getQuery
(
queryName
));
...
...
huigou-uasp/pom.xml
View file @
265886b4
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
<version>
1.1.3-SNAPSHOT
</version>
<version>
1.1.3-SNAPSHOT
</version>
</parent>
</parent>
<artifactId>
huigou-uasp
</artifactId>
<artifactId>
huigou-uasp
</artifactId>
<name>
统一架构平台
</name>
<name>
huigou-uasp
</name>
<description>
统一架构平台
</description>
<description>
huigou-uasp
</description>
<dependencies>
<dependencies>
<!-- 公用的组件包 -->
<!-- 公用的组件包 -->
<dependency>
<dependency>
...
...
huigou-uasp/src/main/java/com/huigou/uasp/bmp/common/query/QueryXmlManager.java
View file @
265886b4
package
com
.
huigou
.
uasp
.
bmp
.
common
.
query
;
package
com
.
huigou
.
uasp
.
bmp
.
common
.
query
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
org.springframework.core.io.ClassPathResource
;
import
com.huigou.data.query.QueryXmlLoadInterface
;
import
com.huigou.data.query.QueryXmlLoadInterface
;
import
com.huigou.data.query.QueryXmlModel
;
import
com.huigou.data.query.QueryXmlModel
;
import
com.huigou.exception.ResourceLoadException
;
import
com.huigou.exception.ResourceLoadException
;
import
com.huigou.uasp.bmp.query.QueryMappingsDocument
;
import
com.huigou.uasp.bmp.query.QueryMappingsDocument
;
import
com.huigou.util.ResourceLoadManager
;
import
com.huigou.util.ResourceLoadManager
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.util.Assert
;
import
java.io.InputStream
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
/**
/**
* 查询模型管理类
* 查询模型管理类
*
*
* @author xx
* @author xx
*/
*/
public
class
QueryXmlManager
extends
ResourceLoadManager
<
QueryXmlModel
>
implements
QueryXmlLoadInterface
{
public
class
QueryXmlManager
extends
ResourceLoadManager
<
QueryXmlModel
>
implements
QueryXmlLoadInterface
,
InitializingBean
{
/**
* SQL 方言。
*/
private
String
sqlDialect
;
public
void
setSqlDialect
(
String
sqlDialect
)
{
this
.
sqlDialect
=
sqlDialect
;
}
/**
/**
* 加载配置文件
* 加载配置文件
*/
*/
@Override
public
QueryXmlModel
loadConfigFile
(
String
path
)
throws
ResourceLoadException
{
public
QueryXmlModel
loadConfigFile
(
String
path
)
throws
ResourceLoadException
{
InputStream
inputStream
=
null
;
InputStream
inputStream
=
null
,
dialectXmlStream
=
null
;
try
{
try
{
// 默认SQL XML 文件
ClassPathResource
resource
=
getResource
(
path
);
ClassPathResource
resource
=
getResource
(
path
);
inputStream
=
resource
.
getInputStream
();
// 方言SQL XML文件
QueryMappingsDocument
doc
=
QueryMappingsDocument
.
Factory
.
parse
(
inputStream
);
ClassPathResource
dialectXml
=
getResource
(
getDialectXmlPath
(
path
));
QueryXmlModel
model
=
new
QueryXmlModel
(
doc
.
getQueryMappings
());
Assert
.
isTrue
(
resource
.
exists
()
||
dialectXml
.
exists
(),
"文件不存在"
);
model
.
setVersion
(
resource
.
lastModified
());
// 文件最后修改时间
QueryMappingsDocument
.
QueryMappings
queryMappings
=
null
;
if
(
resource
.
exists
())
{
inputStream
=
resource
.
getInputStream
();
queryMappings
=
QueryMappingsDocument
.
Factory
.
parse
(
inputStream
).
getQueryMappings
();
}
QueryMappingsDocument
.
QueryMappings
dialectQueryMappings
=
null
;
if
(
dialectXml
.
exists
())
{
dialectXmlStream
=
dialectXml
.
getInputStream
();
dialectQueryMappings
=
QueryMappingsDocument
.
Factory
.
parse
(
dialectXmlStream
)
.
getQueryMappings
();
}
QueryXmlModel
model
=
new
QueryXmlModel
(
queryMappings
,
dialectQueryMappings
);
// 文件最后修改时间
long
version
;
if
(
resource
.
exists
()
&&
dialectXml
.
exists
())
{
version
=
resource
.
lastModified
()
>
dialectXml
.
lastModified
()
?
resource
.
lastModified
()
:
dialectXml
.
lastModified
();
}
else
{
version
=
resource
.
exists
()
?
resource
.
lastModified
()
:
dialectXml
.
lastModified
();
}
model
.
setVersion
(
version
);
model
.
setConfigFilePath
(
path
);
model
.
setConfigFilePath
(
path
);
return
model
;
return
model
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ResourceLoadException
(
String
.
format
(
"读取配置文件[%s]失败:%s"
,
path
,
e
.
getMessage
()));
throw
new
ResourceLoadException
(
String
.
format
(
"读取配置文件[%s]失败:%s"
,
path
,
e
.
getMessage
()));
}
finally
{
}
finally
{
if
(
inputStream
!=
null
)
{
IOUtils
.
closeQuietly
(
inputStream
);
try
{
IOUtils
.
closeQuietly
(
dialectXmlStream
);
inputStream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
}
private
String
getDialectXmlPath
(
String
path
)
{
Path
filePath
=
Paths
.
get
(
path
);
Path
dialectXmlPath
=
filePath
.
getParent
().
resolve
(
sqlDialect
).
resolve
(
filePath
.
getFileName
());
return
dialectXmlPath
.
toString
();
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
Assert
.
hasText
(
sqlDialect
,
"sql方言不能为空"
);
}
}
}
\ No newline at end of file
huigou-xt/pom.xml
View file @
265886b4
...
@@ -420,8 +420,9 @@
...
@@ -420,8 +420,9 @@
</exclusions>
</exclusions>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.mchange
</groupId>
<groupId>
com.alibaba
</groupId>
<artifactId>
c3p0
</artifactId>
<artifactId>
druid
</artifactId>
<version>
1.1.16
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.codehaus.woodstox
</groupId>
<groupId>
org.codehaus.woodstox
</groupId>
...
@@ -443,6 +444,11 @@
...
@@ -443,6 +444,11 @@
<groupId>
javax.servlet
</groupId>
<groupId>
javax.servlet
</groupId>
<artifactId>
jstl
</artifactId>
<artifactId>
jstl
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.17
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<finalName>
huigou-xt
</finalName>
<finalName>
huigou-xt
</finalName>
...
...
huigou-xt/src/main/resources/application.properties
View file @
265886b4
#pub.db.url=jdbc:oracle:thin:@192.168.2.200:1521:orcl
pub.db.url
=
jdbc:mysql://127.0.0.1:3306/avic_sys?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false
#pub.db.user=c##gtoa_fx
pub.db.user
=
root
#pub.db.password=123456
pub.db.password
=
root
#log.db.url=jdbc:oracle:thin:@192.168.2.200:1521:orcl
log.db.url
=
jdbc:mysql://127.0.0.1:3306/avic_sys?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false
#log.db.user=c##gtoa_fx
log.db.user
=
root
#log.db.password=123456
log.db.password
=
root
pub.db.url
=
jdbc:oracle:thin:@192.168.2.200:1521:orcl
pub.db.user
=
iesms
pub.db.password
=
iesms123
log.db.url
=
jdbc:oracle:thin:@192.168.2.200:1521:orcl
log.db.user
=
iesms
log.db.password
=
iesms123
shiro.host
=
127.0.0.1
shiro.host
=
127.0.0.1
shiro.port
=
6379
shiro.port
=
6379
shiro.expire
=
18000
shiro.expire
=
18000
system.dataSource
=
dataSource
system.dataSource
=
dataSource
system.hibernate.dialect
=
org.hibernate.dialect.Oracle10gDialect
system.hibernate.dialect
=
org.hibernate.dialect.MySQL57InnoDBDialect
sqlDialect
=
mysql
#shiroFilter loginUrl
#shiroFilter loginUrl
shiro.loginUrl
=
/Login.jsp
shiro.loginUrl
=
/Login.jsp
...
...
huigou-xt/src/main/resources/config/spring/spring-dataSource.xml
View file @
265886b4
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xsi:schemaLocation=
"
xsi:schemaLocation=
"
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context
...
@@ -14,29 +14,36 @@
...
@@ -14,29 +14,36 @@
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"
>
http://www.springframework.org/schema/tx/spring-tx.xsd"
>
<bean
id=
"dataSource"
class=
"com.mchange.v2.c3p0.ComboPooledDataSource"
<bean
id=
"dataSource"
class=
"com.alibaba.druid.pool.DruidDataSource"
init-method=
"init"
destroy-method=
"close"
>
destroy-method=
"close"
>
<property
name=
"url"
value=
"${pub.db.url}"
/>
<property
name=
"driverClass"
value=
"oracle.jdbc.driver.OracleDriver"
/>
<property
name=
"username"
value=
"${pub.db.user}"
/>
<property
name=
"jdbcUrl"
value=
"${pub.db.url}"
/>
<property
name=
"password"
value=
"${pub.db.password}"
/>
<property
name=
"user"
value=
"${pub.db.user}"
/>
<property
name=
"password"
value=
"${pub.db.password}"
/>
<property
name=
"filters"
value=
"stat"
/>
<property
name=
"maxPoolSize"
value=
"200"
/>
<property
name=
"minPoolSize"
value=
"3"
/>
<property
name=
"maxActive"
value=
"20"
/>
<property
name=
"initialPoolSize"
value=
"1"
/>
<property
name=
"initialSize"
value=
"1"
/>
<property
name=
"maxIdleTime"
value=
"20"
/>
<property
name=
"maxWait"
value=
"60000"
/>
</bean>
<property
name=
"minIdle"
value=
"1"
/>
<bean
id=
"nativeJdbcExtractor"
lazy-init=
"true"
class=
"org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"
/>
<property
name=
"timeBetweenEvictionRunsMillis"
value=
"60000"
/>
<property
name=
"minEvictableIdleTimeMillis"
value=
"300000"
/>
<bean
id=
"lobHandler"
lazy-init=
"true"
class=
"org.springframework.jdbc.support.lob.OracleLobHandler"
>
<property
name=
"testWhileIdle"
value=
"true"
/>
<property
name=
"nativeJdbcExtractor"
>
<property
name=
"testOnBorrow"
value=
"false"
/>
<ref
bean=
"nativeJdbcExtractor"
/>
<property
name=
"testOnReturn"
value=
"false"
/>
</property>
</bean>
<property
name=
"poolPreparedStatements"
value=
"true"
/>
<property
name=
"maxOpenPreparedStatements"
value=
"20"
/>
<bean
id=
"jdbcTemplate"
class=
"org.springframework.jdbc.core.JdbcTemplate"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
<property
name=
"asyncInit"
value=
"true"
/>
</bean>
</bean>
<bean
id=
"lobHandler"
lazy-init=
"true"
class=
"com.alibaba.druid.support.spring.DruidLobHandler"
>
</bean>
<bean
id=
"jdbcTemplate"
class=
"org.springframework.jdbc.core.JdbcTemplate"
>
<property
name=
"dataSource"
ref=
"dataSource"
/>
</bean>
</beans>
</beans>
\ No newline at end of file
huigou-xt/src/main/resources/config/spring/spring-log-dataSource.xml
View file @
265886b4
...
@@ -5,16 +5,28 @@
...
@@ -5,16 +5,28 @@
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
>
http://www.springframework.org/schema/beans/spring-beans.xsd"
>
<bean
id=
"logDataSource"
class=
"com.mchange.v2.c3p0.ComboPooledDataSource"
<bean
id=
"logDataSource"
class=
"com.alibaba.druid.pool.DruidDataSource"
init-method=
"init"
destroy-method=
"close"
>
destroy-method=
"close"
>
<property
name=
"url"
value=
"${log.db.url}"
/>
<property
name=
"driverClass"
value=
"oracle.jdbc.driver.OracleDriver"
/>
<property
name=
"username"
value=
"${log.db.user}"
/>
<property
name=
"jdbcUrl"
value=
"${log.db.url}"
/>
<property
name=
"user"
value=
"${log.db.user}"
/>
<property
name=
"password"
value=
"${log.db.password}"
/>
<property
name=
"password"
value=
"${log.db.password}"
/>
<property
name=
"maxPoolSize"
value=
"200"
/>
<property
name=
"filters"
value=
"stat"
/>
<property
name=
"minPoolSize"
value=
"3"
/>
<property
name=
"initialPoolSize"
value=
"1"
/>
<property
name=
"maxActive"
value=
"20"
/>
<property
name=
"maxIdleTime"
value=
"20"
/>
<property
name=
"initialSize"
value=
"1"
/>
<property
name=
"maxWait"
value=
"60000"
/>
<property
name=
"minIdle"
value=
"1"
/>
<property
name=
"timeBetweenEvictionRunsMillis"
value=
"60000"
/>
<property
name=
"minEvictableIdleTimeMillis"
value=
"300000"
/>
<property
name=
"testWhileIdle"
value=
"true"
/>
<property
name=
"testOnBorrow"
value=
"false"
/>
<property
name=
"testOnReturn"
value=
"false"
/>
<property
name=
"poolPreparedStatements"
value=
"true"
/>
<property
name=
"maxOpenPreparedStatements"
value=
"20"
/>
<property
name=
"asyncInit"
value=
"true"
/>
</bean>
</bean>
<bean
id=
"logEntityManagerFactory"
<bean
id=
"logEntityManagerFactory"
...
...
huigou-xt/src/main/resources/config/spring/spring-system.xml
View file @
265886b4
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<beans
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://www.springframework.org/schema/beans"
xmlns=
"http://www.springframework.org/schema/beans"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
>
http://www.springframework.org/schema/beans/spring-beans.xsd"
>
<!-- freeMarker 配置-->
<!-- freeMarker 配置-->
<bean
id=
"freeMarkerConfigurer"
<bean
id=
"freeMarkerConfigurer"
class=
"org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"
>
class=
"org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"
>
<property
name=
"templateLoaderPath"
value=
"/template"
/>
<property
name=
"templateLoaderPath"
value=
"/template"
/>
<property
name=
"freemarkerSettings"
>
<property
name=
"freemarkerSettings"
>
<props>
<props>
<prop
key=
"template_update_delay"
>
0
</prop>
<prop
key=
"template_update_delay"
>
0
</prop>
<prop
key=
"default_encoding"
>
UTF-8
</prop>
<prop
key=
"default_encoding"
>
UTF-8
</prop>
<prop
key=
"locale"
>
zh_CN
</prop>
<prop
key=
"locale"
>
zh_CN
</prop>
</props>
</props>
</property>
</property>
</bean>
</bean>
<bean
class=
"com.huigou.freemarker.FreemarkerUtil"
>
<bean
class=
"com.huigou.freemarker.FreemarkerUtil"
>
<property
name=
"freeMarkerConfigurer"
ref=
"freeMarkerConfigurer"
/>
<property
name=
"freeMarkerConfigurer"
ref=
"freeMarkerConfigurer"
/>
</bean>
</bean>
<!-- 查询配置文件读取 -->
<!-- 查询配置文件读取 -->
<bean
id=
"queryXmlManager"
class=
"com.huigou.uasp.bmp.common.query.QueryXmlManager"
/>
<bean
id=
"queryXmlManager"
class=
"com.huigou.uasp.bmp.common.query.QueryXmlManager"
>
<!-- 快捷树查询配置 -->
<property
name=
"sqlDialect"
value=
"${sqlDialect}"
/>
<bean
id=
"treeViewManager"
class=
"com.huigou.uasp.bmp.common.treeview.TreeViewManager"
/>
</bean>
<bean
id=
"treeViewApplication"
class=
"com.huigou.uasp.bmp.common.treeview.application.impl.TreeViewApplicationImpl"
>
<!-- 快捷树查询配置 -->
<property
name=
"jdbcDao"
ref=
"jdbcDao"
/>
<bean
id=
"treeViewManager"
class=
"com.huigou.uasp.bmp.common.treeview.TreeViewManager"
/>
<property
name=
"permissionBuilder"
ref=
"queryPermissionBuilder"
/>
<bean
id=
"treeViewApplication"
class=
"com.huigou.uasp.bmp.common.treeview.application.impl.TreeViewApplicationImpl"
>
</bean>
<property
name=
"jdbcDao"
ref=
"jdbcDao"
/>
<!--快捷查询控件配置 -->
<property
name=
"permissionBuilder"
ref=
"queryPermissionBuilder"
/>
<bean
id=
"easySearchManager"
class=
"com.huigou.uasp.bmp.common.easysearch.EasySearchManager"
/>
</bean>
<bean
id=
"easySearchApplication"
class=
"com.huigou.uasp.bmp.common.easysearch.application.impl.EasySearchApplicationImpl"
>
<!--快捷查询控件配置 -->
<property
name=
"sqlQuery"
ref=
"sqlQuery"
/>
<bean
id=
"easySearchManager"
class=
"com.huigou.uasp.bmp.common.easysearch.EasySearchManager"
/>
<property
name=
"permissionBuilder"
ref=
"queryPermissionBuilder"
/>
<bean
id=
"easySearchApplication"
</bean>
class=
"com.huigou.uasp.bmp.common.easysearch.application.impl.EasySearchApplicationImpl"
>
<!--properties 配置文件读取 -->
<property
name=
"sqlQuery"
ref=
"sqlQuery"
/>
<bean
id=
"propertiesReader"
class=
"com.huigou.properties.PropertiesManager"
/>
<property
name=
"permissionBuilder"
ref=
"queryPermissionBuilder"
/>
<!--启动插件配置 -->
</bean>
<bean
id=
"plugInManager"
class=
"com.huigou.uasp.bmp.plugin.PlugInManager"
>
<!--properties 配置文件读取 -->
<property
name=
"plugIns"
>
<bean
id=
"propertiesReader"
class=
"com.huigou.properties.PropertiesManager"
/>
<list>
<!--启动插件配置 -->
<ref
bean=
"sysDictionaryPlugIn"
/>
<bean
id=
"plugInManager"
class=
"com.huigou.uasp.bmp.plugin.PlugInManager"
>
<ref
bean=
"parameterPlugIn"
/>
<property
name=
"plugIns"
>
<ref
bean=
"tmspmPlugIn"
/>
<list>
<ref
bean=
"threeMemberPermissionPlugIn"
/>
<ref
bean=
"sysDictionaryPlugIn"
/>
<ref
bean=
"applicationSystemPlugIn"
/>
<ref
bean=
"parameterPlugIn"
/>
<ref
bean=
"i18npropertiesPlugIn"
/>
<ref
bean=
"tmspmPlugIn"
/>
</list>
<ref
bean=
"threeMemberPermissionPlugIn"
/>
</property>
<ref
bean=
"applicationSystemPlugIn"
/>
</bean>
<ref
bean=
"i18npropertiesPlugIn"
/>
<!-- 表达式执行的工具类 -->
</list>
<bean
id=
"expressUtil"
class=
"com.huigou.express.ExpressUtil"
>
</property>
<property
name=
"beanNames"
>
</bean>
<list>
<!-- 表达式执行的工具类 -->
<ref
bean=
"commonFun"
/>
<bean
id=
"expressUtil"
class=
"com.huigou.express.ExpressUtil"
>
<ref
bean=
"codeGenerator"
/>
<property
name=
"beanNames"
>
<ref
bean=
"orgFun"
/>
<list>
<ref
bean=
"processFun"
/>
<ref
bean=
"commonFun"
/>
</list>
<ref
bean=
"codeGenerator"
/>
</property>
<ref
bean=
"orgFun"
/>
</bean>
<ref
bean=
"processFun"
/>
</list>
</property>
</bean>
</beans>
</beans>
\ No newline at end of file
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