1.定义实体类
@TableName("role")
@Data
public class Role {
@TableId
private String id;
private String name;
}
2.定义mapper接口
public interface RoleMapper extends BaseMapper<Role> {
//xml分页
IPage<Role> getRolePage(IPage<Role> page);
//xml分页带条件
IPage<Role> getRolePageByCondition(IPage<Role> page, @Param("query")Role query);
}
3.编写XML
<select id="getRolePage" resultType="com.hj.entity.Role">
select * from role
</select>
<select id="getRolePageByCondition" resultType="com.hj.entity.Role">
select * from role
<where>
<if test="query.id != '' and query.id != null">
id = #{query.id}
</if>
<if test="query.name != '' and query.name != null">
or name = #{query.name}
</if>
</where>
</select>
标签:xml,name,自定义,role,IPage,Mybatis,query,id
From: https://www.cnblogs.com/marchxd/p/16791012.html