1:定义model
Model.java
public class Page {
private int page = 1;
private int count = 0;
private Map sorting = Maps.newHashMap();
}
2:定义mapper接口
Mapper.java
public interfaceMemberInfoMapper {
ListgetByOrgId(Page page);
}
3:编写mapper.xml
sql语句
select * from user_hospital uh
where 1 = 1
<choose>
<when test="sorting != null and sorting.size()>0 ">
<foreach item="orderDirection" index="orderField" collection="sorting" open="order by" separator="," close"">
${orderField} ${orderDirection}
</foreach>
<when>
<when test = "orderField != null and orderField != '' and orderDirection != null and orderDirection != ''">
order by ${orderField} ${orderDirection}
</when>
<otherwise>
order by last_time desc
</otherwise>
</choose>