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
acef36f1
Commit
acef36f1
authored
May 30, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将源码打包进jar包
parent
d82a57fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
BaseDaoImpl.java
...b/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
+1
-5
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+19
-11
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
View file @
acef36f1
...
...
@@ -98,7 +98,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
List
<
Object
>
paraList
=
new
ArrayList
<>();
for
(
Object
item
:
list
)
{
List
<
Object
>
paras
=
new
ArrayList
<>();
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
item
);
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
item
,
true
);
if
(
sqlList
.
length
()
>
0
)
{
sql
=
sql
.
replaceAll
(
DaoConst
.
SQL_LIST_FROM
,
DaoConst
.
SQL_LIST_TO
);
}
...
...
@@ -402,10 +402,6 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
if
(
queryPara
!=
null
&&
queryPara
.
isFullCond
())
{
return
model
;
}
// 对查询条件进行初始化
if
(
model
instanceof
InitDaoQuery
)
{
((
InitDaoQuery
)
model
).
initCond
();
}
// 获取来源主键
Object
from
=
this
.
table
.
getKeyObject
(
model
);
return
from
;
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
acef36f1
...
...
@@ -11,10 +11,7 @@ import com.yanzuoguang.util.cache.MemoryCache;
import
com.yanzuoguang.util.helper.ArrayHelper
;
import
com.yanzuoguang.util.helper.StringFormatHandle
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.MapRow
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeReq
;
import
com.yanzuoguang.util.vo.PageSizeReqVo
;
import
com.yanzuoguang.util.vo.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.*
;
...
...
@@ -190,7 +187,7 @@ public abstract class BaseDaoSql {
*/
protected
int
updateSql
(
SqlData
sqlData
,
Object
model
)
{
List
<
Object
>
paras
=
new
ArrayList
<
Object
>();
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
model
);
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
model
,
true
);
int
ret
=
this
.
getDb
().
update
(
this
.
getClass
(),
sqlData
.
getName
(),
sql
,
paras
.
toArray
());
this
.
onUpdateSql
(
model
);
return
ret
;
...
...
@@ -251,7 +248,7 @@ public abstract class BaseDaoSql {
*/
protected
<
T
extends
Object
>
List
<
T
>
queryData
(
Class
<
T
>
cls
,
SqlData
sqlData
,
Object
model
)
{
List
<
Object
>
paras
=
new
ArrayList
<
Object
>();
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
model
);
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
model
,
false
);
List
<
T
>
list
=
this
.
queryWithCache
(
cls
,
sqlData
.
getName
(),
sql
,
paras
.
toArray
());
return
list
;
}
...
...
@@ -266,7 +263,7 @@ public abstract class BaseDaoSql {
*/
protected
<
T
extends
Object
>
void
queryData
(
Class
<
T
>
cls
,
DbRow
<
T
>
handle
,
SqlData
sqlData
,
Object
model
)
{
List
<
Object
>
paras
=
new
ArrayList
<>();
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
model
);
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
model
,
false
);
// 查询数据
this
.
getDb
().
query
(
this
.
getClass
(),
cls
,
handle
,
sqlData
.
getName
(),
sql
,
paras
.
toArray
());
}
...
...
@@ -305,7 +302,7 @@ public abstract class BaseDaoSql {
sqlData
=
getSqlQueryPara
(
sqlData
,
queryPara
,
true
);
List
<
Object
>
paras
=
new
ArrayList
<>();
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
model
);
String
sql
=
this
.
getPara
(
paras
,
sqlData
,
model
,
false
);
Object
cell
=
this
.
queryCellWithCache
(
sqlData
.
getName
(),
sql
,
paras
.
toArray
());
return
cell
;
}
...
...
@@ -527,7 +524,7 @@ public abstract class BaseDaoSql {
// 按照分页查询数据
List
<
Object
>
baseParas
=
new
ArrayList
<
Object
>();
String
sql
=
this
.
getPara
(
baseParas
,
to
,
model
);
String
sql
=
this
.
getPara
(
baseParas
,
to
,
model
,
false
);
// 查询实体数据
List
<
T
>
list
=
this
.
queryWithCache
(
cls
,
sqlName
,
sql
,
baseParas
.
toArray
());
data
.
setList
(
list
);
...
...
@@ -544,7 +541,7 @@ public abstract class BaseDaoSql {
// 按照分页查询数据
List
<
Object
>
baseParas
=
new
ArrayList
<
Object
>();
String
sql
=
this
.
getPara
(
baseParas
,
fromPageSize
,
model
);
String
sql
=
this
.
getPara
(
baseParas
,
fromPageSize
,
model
,
false
);
sql
=
sql
.
trim
();
// 查询总数据量
String
sqlSize
=
"SELECT COUNT(1) FROM ("
+
...
...
@@ -569,7 +566,18 @@ public abstract class BaseDaoSql {
* @param model 参数的实体
* @return SQL条件
*/
protected
String
getPara
(
List
<
Object
>
paras
,
SqlData
sqlData
,
Object
model
)
{
protected
String
getPara
(
List
<
Object
>
paras
,
SqlData
sqlData
,
Object
model
,
boolean
isUpdate
)
{
if
(
isUpdate
)
{
if
(
model
instanceof
InitDao
)
{
InitDao
to
=
(
InitDao
)
model
;
to
.
init
();
}
}
else
{
// 对查询条件进行初始化
if
(
model
instanceof
InitDaoQuery
)
{
((
InitDaoQuery
)
model
).
initCond
();
}
}
// 将SQL语句进行代码片段追加
StringBuilder
sb
=
new
StringBuilder
(
sqlData
.
getSql
());
for
(
String
code
:
DaoConst
.
LAST_AUTO_ADD
)
{
...
...
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