1.新建dto类
@Data
public class Entity implements Serializable {
private static final long serialVersionUID = 1L;
private String findDate;
private Integer virusCount;
}
2.dao
List<Entity> queryVirusPage(Page<Entity> page, Map<String, Object> params);
3.mapper.xml
<resultMap id="virusCountMap" type="com.guorui.modules.ext.dto.Entity">
<result property="findDate" column="find_date"/>
<result property="virusCount" column="virus_count"/>
</resultMap>
<select id="queryVirusPage" parameterType="map" resultMap="virusCountMap">
select DATE_FORMAT(find_time,'%Y-%m-%d') find_date,count(id) virus_count
from vir_virus_info as v
WHERE 1=1
group by find_date
order by find_date desc
</select>
4.Service类
List<Entity> queryVirusPage(Page<Entity> page, Map<String, Object> params);
5.ServiceImpl
public List<Entity> queryVirusPage(Page<Entity> page, Map<String, Object> params){
return baseMapper.queryVirusPage(page, params);
}
6.controller
public R selectCount(@RequestParam Map<String, Object> params) {
int current = TryParse.parseInt(params.get("page"));
int limit = TryParse.parseInt(params.get("limit"));
Page<Entity> page = new Page<Entity>(current, limit);
List<Entity> pageList = virusInfoService.queryVirusPage(page, params);
page.setRecords(pageList);
return R.ok().put("page", page);
}
标签:Map,分页,自定义,find,Page,开源,params,queryVirusPage,page
From: https://www.cnblogs.com/yangyezhuang/p/17255680.html