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
52ab4784
Commit
52ab4784
authored
Oct 08, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口文档的支持
parent
8c810bf4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
GroupAdd.java
...l-db/src/main/java/com/yanzuoguang/dao/impl/GroupAdd.java
+14
-0
TableStruct.java
...b/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
+39
-0
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/GroupAdd.java
0 → 100644
View file @
52ab4784
package
com
.
yanzuoguang
.
dao
.
impl
;
/**
* 累加接口
*
* @param <T>
*/
public
interface
GroupAdd
<
T
extends
GroupAdd
>
{
/***
* 自动累加接口
* @param from 累加接口
*/
void
add
(
T
from
);
}
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
View file @
52ab4784
...
...
@@ -683,4 +683,43 @@ public class TableStruct {
addWhereRemove
(
sql
);
sqlTableData
.
add
(
sql
);
}
/**
* 表结构累加
*
* @param froms 来源数据
* @param cls 类型
* @param <T>
* @return
*/
public
static
<
T
extends
GroupAdd
>
List
<
T
>
megerGroupAdd
(
List
<
T
>
froms
,
Class
<
T
>
cls
)
{
List
<
T
>
tos
=
new
ArrayList
<>();
Map
<
String
,
T
>
mapFrom
=
new
HashMap
<>();
TableStruct
tableStruct
=
new
TableStruct
(
StringHelper
.
EMPTY
,
cls
);
List
<
TableFieldVo
>
fields
=
tableStruct
.
getGroupLatitudeFields
();
for
(
T
from
:
froms
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
TableFieldVo
field
:
fields
)
{
String
value
=
StringHelper
.
getFirst
(
ObjectHelper
.
getString
(
from
,
field
.
inputName
));
sb
.
append
(
value
);
sb
.
append
(
":"
);
}
String
key
=
StringHelper
.
getIdMD5
(
sb
.
toString
());
if
(!
mapFrom
.
containsKey
(
key
))
{
tos
.
add
(
from
);
mapFrom
.
put
(
key
,
from
);
}
else
{
T
histor
=
mapFrom
.
get
(
key
);
histor
.
add
(
from
);
}
}
return
tos
;
}
}
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