Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
35e63c66
Commit
35e63c66
authored
Aug 09, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实例化关系
parent
0e4dcd82
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
82 deletions
+20
-82
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+8
-30
DbExecuteImpl.java
.../src/main/java/com/yanzuoguang/db/impl/DbExecuteImpl.java
+9
-28
DbPrintSql.java
...-db/src/main/java/com/yanzuoguang/db/impl/DbPrintSql.java
+3
-24
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
35e63c66
...
...
@@ -11,11 +11,8 @@ import com.yanzuoguang.util.helper.ArrayHelper;
import
com.yanzuoguang.util.helper.StringFormatHandle
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.*
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.BeanInitializationException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.context.*
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -25,17 +22,16 @@ import java.util.regex.Pattern;
*
* @author 颜佐光
*/
public
abstract
class
BaseDaoSql
implements
ApplicationContextAware
{
public
abstract
class
BaseDaoSql
{
/**
* SQL语句支持的最大长度
*/
public
static
int
MAX_LEVEL
=
10
;
/**
*
数据库执行类
*
缓存的表结构和SQL语句
*/
pr
ivate
DbExecute
db
;
pr
otected
final
static
MemoryCache
<
TableSqlCache
>
cache
=
new
MemoryCache
<>()
;
/**
* 定义列表记录缓存对象
...
...
@@ -48,9 +44,9 @@ public abstract class BaseDaoSql implements ApplicationContextAware {
protected
TableSqlCache
table
=
null
;
/**
*
缓存的表结构和SQL语句
*
数据库执行类
*/
pr
otected
final
static
MemoryCache
<
TableSqlCache
>
cache
=
new
MemoryCache
<>()
;
pr
ivate
DbExecute
db
;
/**
* 构造函数
...
...
@@ -72,25 +68,7 @@ public abstract class BaseDaoSql implements ApplicationContextAware {
this
.
init
();
}
/**
* Set the ApplicationContext that this object runs in.
* Normally this call will be used to initialize the object.
* <p>Invoked after population of normal bean properties but before an init callback such
* as {@link InitializingBean#afterPropertiesSet()}
* or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
* {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
* {@link MessageSourceAware}, if applicable.
*
* @param applicationContext the ApplicationContext object to be used by this object
* @throws ApplicationContextException in case of context initialization errors
* @throws BeansException if thrown by application context methods
* @see BeanInitializationException
*/
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
db
=
applicationContext
.
getBean
(
DbExecute
.
class
);
}
@Resource
public
void
setDb
(
DbExecute
db
)
{
this
.
db
=
db
;
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/db/impl/DbExecuteImpl.java
View file @
35e63c66
...
...
@@ -4,10 +4,8 @@ import com.yanzuoguang.db.ConfigDb;
import
com.yanzuoguang.db.DbExecute
;
import
com.yanzuoguang.util.vo.MapRow
;
import
com.yanzuoguang.util.vo.Ref
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.BeanInitializationException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.context.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.RowCallbackHandler
;
import
org.springframework.jdbc.support.rowset.SqlRowSet
;
...
...
@@ -25,34 +23,17 @@ import java.util.List;
* @author 颜佐光
*/
@Component
public
class
DbExecuteImpl
implements
DbExecute
,
ApplicationContextAware
{
private
DbPrintSql
printSql
;
private
ConfigDb
configDb
;
public
class
DbExecuteImpl
implements
DbExecute
{
@Resource
@Qualifier
(
"jdbcTemplate"
)
private
JdbcTemplate
jdbc
;
/**
* Set the ApplicationContext that this object runs in.
* Normally this call will be used to initialize the object.
* <p>Invoked after population of normal bean properties but before an init callback such
* as {@link InitializingBean#afterPropertiesSet()}
* or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
* {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
* {@link MessageSourceAware}, if applicable.
*
* @param applicationContext the ApplicationContext object to be used by this object
* @throws ApplicationContextException in case of context initialization errors
* @throws BeansException if thrown by application context methods
* @see BeanInitializationException
*/
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
printSql
=
applicationContext
.
getBean
(
DbPrintSql
.
class
);
this
.
configDb
=
applicationContext
.
getBean
(
ConfigDb
.
class
);
}
@Autowired
private
DbPrintSql
printSql
;
@Autowired
private
ConfigDb
configDb
;
public
JdbcTemplate
getJdbc
()
{
return
jdbc
;
...
...
yzg-util-db/src/main/java/com/yanzuoguang/db/impl/DbPrintSql.java
View file @
35e63c66
...
...
@@ -3,10 +3,7 @@ package com.yanzuoguang.db.impl;
import
com.yanzuoguang.db.ConfigDb
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.BeanInitializationException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.context.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -15,29 +12,11 @@ import org.springframework.stereotype.Component;
* @author 颜佐光
*/
@Component
public
class
DbPrintSql
implements
ApplicationContextAware
{
public
class
DbPrintSql
{
@Autowired
private
ConfigDb
configDb
;
/**
* Set the ApplicationContext that this object runs in.
* Normally this call will be used to initialize the object.
* <p>Invoked after population of normal bean properties but before an init callback such
* as {@link InitializingBean#afterPropertiesSet()}
* or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
* {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
* {@link MessageSourceAware}, if applicable.
*
* @param applicationContext the ApplicationContext object to be used by this object
* @throws ApplicationContextException in case of context initialization errors
* @throws BeansException if thrown by application context methods
* @see BeanInitializationException
*/
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
configDb
=
applicationContext
.
getBean
(
ConfigDb
.
class
);
}
/**
* 获取参数处理之后的SQL语句
*
...
...
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