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
d3d0501b
Commit
d3d0501b
authored
Jun 14, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
压缩视频
parent
c203eb85
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
DaoConst.java
yzg-util-db/src/main/java/com/yanzuoguang/dao/DaoConst.java
+4
-0
TableStruct.java
...b/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
+13
-10
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/DaoConst.java
View file @
d3d0501b
...
@@ -144,6 +144,10 @@ public class DaoConst {
...
@@ -144,6 +144,10 @@ public class DaoConst {
* 等于条件
* 等于条件
*/
*/
public
static
final
String
CODE_WHERE_EQUALS
=
"AND %s%s=%s"
;
public
static
final
String
CODE_WHERE_EQUALS
=
"AND %s%s=%s"
;
/**
* In条件参数
*/
public
static
final
String
CODE_WHERE_IN
=
"AND %s%s IN (%s)"
;
/**
/**
* 等于条件参数
* 等于条件参数
*/
*/
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
View file @
d3d0501b
...
@@ -551,9 +551,15 @@ public class TableStruct {
...
@@ -551,9 +551,15 @@ public class TableStruct {
}
}
// 添加普通的Where条件
// 添加普通的Where条件
for
(
TableFieldVo
field
:
fields
)
{
for
(
TableFieldVo
field
:
fields
)
{
sql
.
add
(
field
.
inputName
,
// 添加等于条件
String
.
format
(
DaoConst
.
CODE_WHERE_EQUALS
,
tag
,
field
.
name
,
DaoConst
.
CODE_PARA
)
sql
.
add
(
field
.
inputName
,
String
.
format
(
DaoConst
.
CODE_WHERE_EQUALS
,
tag
,
field
.
name
,
DaoConst
.
CODE_PARA
));
);
// 添加in条件
String
sqlIn
=
String
.
format
(
DaoConst
.
CODE_WHERE_IN
,
tag
,
field
.
name
,
DaoConst
.
CODE_PARA
);
if
(
field
.
inputLName
.
endsWith
(
DaoConst
.
CODE_WHERE_IN_END
))
{
sql
.
add
(
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END_ES
,
sqlIn
);
}
else
{
sql
.
add
(
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END
,
sqlIn
);
}
}
}
// 查询时,不能查询到非删除的字段
// 查询时,不能查询到非删除的字段
addWhereRemove
(
sql
);
addWhereRemove
(
sql
);
...
@@ -597,8 +603,6 @@ public class TableStruct {
...
@@ -597,8 +603,6 @@ public class TableStruct {
* @return 生成的SQL语句
* @return 生成的SQL语句
*/
*/
private
SqlData
releaseSql
(
int
sqlType
,
String
name
,
String
model
,
String
valueModel
,
List
<
TableFieldVo
>
valueFields
,
List
<
TableFieldVo
>
whereFields
)
{
private
SqlData
releaseSql
(
int
sqlType
,
String
name
,
String
model
,
String
valueModel
,
List
<
TableFieldVo
>
valueFields
,
List
<
TableFieldVo
>
whereFields
)
{
// 参数字段
List
<
String
>
paraFields
=
new
ArrayList
<
String
>();
// 生成修改的SQL语句
// 生成修改的SQL语句
SqlData
sql
=
new
SqlData
(
name
,
model
.
replace
(
DaoConst
.
CODE_TABLE
,
this
.
name
));
SqlData
sql
=
new
SqlData
(
name
,
model
.
replace
(
DaoConst
.
CODE_TABLE
,
this
.
name
));
sql
.
setSqlType
(
sqlType
);
sql
.
setSqlType
(
sqlType
);
...
@@ -610,14 +614,13 @@ public class TableStruct {
...
@@ -610,14 +614,13 @@ public class TableStruct {
}
}
for
(
TableFieldVo
field
:
whereFields
)
{
for
(
TableFieldVo
field
:
whereFields
)
{
sql
.
addParaConst
(
field
.
inputName
,
DaoConst
.
CODE_WHERE
,
String
.
format
(
DaoConst
.
CODE_WHERE_EQUALS_PARA
,
field
.
name
));
sql
.
addConst
(
field
.
inputName
,
String
.
format
(
DaoConst
.
CODE_WHERE_EQUALS_PARA
,
field
.
name
));
// 添加in条件
// 添加in条件
if
(
field
.
inputLName
.
endsWith
(
DaoConst
.
CODE_WHERE_IN_END
))
{
if
(
field
.
inputLName
.
endsWith
(
DaoConst
.
CODE_WHERE_IN_END
))
{
sql
.
addParaConst
(
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END_ES
,
sql
.
add
(
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END_ES
,
String
.
format
(
DaoConst
.
CODE_WHERE_IN_PARA
,
field
.
name
));
DaoConst
.
CODE_WHERE
,
String
.
format
(
DaoConst
.
CODE_WHERE_IN_PARA
,
field
.
name
));
}
else
{
}
else
{
sql
.
addParaConst
(
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END
,
sql
.
add
(
field
.
inputName
+
DaoConst
.
CODE_WHERE_IN_END
,
String
.
format
(
DaoConst
.
CODE_WHERE_IN_PARA
,
field
.
name
));
DaoConst
.
CODE_WHERE
,
String
.
format
(
DaoConst
.
CODE_WHERE_IN_PARA
,
field
.
name
));
}
}
}
}
...
...
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