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
621a14bb
Commit
621a14bb
authored
Jun 05, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
压缩视频
parent
d73ea0f1
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
285 additions
and
119 deletions
+285
-119
BaseDao.java
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
+12
-14
QueryPara.java
yzg-util-db/src/main/java/com/yanzuoguang/dao/QueryPara.java
+53
-0
BaseDaoImpl.java
...b/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
+32
-31
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+188
-74
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
View file @
621a14bb
...
...
@@ -5,8 +5,6 @@ import com.yanzuoguang.util.vo.DataDaoVo;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeReqVo
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -73,11 +71,11 @@ public interface BaseDao {
*
* @param model 加载数据的请求参数,可以是主键字符串(Int),或者是包含主键的实体,或者是包含其他非主键的实体完全匹配.
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
<
T
extends
Object
>
T
load
(
Object
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
);
<
T
extends
Object
>
T
load
(
Object
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
);
/**
...
...
@@ -95,11 +93,11 @@ public interface BaseDao {
*
* @param model 加载数据的请求参数,可以是主键字符串(Int),或者是包含主键的实体,或者是包含其他非主键的实体完全匹配.
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
<
T
extends
Object
>
List
<
T
>
loadList
(
Object
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
);
<
T
extends
Object
>
List
<
T
>
loadList
(
Object
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
);
/**
* 加载分页数据
...
...
@@ -116,11 +114,11 @@ public interface BaseDao {
*
* @param model 加载数据的请求参数,可以是主键字符串(Int),或者是包含主键的实体,或者是包含其他非主键的实体完全匹配.
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
);
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
);
/**
* 加载分页数据
...
...
@@ -139,11 +137,11 @@ public interface BaseDao {
* @param pageReq 分页数据信息
* @param model 加载数据的请求参数,可以是主键字符串(Int),或者是包含主键的实体,或者是包含其他非主键的实体完全匹配.
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
);
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
);
/**
* 加载分页数据
...
...
@@ -160,11 +158,11 @@ public interface BaseDao {
*
* @param model 加载数据的请求参数
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
);
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
);
/**
* 加载分页数据
...
...
@@ -181,11 +179,11 @@ public interface BaseDao {
*
* @param model 加载数据的请求参数
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
);
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
);
/**
* 修改数据
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/QueryPara.java
0 → 100644
View file @
621a14bb
package
com
.
yanzuoguang
.
dao
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* 查询参数
*
* @author 颜佐光
*/
@ApiModel
(
description
=
"查询参数"
)
public
class
QueryPara
{
/**
* 所有条件生效
*/
@ApiModelProperty
(
notes
=
"所有条件生效,而不仅仅在主键存在时,通过主键加载"
)
private
boolean
fullCond
;
/**
* 查询删除标记的结果
*/
@ApiModelProperty
(
notes
=
"在数据通过删除标记删除时,可以通过该参数查询出来"
)
private
boolean
loadRemove
;
public
QueryPara
()
{
}
public
QueryPara
(
boolean
fullCond
)
{
this
.
fullCond
=
fullCond
;
}
public
QueryPara
(
boolean
fullCond
,
boolean
loadRemove
)
{
this
.
fullCond
=
fullCond
;
this
.
loadRemove
=
loadRemove
;
}
public
boolean
isFullCond
()
{
return
fullCond
;
}
public
void
setFullCond
(
boolean
fullCond
)
{
this
.
fullCond
=
fullCond
;
}
public
boolean
isLoadRemove
()
{
return
loadRemove
;
}
public
void
setLoadRemove
(
boolean
loadRemove
)
{
this
.
loadRemove
=
loadRemove
;
}
}
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
View file @
621a14bb
...
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.dao.impl;
import
com.yanzuoguang.dao.BaseDao
;
import
com.yanzuoguang.dao.DaoConst
;
import
com.yanzuoguang.dao.QueryPara
;
import
com.yanzuoguang.db.DbExecute
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.exception.CodeException
;
...
...
@@ -391,8 +392,8 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
* @param model 来源对象
* @return
*/
protected
Object
getLoadFrom
(
Object
model
,
boolean
fullCond
)
{
if
(
fullCond
)
{
protected
Object
getLoadFrom
(
Object
model
,
QueryPara
queryPara
)
{
if
(
queryPara
!=
null
&&
queryPara
.
isFullCond
()
)
{
return
model
;
}
...
...
@@ -429,16 +430,16 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*
* @param model 加载数据的请求参数
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
@Override
public
<
T
extends
Object
>
T
load
(
Object
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
)
{
public
<
T
extends
Object
>
T
load
(
Object
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
)
{
// 获取来源主键
Object
from
=
this
.
getLoadFrom
(
model
,
fullCond
);
Object
from
=
this
.
getLoadFrom
(
model
,
queryPara
);
// 通过传入数据进行加载
T
to
=
this
.
queryFirst
(
resultClass
,
DaoConst
.
LOAD
,
from
);
T
to
=
this
.
queryFirst
(
resultClass
,
DaoConst
.
LOAD
,
from
,
queryPara
);
if
(
to
==
null
)
{
return
null
;
}
...
...
@@ -460,7 +461,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/
@Override
public
<
T
extends
Object
>
T
load
(
Object
model
,
Class
<
T
>
resultClass
)
{
return
this
.
load
(
model
,
resultClass
,
false
);
return
this
.
load
(
model
,
resultClass
,
null
);
}
/**
...
...
@@ -468,17 +469,17 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*
* @param model 加载数据的请求参数
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
@Override
public
<
T
extends
Object
>
List
<
T
>
loadList
(
Object
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
)
{
public
<
T
extends
Object
>
List
<
T
>
loadList
(
Object
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
)
{
// 获取来源主键
Object
from
=
this
.
getLoadFrom
(
model
,
fullCond
);
Object
from
=
this
.
getLoadFrom
(
model
,
queryPara
);
// 通过传入数据进行加载
List
<
T
>
to
=
this
.
query
(
resultClass
,
DaoConst
.
LOAD
,
from
);
List
<
T
>
to
=
this
.
query
(
resultClass
,
DaoConst
.
LOAD
,
from
,
queryPara
);
if
(
to
==
null
||
to
.
size
()
==
0
)
{
return
new
ArrayList
<>();
}
...
...
@@ -498,7 +499,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/
@Override
public
<
T
extends
Object
>
List
<
T
>
loadList
(
Object
model
,
Class
<
T
>
resultClass
)
{
return
this
.
loadList
(
model
,
resultClass
,
false
);
return
this
.
loadList
(
model
,
resultClass
,
null
);
}
...
...
@@ -512,7 +513,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/
@Override
public
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
)
{
return
this
.
loadPage
(
model
,
model
,
resultClass
,
false
);
return
this
.
loadPage
(
model
,
model
,
resultClass
,
null
);
}
/**
...
...
@@ -520,13 +521,13 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*
* @param model 加载数据的请求参数
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
@Override
public
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
)
{
return
this
.
loadPage
(
model
,
model
,
resultClass
,
fullCond
);
public
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
)
{
return
this
.
loadPage
(
model
,
model
,
resultClass
,
queryPara
);
}
/**
...
...
@@ -539,7 +540,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/
@Override
public
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
)
{
return
this
.
loadPage
(
pageReq
,
model
,
resultClass
,
false
);
return
this
.
loadPage
(
pageReq
,
model
,
resultClass
,
null
);
}
/**
...
...
@@ -547,17 +548,17 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*
* @param model 加载数据的请求参数
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
@Override
public
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
)
{
public
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
)
{
// 获取来源主键
Object
from
=
this
.
getLoadFrom
(
model
,
fullCond
);
Object
from
=
this
.
getLoadFrom
(
model
,
queryPara
);
// 通过传入数据进行加载
PageSizeData
<
T
>
to
=
this
.
queryPage
(
resultClass
,
pageReq
,
DaoConst
.
LOAD
,
from
);
PageSizeData
<
T
>
to
=
this
.
queryPage
(
resultClass
,
pageReq
,
DaoConst
.
LOAD
,
from
,
queryPara
);
if
(
to
==
null
||
to
.
getPageTotal
()
==
0
)
{
return
to
;
}
...
...
@@ -579,7 +580,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/
@Override
public
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
)
{
return
this
.
loadPageData
(
model
,
model
,
resultClass
,
false
);
return
this
.
loadPageData
(
model
,
model
,
resultClass
,
null
);
}
/**
...
...
@@ -587,13 +588,13 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*
* @param model 加载数据的请求参数
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
@Override
public
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
)
{
return
this
.
loadPageData
(
model
,
model
,
resultClass
,
fullCond
);
public
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
)
{
return
this
.
loadPageData
(
model
,
model
,
resultClass
,
queryPara
);
}
...
...
@@ -607,7 +608,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*/
@Override
public
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
)
{
return
this
.
loadPageData
(
pageReq
,
model
,
resultClass
,
false
);
return
this
.
loadPageData
(
pageReq
,
model
,
resultClass
,
null
);
}
/**
...
...
@@ -615,19 +616,19 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
*
* @param model 加载数据的请求参数
* @param resultClass 需要加载的数据的类型
* @param
fullCond 所有条件生效
* @param
queryPara 查询参数
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
@Override
public
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
,
boolean
fullCond
)
{
public
<
T
extends
Object
>
List
<
T
>
loadPageData
(
PageSizeReqVo
pageReq
,
Object
model
,
Class
<
T
>
resultClass
,
QueryPara
queryPara
)
{
// 获取来源主键
Object
from
=
this
.
getLoadFrom
(
model
,
fullCond
);
Object
from
=
this
.
getLoadFrom
(
model
,
queryPara
);
// 通过传入数据进行加载
List
<
T
>
to
=
this
.
queryPageData
(
resultClass
,
pageReq
,
DaoConst
.
LOAD
,
from
);
List
<
T
>
to
=
this
.
queryPageData
(
resultClass
,
pageReq
,
DaoConst
.
LOAD
,
from
,
queryPara
);
if
(
to
==
null
)
{
return
to
;
return
new
ArrayList
<>()
;
}
// 判断来源主键是否存在,不存在则获取加载后的主键
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
621a14bb
This diff is collapsed.
Click to expand it.
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