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>