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
086becc7
Commit
086becc7
authored
Jun 27, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
常规BUG的修改
parent
bd366987
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
169 additions
and
21 deletions
+169
-21
ObjectHelper.java
...src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
+16
-3
BaseDao.java
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
+48
-1
BaseDaoImpl.java
...b/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
+105
-17
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/base/ObjectHelper.java
View file @
086becc7
...
...
@@ -337,7 +337,7 @@ public class ObjectHelper {
if
(
method
.
getParameterTypes
().
length
!=
1
)
{
continue
;
}
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
,
toName
);
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
,
toName
);
if
(
obj
.
getSetMethod
()
==
null
)
{
obj
.
setSetMethod
(
method
);
}
...
...
@@ -345,7 +345,7 @@ public class ObjectHelper {
if
(
method
.
getReturnType
()
==
null
)
{
continue
;
}
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
,
toName
);
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
,
toName
);
if
(
obj
.
getGetMethod
()
==
null
)
{
obj
.
setGetMethod
(
method
);
}
...
...
@@ -353,7 +353,7 @@ public class ObjectHelper {
if
(
method
.
getReturnType
()
==
null
)
{
continue
;
}
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
,
toName
);
MethodField
obj
=
getField
(
typeCache
,
methodNameSource
,
toName
);
if
(
obj
.
getGetMethod
()
==
null
)
{
obj
.
setGetMethod
(
method
);
}
...
...
@@ -465,6 +465,19 @@ public class ObjectHelper {
return
writeWithClass
(
emptyWrite
,
to
,
from
,
mapField
);
}
/**
* 根据来源数据,往目标中写入数据
*
* @param tos 目标对象
* @param froms 来源对象
*/
public
static
void
writeArrayWithFrom
(
Object
[]
tos
,
Object
...
froms
)
{
for
(
Object
to
:
tos
)
{
writeWithFrom
(
to
,
froms
);
}
}
/**
* 根据来源数据,往目标中写入数据
*
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/BaseDao.java
View file @
086becc7
...
...
@@ -4,6 +4,7 @@ package com.yanzuoguang.dao;
import
com.yanzuoguang.util.vo.PageSizeData
;
import
com.yanzuoguang.util.vo.PageSizeReqVo
;
import
java.util.Collection
;
import
java.util.List
;
/**
...
...
@@ -21,7 +22,6 @@ public interface BaseDao {
*/
String
create
(
Object
model
);
/**
* 修改数据
*
...
...
@@ -76,4 +76,51 @@ public interface BaseDao {
* @return 需要返回的数据
*/
<
T
extends
Object
>
PageSizeData
<
T
>
loadPage
(
PageSizeReqVo
model
,
Class
<
T
>
resultClass
);
/**
* 修改数据
*
* @param model 需要修改的数据
* @return 删除的主键编号
*/
List
<
String
>
updateList
(
Collection
model
);
/**
* 修改数据
*
* @param model 需要修改的数据
* @return 删除的主键编号
*/
List
<
String
>
updateArray
(
Object
...
model
);
/**
* 创建数据,当不传入了主键时,则会自动生成主键,传入时不会生成。
*
* @param model 需要创建的数据
* @return 创建的主键编号
*/
List
<
String
>
createList
(
List
model
);
/**
* 创建数据,当不传入了主键时,则会自动生成主键,传入时不会生成。
*
* @param model 需要创建的数据
* @return 创建的主键编号
*/
List
<
String
>
createArray
(
Object
...
model
);
/**
* 保存数据,有主键时修改,无主键时创建
*
* @param model 需要保存的数据
* @return 保存的主键编号
*/
List
<
String
>
saveList
(
List
model
);
/**
* 保存数据,有主键时修改,无主键时创建
*
* @param model 需要保存的数据
* @return 保存的主键编号
*/
List
<
String
>
saveArray
(
Object
...
model
);
}
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
View file @
086becc7
...
...
@@ -132,7 +132,6 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
return
retVal
;
}
/**
* 修改数据
*
...
...
@@ -155,6 +154,111 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
return
retVal
;
}
/**
* 保存数据
*
* @param model 需要保存的数据
* @return 保存的主键编号
*/
@Override
public
String
save
(
Object
model
)
{
String
id
=
this
.
getKeyString
(
model
);
if
(
StringHelper
.
isEmpty
(
id
))
{
return
create
(
model
);
}
else
{
return
update
(
model
);
}
}
/**
* 创建数据,当不传入了主键时,则会自动生成主键,传入时不会生成。
*
* @param model 需要创建的数据
* @return 创建的主键编号
*/
@Override
public
List
<
String
>
createList
(
List
model
)
{
List
<
String
>
ret
=
new
ArrayList
<>();
for
(
Object
item
:
model
)
{
ret
.
add
(
this
.
create
(
item
));
}
return
ret
;
}
/**
* 创建数据,当不传入了主键时,则会自动生成主键,传入时不会生成。
*
* @param model 需要创建的数据
* @return 创建的主键编号
*/
@Override
public
List
<
String
>
createArray
(
Object
...
model
)
{
List
<
String
>
ret
=
new
ArrayList
<>();
for
(
Object
item
:
model
)
{
ret
.
add
(
this
.
create
(
item
));
}
return
ret
;
}
/**
* 修改数据
*
* @param model 需要修改的数据
* @return 删除的主键编号
*/
@Override
public
List
<
String
>
updateList
(
Collection
model
)
{
List
<
String
>
ret
=
new
ArrayList
<>();
for
(
Object
item
:
model
)
{
ret
.
add
(
this
.
update
(
item
));
}
return
ret
;
}
/**
* 修改数据
*
* @param model 需要修改的数据
* @return 删除的主键编号
*/
@Override
public
List
<
String
>
updateArray
(
Object
...
model
)
{
List
<
String
>
ret
=
new
ArrayList
<>();
for
(
Object
item
:
model
)
{
ret
.
add
(
this
.
update
(
item
));
}
return
ret
;
}
/**
* 保存数据,有主键时修改,无主键时创建
*
* @param model 需要保存的数据
* @return 保存的主键编号
*/
@Override
public
List
<
String
>
saveList
(
List
model
){
List
<
String
>
ret
=
new
ArrayList
<>();
for
(
Object
item
:
model
)
{
ret
.
add
(
this
.
save
(
item
));
}
return
ret
;
}
/**
* 保存数据,有主键时修改,无主键时创建
*
* @param model 需要保存的数据
* @return 保存的主键编号
*/
@Override
public
List
<
String
>
saveArray
(
Object
...
model
){
List
<
String
>
ret
=
new
ArrayList
<>();
for
(
Object
item
:
model
)
{
ret
.
add
(
this
.
save
(
item
));
}
return
ret
;
}
/**
* 检测数据
*
...
...
@@ -177,22 +281,6 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
}
}
/**
* 保存数据
*
* @param model 需要保存的数据
* @return 保存的主键编号
*/
@Override
public
String
save
(
Object
model
)
{
String
id
=
this
.
getKeyString
(
model
);
if
(
StringHelper
.
isEmpty
(
id
))
{
return
create
(
model
);
}
else
{
return
update
(
model
);
}
}
/**
* 删除数据
*
...
...
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