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
cd127be2
Commit
cd127be2
authored
Jun 18, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL层级处理的支持
parent
fcc5778a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
17 deletions
+12
-17
StringFormatHandle.java
.../java/com/yanzuoguang/util/helper/StringFormatHandle.java
+2
-1
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+5
-11
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+2
-2
PrinterHelper.java
...int/src/main/java/com/yanzuoguang/util/PrinterHelper.java
+3
-3
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringFormatHandle.java
View file @
cd127be2
...
@@ -11,9 +11,10 @@ public interface StringFormatHandle {
...
@@ -11,9 +11,10 @@ public interface StringFormatHandle {
* 对模板进行格式化处理
* 对模板进行格式化处理
*
*
* @param sb 返回得结果模板
* @param sb 返回得结果模板
* @param group 带{xxx}的全格式
* @param fieldFull 全格式
* @param fieldFull 全格式
* @param field 字段
* @param field 字段
* @param command 字段格式化
* @param command 字段格式化
*/
*/
void
addPos
(
StringBuilder
sb
,
String
fieldFull
,
String
field
,
String
command
);
void
addPos
(
StringBuilder
sb
,
String
group
,
String
fieldFull
,
String
field
,
String
command
);
}
}
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
cd127be2
...
@@ -1060,22 +1060,16 @@ public class StringHelper {
...
@@ -1060,22 +1060,16 @@ public class StringHelper {
*/
*/
public
static
String
getCodeString
(
String
from
,
Object
target
)
{
public
static
String
getCodeString
(
String
from
,
Object
target
)
{
return
getFormat
(
from
,
StringHelper
.
EMPTY
,
new
StringFormatHandle
()
{
return
getFormat
(
from
,
StringHelper
.
EMPTY
,
new
StringFormatHandle
()
{
/**
* 对模板进行格式化处理
*
* @param sb 返回得结果模板
* @param fieldFull 全格式
* @param field 字段
* @param command 字段格式化
*/
@Override
@Override
public
void
addPos
(
StringBuilder
sb
,
String
fieldFull
,
String
field
,
String
command
)
{
public
void
addPos
(
StringBuilder
sb
,
String
gorup
,
String
fieldFull
,
String
field
,
String
command
)
{
String
value
=
StringHelper
.
getFirst
(
ObjectHelper
.
getString
(
target
,
field
),
EMPTY
);
String
value
=
StringHelper
.
getFirst
(
ObjectHelper
.
getString
(
target
,
field
),
EMPTY
);
sb
.
append
(
value
);
sb
.
append
(
value
);
}
}
});
});
}
}
private
static
Pattern
reg
=
Pattern
.
compile
(
"\\{(.+?)\\}"
);
/**
/**
* 进行字段格式化处理
* 进行字段格式化处理
*
*
...
@@ -1086,7 +1080,6 @@ public class StringHelper {
...
@@ -1086,7 +1080,6 @@ public class StringHelper {
*/
*/
public
static
String
getFormat
(
String
format
,
String
defaultField
,
StringFormatHandle
fieldFormatHandle
)
{
public
static
String
getFormat
(
String
format
,
String
defaultField
,
StringFormatHandle
fieldFormatHandle
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
Pattern
reg
=
Pattern
.
compile
(
"\\{(.+?)\\}"
);
Matcher
matches
=
reg
.
matcher
(
format
);
Matcher
matches
=
reg
.
matcher
(
format
);
int
start
=
0
;
int
start
=
0
;
while
(
matches
.
find
())
{
while
(
matches
.
find
())
{
...
@@ -1094,6 +1087,7 @@ public class StringHelper {
...
@@ -1094,6 +1087,7 @@ public class StringHelper {
if
(
len
>
0
)
{
if
(
len
>
0
)
{
sb
.
append
(
format
.
substring
(
start
,
matches
.
start
()));
sb
.
append
(
format
.
substring
(
start
,
matches
.
start
()));
}
}
String
group
=
matches
.
group
(
0
);
String
fieldFull
=
matches
.
group
(
1
);
String
fieldFull
=
matches
.
group
(
1
);
if
(
fieldFull
.
startsWith
(
"0"
)
&&
!
StringHelper
.
isEmpty
(
defaultField
))
{
if
(
fieldFull
.
startsWith
(
"0"
)
&&
!
StringHelper
.
isEmpty
(
defaultField
))
{
fieldFull
=
defaultField
+
fieldFull
.
substring
(
1
);
fieldFull
=
defaultField
+
fieldFull
.
substring
(
1
);
...
@@ -1104,7 +1098,7 @@ public class StringHelper {
...
@@ -1104,7 +1098,7 @@ public class StringHelper {
if
(
fields
.
length
>
1
)
{
if
(
fields
.
length
>
1
)
{
fieldFormat
=
fieldFull
.
substring
(
field
.
length
()
+
1
);
fieldFormat
=
fieldFull
.
substring
(
field
.
length
()
+
1
);
}
}
fieldFormatHandle
.
addPos
(
sb
,
fieldFull
,
field
,
fieldFormat
);
fieldFormatHandle
.
addPos
(
sb
,
group
,
fieldFull
,
field
,
fieldFormat
);
start
=
matches
.
end
();
start
=
matches
.
end
();
}
}
sb
.
append
(
format
.
substring
(
start
));
sb
.
append
(
format
.
substring
(
start
));
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
cd127be2
...
@@ -586,11 +586,11 @@ public abstract class BaseDaoSql {
...
@@ -586,11 +586,11 @@ public abstract class BaseDaoSql {
sql
=
StringHelper
.
getFormat
(
sql
,
StringHelper
.
EMPTY
,
new
StringFormatHandle
()
{
sql
=
StringHelper
.
getFormat
(
sql
,
StringHelper
.
EMPTY
,
new
StringFormatHandle
()
{
@Override
@Override
public
void
addPos
(
StringBuilder
sb
,
String
fieldFull
,
String
field
,
String
command
)
{
public
void
addPos
(
StringBuilder
sb
,
String
group
,
String
fieldFull
,
String
field
,
String
command
)
{
// 设置寻找到标签
// 设置寻找到标签
find
[
0
]
=
true
;
find
[
0
]
=
true
;
// 寻找到的代码片段 不包含分括号
// 寻找到的代码片段 不包含分括号
String
name
=
fieldFull
;
String
name
=
group
;
List
<
String
>
codes
=
codeMap
.
containsKey
(
name
)
?
codeMap
.
get
(
name
)
:
new
ArrayList
<>();
List
<
String
>
codes
=
codeMap
.
containsKey
(
name
)
?
codeMap
.
get
(
name
)
:
new
ArrayList
<>();
for
(
String
code
:
codes
)
{
for
(
String
code
:
codes
)
{
sb
.
append
(
" "
);
sb
.
append
(
" "
);
...
...
yzg-util-print/src/main/java/com/yanzuoguang/util/PrinterHelper.java
View file @
cd127be2
...
@@ -88,7 +88,7 @@ public class PrinterHelper {
...
@@ -88,7 +88,7 @@ public class PrinterHelper {
// 生成目标格式化字符串
// 生成目标格式化字符串
String
format
=
StringHelper
.
getFormat
(
item
.
getFormat
(),
item
.
getName
(),
new
StringFormatHandle
()
{
String
format
=
StringHelper
.
getFormat
(
item
.
getFormat
(),
item
.
getName
(),
new
StringFormatHandle
()
{
@Override
@Override
public
void
addPos
(
StringBuilder
sb
,
String
fieldFull
,
String
field
,
String
command
)
{
public
void
addPos
(
StringBuilder
sb
,
String
group
,
String
fieldFull
,
String
field
,
String
command
)
{
// 对现有的字段进行加密
// 对现有的字段进行加密
sb
.
append
(
"{"
);
sb
.
append
(
"{"
);
String
fieldTo
=
field
;
String
fieldTo
=
field
;
...
@@ -131,7 +131,7 @@ public class PrinterHelper {
...
@@ -131,7 +131,7 @@ public class PrinterHelper {
String
format
,
String
defaultField
)
{
String
format
,
String
defaultField
)
{
return
StringHelper
.
getFormat
(
format
,
defaultField
,
new
StringFormatHandle
()
{
return
StringHelper
.
getFormat
(
format
,
defaultField
,
new
StringFormatHandle
()
{
@Override
@Override
public
void
addPos
(
StringBuilder
sb
,
String
fieldFull
,
String
field
,
String
command
)
{
public
void
addPos
(
StringBuilder
sb
,
String
group
,
String
fieldFull
,
String
field
,
String
command
)
{
sb
.
append
(
"{"
);
sb
.
append
(
"{"
);
Object
fieldValue
=
ObjectHelper
.
get
(
resultFrom
,
field
);
Object
fieldValue
=
ObjectHelper
.
get
(
resultFrom
,
field
);
String
fieldTo
=
field
;
String
fieldTo
=
field
;
...
@@ -155,7 +155,7 @@ public class PrinterHelper {
...
@@ -155,7 +155,7 @@ public class PrinterHelper {
public
static
String
getResult
(
Object
resultFrom
,
String
format
)
{
public
static
String
getResult
(
Object
resultFrom
,
String
format
)
{
return
StringHelper
.
getFormat
(
format
,
StringHelper
.
EMPTY
,
new
StringFormatHandle
()
{
return
StringHelper
.
getFormat
(
format
,
StringHelper
.
EMPTY
,
new
StringFormatHandle
()
{
@Override
@Override
public
void
addPos
(
StringBuilder
sb
,
String
fieldFull
,
String
field
,
String
command
)
{
public
void
addPos
(
StringBuilder
sb
,
String
group
,
String
fieldFull
,
String
field
,
String
command
)
{
Object
fieldValue
=
ObjectHelper
.
get
(
resultFrom
,
field
);
Object
fieldValue
=
ObjectHelper
.
get
(
resultFrom
,
field
);
sb
.
append
(
fieldValue
);
sb
.
append
(
fieldValue
);
}
}
...
...
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