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
2a872c7e
Commit
2a872c7e
authored
May 28, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
常规BUG的修改
parent
249c8f0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
BaseDao.java
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
+14
-0
BaseDaoImpl.java
...b/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
+41
-2
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
View file @
2a872c7e
package
com
.
yanzuoguang
.
dao
;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeReqVo
;
import
java.util.List
;
/**
* 数据基本操作接口
*
* @author 颜佐光
*/
public
interface
BaseDao
{
...
...
@@ -62,4 +66,14 @@ public interface BaseDao {
* @return 需要返回的数据
*/
<
T
extends
Object
>
List
<
T
>
loadList
(
Object
model
,
Class
<
T
>
cls
);
/**
* 加载分页数据
*
* @param model 加载数据的请求参数
* @param cls 需要加载的数据的类型
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
model
,
Class
<
T
>
cls
);
}
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
View file @
2a872c7e
...
...
@@ -7,8 +7,7 @@ import com.yanzuoguang.util.base.ObjectHelper;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.DateHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.InitDao
;
import
com.yanzuoguang.util.vo.MapRow
;
import
com.yanzuoguang.util.vo.*
;
import
java.util.*
;
...
...
@@ -290,6 +289,46 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
return
to
;
}
/**
* 加载分页数据
*
* @param model 加载数据的请求参数
* @param cls 需要加载的数据的类型
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
@Override
public
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
model
,
Class
<
T
>
cls
)
{
// 获取来源主键
Object
from
=
model
;
String
key
=
this
.
getInputKey
(
from
);
// 当主键存在时,只通过主键加载
if
(!
StringHelper
.
isEmpty
(
key
))
{
from
=
new
HashMap
<
String
,
Object
>(
DaoConst
.
COLLECTION_INIT_SIZE
);
this
.
setKeyString
(
from
,
key
);
}
// 通过传入数据进行加载
PageSizeData
<
T
>
to
=
this
.
queryPage
(
cls
,
model
,
DaoConst
.
LOAD
,
from
);
if
(
to
==
null
||
to
.
getPageTotal
()
==
0
)
{
return
to
;
}
// 判断来源主键是否存在,不存在则获取加载后的主键
if
(
StringHelper
.
isEmpty
(
key
))
{
check
(
DaoConst
.
OPERATOR_TYPE_LOAD
,
key
,
to
);
}
else
{
for
(
Object
item
:
to
.
getList
())
{
key
=
this
.
getKeyString
(
item
);
check
(
DaoConst
.
OPERATOR_TYPE_LOAD
,
key
,
to
);
}
}
return
to
;
}
/**
* 添加统计数据
*
...
...
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