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
8bcae95e
Commit
8bcae95e
authored
Aug 11, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
默认日期格式的支持
parent
36fdb25b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
13 deletions
+28
-13
SqlCondDefault.java
...rc/main/java/com/yanzuoguang/dao/cond/SqlCondDefault.java
+1
-1
SqlData.java
...il-db/src/main/java/com/yanzuoguang/dao/impl/SqlData.java
+4
-4
TableStruct.java
...b/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
+23
-8
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/cond/SqlCondDefault.java
View file @
8bcae95e
...
@@ -18,7 +18,7 @@ public class SqlCondDefault extends SqlCondBase<SqlCondDefault> {
...
@@ -18,7 +18,7 @@ public class SqlCondDefault extends SqlCondBase<SqlCondDefault> {
this
(
Arrays
.
asList
(
field
));
this
(
Arrays
.
asList
(
field
));
}
}
p
rotected
SqlCondDefault
(
List
<
String
>
fields
)
{
p
ublic
SqlCondDefault
(
List
<
String
>
fields
)
{
super
(
fields
);
super
(
fields
);
}
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/SqlData.java
View file @
8bcae95e
...
@@ -169,8 +169,8 @@ public class SqlData {
...
@@ -169,8 +169,8 @@ public class SqlData {
* @param tag 标签
* @param tag 标签
* @return
* @return
*/
*/
public
SqlData
add
(
Class
<?>
clsModel
,
String
tag
)
{
public
SqlData
add
(
Class
<?>
clsModel
,
String
tag
,
String
...
codes
)
{
return
this
.
add
(
clsModel
,
tag
,
false
);
return
this
.
add
(
clsModel
,
tag
,
false
,
codes
);
}
}
/**
/**
...
@@ -180,10 +180,10 @@ public class SqlData {
...
@@ -180,10 +180,10 @@ public class SqlData {
* @param tag 标签
* @param tag 标签
* @return
* @return
*/
*/
public
SqlData
add
(
Class
<?>
clsModel
,
String
tag
,
boolean
removeFlag
)
{
public
SqlData
add
(
Class
<?>
clsModel
,
String
tag
,
boolean
removeFlag
,
String
...
codes
)
{
// 生成表结构
// 生成表结构
TableStruct
table
=
new
TableStruct
(
StringHelper
.
EMPTY
,
clsModel
);
TableStruct
table
=
new
TableStruct
(
StringHelper
.
EMPTY
,
clsModel
);
table
.
addWhereExtend
(
this
,
tag
,
removeFlag
);
table
.
addWhereExtend
(
this
,
tag
,
removeFlag
,
codes
);
return
this
;
return
this
;
}
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
View file @
8bcae95e
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.dao.impl;
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.dao.impl;
import
com.yanzuoguang.dao.DaoConst
;
import
com.yanzuoguang.dao.DaoConst
;
import
com.yanzuoguang.dao.TableAnnotation
;
import
com.yanzuoguang.dao.TableAnnotation
;
import
com.yanzuoguang.dao.cond.SqlCondDefault
;
import
com.yanzuoguang.util.base.MethodField
;
import
com.yanzuoguang.util.base.MethodField
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.base.ObjectHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
...
@@ -18,6 +19,9 @@ import java.util.Map;
...
@@ -18,6 +19,9 @@ import java.util.Map;
*/
*/
public
class
TableStruct
{
public
class
TableStruct
{
private
static
final
int
WHERE_ADD
=
1
;
private
static
final
int
WHERE_REMOVE_ADD
=
2
;
private
static
final
int
WHERE_ADD_NOT
=
0
;
/**
/**
* 数据库中的表名称
* 数据库中的表名称
*/
*/
...
@@ -568,11 +572,11 @@ public class TableStruct {
...
@@ -568,11 +572,11 @@ public class TableStruct {
* @param sql 需要扩展的SQL语句
* @param sql 需要扩展的SQL语句
* @param tag 扩展标签
* @param tag 扩展标签
*/
*/
public
void
addWhereExtend
(
SqlData
sql
,
String
tag
,
boolean
removeHistory
)
{
public
void
addWhereExtend
(
SqlData
sql
,
String
tag
,
boolean
removeHistory
,
String
...
codes
)
{
addWhereBase
(
sql
,
tag
,
false
,
removeHistory
);
addWhereBase
(
sql
,
tag
,
false
,
removeHistory
,
codes
);
}
}
private
void
addWhereBase
(
SqlData
sql
,
String
tag
,
boolean
isRemove
,
boolean
removeHistory
)
{
private
void
addWhereBase
(
SqlData
sql
,
String
tag
,
boolean
isRemove
,
boolean
removeHistory
,
String
...
codes
)
{
addWhereFieldCommon
(
sql
,
this
.
getKey
(),
tag
,
removeHistory
);
addWhereFieldCommon
(
sql
,
this
.
getKey
(),
tag
,
removeHistory
);
// Where条件包含的字段
// Where条件包含的字段
...
@@ -584,34 +588,45 @@ public class TableStruct {
...
@@ -584,34 +588,45 @@ public class TableStruct {
// 非删除时需要更新的字段
// 非删除时需要更新的字段
fields
=
this
.
getFieldActionList
(
DaoConst
.
FIELD_COMMON
,
DaoConst
.
FIELD_REMOVE_UPDATE
);
fields
=
this
.
getFieldActionList
(
DaoConst
.
FIELD_COMMON
,
DaoConst
.
FIELD_REMOVE_UPDATE
);
}
}
List
<
String
>
codesField
=
new
ArrayList
<>();
// 添加普通的Where条件
// 添加普通的Where条件
for
(
TableFieldVo
field
:
fields
)
{
for
(
TableFieldVo
field
:
fields
)
{
addWhereFieldCommon
(
sql
,
field
,
tag
,
removeHistory
);
int
isAdd
=
addWhereFieldCommon
(
sql
,
field
,
tag
,
removeHistory
);
if
(
isAdd
!=
WHERE_ADD_NOT
)
{
codesField
.
add
(
field
.
inputName
);
}
}
if
(!
codesField
.
isEmpty
())
{
sql
.
addPara
(
new
SqlCondDefault
(
codesField
),
codes
);
}
}
}
}
private
void
addWhereFieldCommon
(
SqlData
sql
,
TableFieldVo
field
,
String
tag
,
boolean
removeHistory
)
{
private
int
addWhereFieldCommon
(
SqlData
sql
,
TableFieldVo
field
,
String
tag
,
boolean
removeHistory
)
{
addWhereFieldNotExtend
(
sql
,
field
.
inputName
,
String
.
format
(
DaoConst
.
CODE_WHERE_EQUALS
,
tag
,
field
.
name
,
DaoConst
.
CODE_PARA
),
removeHistory
);
addWhereFieldNotExtend
(
sql
,
field
.
inputName
,
String
.
format
(
DaoConst
.
CODE_WHERE_EQUALS
,
tag
,
field
.
name
,
DaoConst
.
CODE_PARA
),
removeHistory
);
// 添加in条件
// 添加in条件
String
sqlIn
=
String
.
format
(
DaoConst
.
CODE_WHERE_IN
,
tag
,
field
.
name
,
DaoConst
.
CODE_PARA
);
String
sqlIn
=
String
.
format
(
DaoConst
.
CODE_WHERE_IN
,
tag
,
field
.
name
,
DaoConst
.
CODE_PARA
);
if
(
field
.
inputLName
.
endsWith
(
DaoConst
.
CODE_WHERE_IN_END
))
{
if
(
field
.
inputLName
.
endsWith
(
DaoConst
.
CODE_WHERE_IN_END
))
{
addWhereFieldNotExtend
(
sql
,
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END_ES
,
sqlIn
,
removeHistory
);
return
addWhereFieldNotExtend
(
sql
,
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END_ES
,
sqlIn
,
removeHistory
);
}
else
{
}
else
{
addWhereFieldNotExtend
(
sql
,
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END
,
sqlIn
,
removeHistory
);
return
addWhereFieldNotExtend
(
sql
,
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END
,
sqlIn
,
removeHistory
);
}
}
}
}
private
void
addWhereFieldNotExtend
(
SqlData
sql
,
String
inputName
,
String
sqlWhere
,
boolean
removeHistory
)
{
private
int
addWhereFieldNotExtend
(
SqlData
sql
,
String
inputName
,
String
sqlWhere
,
boolean
removeHistory
)
{
SqlDataField
field
=
sql
.
getField
(
inputName
);
SqlDataField
field
=
sql
.
getField
(
inputName
);
if
(
field
==
null
)
{
if
(
field
==
null
)
{
// 添加新的条件
// 添加新的条件
sql
.
add
(
inputName
,
sqlWhere
);
sql
.
add
(
inputName
,
sqlWhere
);
return
WHERE_ADD
;
}
else
if
(
field
!=
null
&&
removeHistory
)
{
}
else
if
(
field
!=
null
&&
removeHistory
)
{
// 删除历史条件
// 删除历史条件
sql
.
removeField
(
inputName
);
sql
.
removeField
(
inputName
);
// 添加新的条件
// 添加新的条件
sql
.
add
(
inputName
,
sqlWhere
);
sql
.
add
(
inputName
,
sqlWhere
);
return
WHERE_REMOVE_ADD
;
}
}
return
WHERE_ADD_NOT
;
}
}
/**
/**
...
...
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