这个是service
/**
* 返回记录数
* @return
*/
public Integer getPageTotal(Integer userid);
//service的实现类
public Integer getPageTotal(Integer userid) {
return newsMessageMapper.getPageTotal(userid);
}
/** mapper
* 返回记录数
* @return
*/
public Integer getPageTotal(@Param("userid")Integer userid);
//mapperxml文件
<select id="getPageTotal" resultType="int">
select count(*) from news n
where n.userID=#{userid}
</select>
到此查询总记录数的方法已经写完,下面的分页查询的方法
/** 分页查询的service
* 消息列表
* @return
*/
public List<News> showNewsList(Integer userid,Integer rows,Integer page);
//serviceimpl的实现类
public List<News> showNewsList(Integer userid,Integer rows, Integer page) {
return newsMessageMapper.showNewsList(userid,rows,page);
}
/** 分页查询的mapper
* 消息列表
* @return
*/
public List<News> showNewsList(@Param("userid")Integer userid,@Param("rows")Integer rows, @Param("page")Integer page);
//mapperxml
<select id="showNewsList" resultType="com.yituo.noopsyche.model.News">
select
n.id as id,
n.headline as headline,
n.content as content,
u.staffName as staffName,
d.name as name,
nt.messageTypeName as messageTypeName,
n.publishTime as publishTime,
n.filepath as filepath
from news n
left join newsType nt on n.newTypeID=nt.id
left join dept d on d.ID=n.deptID
left join users u on u.ID=n.userID
where u.ID=#{userid}
ORDER BY n.publishtime desc
LIMIT #{page},#{rows}
</select>
在前台的js文件中,进行columns中的field必须要后台返回的属性对应,否则无法进行显示