mybatis xml 获取对象中另一个对象的参数
示例场景:分页查询
实体类
@Data
public class Player implements Serializable {
private Integer id;
private String name;
private Integer age;
private String phone;
private PageInfo page;
}
分页对象
public class PageInfo {
private int currentPage = 1;
private int pageSize = 10;
private int totalPage = 0;
private int totalCount = 0;
public PageInfo () {}
public PageInfo (int currentPage,int pageSize) {
this.currentPage = currentPage;
this.pageSize = pageSize;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
}
分页计算
<select id="selectPlayerList" parameterType="com.gooluke.biz.entity.Player" resultMap="BaseResultMap">
select * from t_player order by id
<if test="page != null">
limit ${(page.currentPage -1) * page.pageSize}, #{page.pageSize}
</if>
</select>