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
1ea210d9
Commit
1ea210d9
authored
May 15, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加对Android的支持
parent
1ee3b43d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
5 deletions
+56
-5
BaseDao.java
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
+13
-0
BaseDaoImpl.java
...b/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
+43
-5
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
View file @
1ea210d9
package
com
.
yanzuoguang
.
dao
;
import
java.util.List
;
/**
* 数据基本操作接口
* @author 颜佐光
...
...
@@ -49,4 +51,15 @@ public interface BaseDao {
* @return 需要返回的数据
*/
<
T
extends
Object
>
T
load
(
Object
model
,
Class
<
T
>
cls
);
/**
* 加载列表数据
*
* @param model 加载数据的请求参数
* @param cls 需要加载的数据的类型
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
<
T
extends
Object
>
List
<
T
>
loadList
(
Object
model
,
Class
<
T
>
cls
);
}
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
View file @
1ea210d9
...
...
@@ -10,13 +10,11 @@ import com.yanzuoguang.util.helper.StringHelper;
import
com.yanzuoguang.util.vo.InitDao
;
import
com.yanzuoguang.util.vo.MapRow
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
/**
* 数据库操作的基本工具类
*
* @author 颜佐光
*/
public
abstract
class
BaseDaoImpl
extends
BaseDaoSql
implements
BaseDao
{
...
...
@@ -55,7 +53,7 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
return
""
;
}
String
keyString
=
key
.
toString
();
if
(
DaoConst
.
ZERO
.
equals
(
keyString
))
{
if
(
DaoConst
.
ZERO
.
equals
(
keyString
))
{
keyString
=
""
;
}
return
keyString
;
...
...
@@ -252,6 +250,46 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
return
to
;
}
/**
* 加载数据
*
* @param model 加载数据的请求参数
* @param cls 需要加载的数据的类型
* @param <T> 返回数据的类型
* @return 需要返回的数据
*/
@Override
public
<
T
extends
Object
>
List
<
T
>
loadList
(
Object
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
);
}
// 通过传入数据进行加载
List
<
T
>
to
=
this
.
query
(
cls
,
DaoConst
.
LOAD
,
from
);
if
(
to
==
null
||
to
.
size
()
==
0
)
{
return
new
ArrayList
<>();
}
// 判断来源主键是否存在,不存在则获取加载后的主键
if
(
StringHelper
.
isEmpty
(
key
))
{
check
(
DaoConst
.
OPERATOR_TYPE_LOAD
,
key
,
to
);
}
else
{
for
(
Object
item
:
to
)
{
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