JavaBean
@Data
public class PointVO extends Page implements Serializable {}
controller
@GetMapping("/page")
public Result<?> page(@RequestBody PointVO pointVO) {
return ResultBuilder.success(pointService.pointPage(pointVO), "查询成功");
}
Service
public interface PointService extends IService<Point> {
Page<PointVO> pointPage(PointVO pointVO);
}
ServiceImpl
@Service
@Transactional(rollbackFor = Exception.class)
@Slf4j
public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements PointService {
@Resource
private PointMapper pointMapper;
@Override
public Page<PointVO> pointPage(PointVO pointVO) {
Page<PointVO> point=new Page<>();
point.setSize(pointVO.getSize());
point.setTotal(pointVO.getTotal());
point.setCurrent(pointVO.getCurrent());
return pointMapper.pointPage(point,pointVO);
}
}
}
Mapper
public interface PointMapper extends BaseMapper<Point> {
/**
* 分页
* @param page
* @param
* @return
*/
Page<PointVO> pointPage(@Param("page") IPage<PointVO> page,
@Param("query") PointVO PointVO);
}
XML
<mapper namespace="com.aspire.sc.center.mapper.PointMapper">
<select id="pointPage" resultType="com.aspire.sc.center.pojo.PointVO">
select t.*,m.`name`,COUNT(id) checkall,COUNT( distinct user_id) userall from point t left join
`mode` m on
t.mode_code=m.`code`
<if test="query.intimestart !=null and query.intimestart != ''">
and t.intime >=#{query.intimestart}
</if>
<if test="query.intimeend !=null and query.intimeend != ''">
and t.intime <=#{query.intimeend}
</if>
where 1=1
<if test="query.school !=null and query.school != ''">
and t.school like '%${query.school}%'
</if>
<if test="query.addres !=null and query.addres != ''">
and t.addres like '%${query.addres}%'
</if>
<if test="query.district !=null and query.district != ''">
and t.district like '%${query.district}%'
</if>
<if test="query.EC !=null and query.EC != ''">
and t.EC like '%${query.EC}%'
</if>
<if test="query.agent !=null and query.agent != ''">
and t.agent like '%${query.agent}%'
</if>
<if test="query.user_id !=null and query.user_id != ''">
and t.user_id like '%${query.user_id}%'
</if>
GROUP BY mode_code
</select>
</mapper>