Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mybatis-generator-plugin
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
mybatis-generator-plugin
Commits
5662c7f9
Commit
5662c7f9
authored
Jan 16, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版本说明
parent
7e403d1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
20 deletions
+49
-20
README.md
README.md
+49
-20
No files found.
README.md
View file @
5662c7f9
...
@@ -18,7 +18,7 @@ Maven引用:
...
@@ -18,7 +18,7 @@ Maven引用:
<dependency>
<dependency>
<groupId>
com.itfsw
</groupId>
<groupId>
com.itfsw
</groupId>
<artifactId>
mybatis-generator-plugin
</artifactId>
<artifactId>
mybatis-generator-plugin
</artifactId>
<version>
1.0.
3
</version>
<version>
1.0.
4
</version>
</dependency>
</dependency>
```
```
---------------------------------------
---------------------------------------
...
@@ -124,6 +124,19 @@ public class TbExample {
...
@@ -124,6 +124,19 @@ public class TbExample {
offset
=
null
;
offset
=
null
;
}
}
}
}
public
class
Test
{
public
static
void
main
(
String
[]
args
)
{
this
.
tbMapper
.
selectByExample
(
new
TbExample
()
.
createCriteria
()
.
andField1GreaterThan
(
1
)
.
example
()
.
limit
(
10
)
// 查询前10条
.
limit
(
10
,
10
)
// 查询10~20条
.
page
(
1
,
10
)
// 查询第2页数据(每页10条)
);
}
}
```
```
### 3. 数据Model链式构建插件
### 3. 数据Model链式构建插件
这个是仿jquery的链式调用强化了表的Model的赋值操作
这个是仿jquery的链式调用强化了表的Model的赋值操作
...
@@ -184,26 +197,42 @@ public class Test {
...
@@ -184,26 +197,42 @@ public class Test {
this
.
tbMapper
.
selectByExample
(
oldEx
);
this
.
tbMapper
.
selectByExample
(
oldEx
);
// new
// new
TbExample
newEx
;
this
.
tbMapper
.
selectByExample
(
newEx
=
new
TbExample
()
new
TbExample
()
.
createCriteria
()
.
andField1EqualTo
(
1
)
.
andField2EqualTo
(
"xxx"
)
// 如果随机数大于0.5,附加Field3查询条件
.
andIf
(
Math
.
random
()
>
0.5
,
new
TbExample
.
Criteria
.
ICriteriaAdd
()
{
@Override
public
TbExample
.
Criteria
add
(
TbExample
.
Criteria
add
)
{
return
add
.
andField3EqualTo
(
2
)
.
andField4EqualTo
(
new
Date
());
}
})
// 当然最简洁的写法是采用java8的Lambda表达式,当然你的项目是Java8+
.
andIf
(
Math
.
random
()
>
0.5
,
add
->
add
.
andField3EqualTo
(
2
)
.
andField4EqualTo
(
new
Date
())
)
.
example
()
);
// -----------------------------------orderBy-----------------------------------
// old
TbExample
ex
=
new
TbExample
();
ex
.
createCriteria
().
andField1GreaterThan
(
1
);
ex
.
setOrderByClause
(
"field1 DESC"
);
this
.
tbMapper
.
selectByExample
(
ex
);
// new
this
.
tbMapper
.
selectByExample
(
new
TbExample
()
.
createCriteria
()
.
createCriteria
()
.
andField1EqualTo
(
1
)
.
andField1GreaterThan
(
1
)
.
andField2EqualTo
(
"xxx"
)
.
example
()
// 如果随机数大于0.5,附加Field3查询条件
.
orderBy
(
"field1 DESC"
)
.
andIf
(
Math
.
random
()
>
0.5
,
new
TbExample
.
Criteria
.
CriteriaAdd
()
{
);
@Override
public
TbExample
.
Criteria
add
(
TbExample
.
Criteria
add
)
{
return
add
.
andField3EqualTo
(
2
)
.
andField4EqualTo
(
new
Date
());
}
})
// 当然最简洁的写法是采用java8的Lambda表达式,当然你的项目是Java8+
.
andIf
(
Math
.
random
()
>
0.5
,
add
->
add
.
andField3EqualTo
(
2
)
.
andField4EqualTo
(
new
Date
())
)
.
example
();
this
.
tbMapper
.
selectByExample
(
newEx
);
}
}
}
}
```
```
...
...
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