@Override
public Pagination findPagination(Map<String, Object> queryMap,
int currentPage, int pageSize)
{
UserMerchantCriteria userMerchantCriteria = new UserMerchantCriteria();
Criteria criteria = userMerchantCriteria.createCriteria();
// 设置搜索条件参数
if (queryMap != null)
{
if(queryMap.containsKey("merchantId"))
{
criteria.andMerchantIdEqualTo(Long.parseLong((String) queryMap.get("merchantId")));
}
else
{
// 如果未传入商家ID则停止查询,否则会查询到所有的餐厅(安全漏洞)
return new Pagination(pageSize, currentPage, 0, new ArrayList<UserMerchant>());
}
if (queryMap.containsKey("userName"))
{
User user = new User();
user.setUserName((String) queryMap.get("userName"));
user = userService.find(user);
if(user != null)
{
criteria.andUserIdEqualTo(user.getId());
}
}
}
// 设置分页参数
userMerchantCriteria.setPageSize(pageSize);