update docs

This commit is contained in:
开源海哥 2023-04-02 16:11:18 +08:00
parent d15fdf98e8
commit 877d3b8058
3 changed files with 18 additions and 30 deletions

View File

@ -67,14 +67,14 @@ public class HelloWorld {
.addMapper(AccountMapper.class)
.start();
//获取 mapper
AccountMapper mapper = MybatisFlexBootstrap.getInstance()
.getMapper(AccountMapper.class);
//示例1查询 id=1 条数据
Account account = MybatisFlexBootstrap.getInstance()
.execute(AccountMapper.class, mapper ->
mapper.selectOneById(1)
);
//示例1查询 id=1 的数据
Account account = mapper.selectOneById(1);
//示例2者使用 Db + Row 查询
//示例2者使用 Db + Row 查询
String sql = "select * from tb_account where age > ?";
List<Row> rows = Db.selectListBySql(sql, 18);
}

View File

@ -57,12 +57,12 @@ class HelloWorld {
.addMapper(AccountMapper.class)
.start();
AccountMapper mapper = MybatisFlexBootstrap.getInstance()
.getMapper(AccountMapper.class);
//id=100
Account account = MybatisFlexBootstrap.getInstance()
.execute(AccountMapper.class, mapper ->
mapper.selectOneById(100)
);
Account account = mapper.selectOneById(100);
}
}
```
@ -81,10 +81,7 @@ QueryWrapper query = QueryWrapper.create()
// ELECT * FROM tb_account
// WHERE tb_account.id >= 100
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
List<Account> accounts = MybatisFlexBootstrap.getInstance()
.execute(AccountMapper.class, mapper ->
mapper.selectListByQuery(query)
);
List<Account> accounts = mapper.selectListByQuery(query);
```
e.g.3: paging query
@ -104,10 +101,7 @@ QueryWrapper query = QueryWrapper.create()
// AND (tb_account.user_name LIKE '%zhang%' OR tb_account.user_name LIKE '%li%' )
// ORDER BY tb_account.id DESC
// LIMIT 40,10
Page<Account> accountPage = MybatisFlexBootstrap.getInstance()
.execute(AccountMapper.class, mapper ->
mapper.paginate(5, 10, query)
);
Page<Account> accountPage = mapper.paginate(5, 10, query);
```
## QueryWrapper Samples

View File

@ -70,12 +70,12 @@ class HelloWorld {
.addMapper(AccountMapper.class)
.start();
AccountMapper mapper = MybatisFlexBootstrap.getInstance()
.getMapper(AccountMapper.class);
//示例1查询 id=100 条数据
Account account = MybatisFlexBootstrap.getInstance()
.execute(AccountMapper.class, mapper ->
mapper.selectOneById(100)
);
Account account = mapper.selectOneById(100);
}
}
```
@ -96,10 +96,7 @@ QueryWrapper query=QueryWrapper.create()
// ELECT * FROM tb_account
// WHERE tb_account.id >= 100
// AND (tb_account.user_name LIKE '%张%' OR tb_account.user_name LIKE '%李%' )
List<Account> accounts = MybatisFlexBootstrap.getInstance()
.execute(AccountMapper.class,mapper->
mapper.selectListByQuery(query)
);
List<Account> accounts = mapper.selectListByQuery(query);
```
示例3分页查询
@ -120,10 +117,7 @@ QueryWrapper query=QueryWrapper.create()
// AND (user_name LIKE '%张%' OR user_name LIKE '%李%' )
// ORDER BY `id` DESC
// LIMIT 40,10
Page<Account> accounts = MybatisFlexBootstrap.getInstance()
.execute(AccountMapper.class,mapper->
mapper.paginate(5,10,query)
);
Page<Account> accounts = mapper.paginate(5,10,query);
```
## QueryWrapper 示例