排序
1
2
3
4
5
6
7
8
9
10
|
public
BlackListIP get(String ip){
BlackListIPExample example =
new
BlackListIPExample();
example.setOrderByClause(
"CREATE_TIME desc"
);
//按创建时间排序
example.createCriteria().andIpEqualTo(ip);
List<BlackListIP> blackListIPList = blackListipMapper.selectByExample(example);
if
(blackListIPList!=
null
&& blackListIPList.size()>
0
){
return
blackListIPList.get(
0
);
}
return
null
;
}
|
分页
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
public
PageInfo list(Account account, PageInfo pageInfo,String startTime,String endTime) {
account.setIsDel(SysParamDetailConstant.IS_DEL_FALSE);
AccountExample example = getCondition(account,startTime,endTime);
if
(
null
!= pageInfo &&
null
!= pageInfo.getPageStart()) {
example.setLimitClauseStart(pageInfo.getPageStart());
example.setLimitClauseCount(pageInfo.getPageCount());
}
example.setOrderByClause(
" CREATE_TIME desc "
);
List<Account> list = accountMapper.selectByExample(example);
int
totalCount = accountMapper.countByExample(example);
pageInfo.setList(list);
pageInfo.setTotalCount(totalCount);
return
pageInfo;
}
|
a=x and (b=xx or b=xxx)
1
2
3
4
5
|
AccountExample accountExample =
new
AccountExample();
AccountExample.Criteria criteria = accountExample.createCriteria().andTypeEqualTo(
"4"
);
criteria.addCriterion(String.format(
" (ID=%d or ID=%d) "
,
34
,
35
));
List<Account> accounts = accountMapper.selectByExample(accountExample);
return
accounts;
|
like 模糊查询
- TExample example = new TExample();
- TExample.Criteria criteria = example.createCriteria();
- if(StringUtils.isNotBlank(userName)){
- userName = "%" + userName + "%";
- }
- if(StringUtils.isNotBlank(userName)){
- criteria.andBuyerNameLike(userName);
- }
- dao.countByExample(example)