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
8e0dcf55
Commit
8e0dcf55
authored
Aug 04, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
默认日期格式的支持
parent
e4c2462e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
+32
-18
SqlCondUtil.java
...b/src/main/java/com/yanzuoguang/dao/impl/SqlCondUtil.java
+32
-18
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/SqlCondUtil.java
View file @
8e0dcf55
...
@@ -13,31 +13,34 @@ import java.util.Map;
...
@@ -13,31 +13,34 @@ import java.util.Map;
* @author 颜佐光
* @author 颜佐光
*/
*/
class
SqlCondUtil
{
class
SqlCondUtil
{
/**
* 代码片段等级
*/
public
static
final
int
COND_CODE
=
0
;
/**
/**
* 时间等级
* 时间等级
*/
*/
public
static
final
int
COND_DATE
=
0
;
public
static
final
int
COND_DATE
=
1
;
/**
/**
* ID等级
* ID等级
*/
*/
public
static
final
int
COND_ID
=
1
;
public
static
final
int
COND_ID
=
2
;
/**
/**
* 普通相等
* 普通相等
*/
*/
public
static
final
int
COND_COMMON
=
2
;
public
static
final
int
COND_COMMON
=
3
;
/**
/**
* 普通IN,NOT IN
* 普通IN,NOT IN
*/
*/
public
static
final
int
COND_IN
=
3
;
public
static
final
int
COND_IN
=
4
;
/**
/**
* Like条件
* Like条件
*/
*/
public
static
final
int
COND_LIKE
=
4
;
public
static
final
int
COND_LIKE
=
5
;
/**
/**
* 全文索引
* 全文索引
*/
*/
public
static
final
int
COND_MATCH
=
5
;
public
static
final
int
COND_MATCH
=
6
;
/**
/**
* 将SQL语句条件排序,符合索引
* 将SQL语句条件排序,符合索引
...
@@ -73,19 +76,25 @@ class SqlCondUtil {
...
@@ -73,19 +76,25 @@ class SqlCondUtil {
return
COND_COMMON
;
return
COND_COMMON
;
}
}
SqlCond
<?>
cond
=
field
.
getCond
();
SqlCond
<?>
cond
=
field
.
getCond
();
for
(
String
fieldName
:
cond
.
getFields
())
{
boolean
isWhere
=
false
;
fieldName
=
fieldName
.
toLowerCase
();
if
(
fieldName
.
indexOf
(
"date"
)
>
-
1
||
fieldName
.
indexOf
(
"time"
)
>
-
1
)
{
return
COND_DATE
;
}
else
if
(
fieldName
.
indexOf
(
"id"
)
>
-
1
)
{
return
COND_ID
;
}
}
int
len
=
field
.
getCodes
().
size
()
/
2
;
int
len
=
field
.
getCodes
().
size
()
/
2
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
String
codeName
=
field
.
getCodes
().
get
(
i
*
2
);
String
codeName
=
field
.
getCodes
().
get
(
i
*
2
)
.
toLowerCase
()
;
String
codeValue
=
field
.
getCodes
().
get
(
i
*
2
+
1
).
toLowerCase
();
String
codeValue
=
field
.
getCodes
().
get
(
i
*
2
+
1
).
toLowerCase
();
if
(
codeName
.
indexOf
(
"where"
)
<
0
)
{
continue
;
}
isWhere
=
true
;
for
(
String
fieldName
:
cond
.
getFields
())
{
fieldName
=
fieldName
.
toLowerCase
();
if
(
fieldName
.
indexOf
(
"date"
)
>
-
1
||
fieldName
.
indexOf
(
"time"
)
>
-
1
)
{
return
COND_DATE
;
}
else
if
(
fieldName
.
indexOf
(
"id"
)
>
-
1
)
{
return
COND_ID
;
}
}
if
(
codeValue
.
indexOf
(
"in"
)
>
-
1
)
{
if
(
codeValue
.
indexOf
(
"in"
)
>
-
1
)
{
return
COND_IN
;
return
COND_IN
;
}
else
if
(
codeValue
.
indexOf
(
"like"
)
>
-
1
)
{
}
else
if
(
codeValue
.
indexOf
(
"like"
)
>
-
1
)
{
...
@@ -95,6 +104,11 @@ class SqlCondUtil {
...
@@ -95,6 +104,11 @@ class SqlCondUtil {
}
}
}
}
return
COND_COMMON
;
if
(
isWhere
)
{
return
COND_COMMON
;
}
else
{
return
COND_CODE
;
}
}
}
}
}
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