配置文件
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
<!--mybaits分页插件-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>
import lombok.Data;
import java.io.Serializable;
@Data
public class Query implements Serializable {
private static final long serialVersionUID = 8933019121780323520L;
/**
* 当前页
*/
private int pageNum = 1;
/**
* 每页的数量
*/
private int pageSize = 20;
}
@Data
@ApiModel(value = "更多查询入参")
public class AmsNewsMoreDto extends Query {
@ApiModelProperty(value = "组织id")
private String orgId;
@ApiModelProperty(value = "类型type 0:pc端,1:app端,2小程序端")
private Byte type;
@ApiModelProperty(value = "是否置顶")
private String isTop;
@ApiModelProperty(value = "公告类型id")
private String typeId;
}
public PageInfo<AmsNewMoreVo> selectHomeNewsMore(String token, AmsNewsMoreDto amsNewsMoreDto) {
PageHelper.startPage(amsNewsMoreDto.getPageNum(), amsNewsMoreDto.getPageSize());
List<AmsNewMoreVo> lsit = amsDetailMapper.selectNewsMoreList(amsNewsMoreDto);
PageInfo<AmsNewMoreVo> pageInfo = new PageInfo<AmsNewMoreVo>(lsit);
return pageInfo;
}
@RestController
@RequestMapping("/home")
@Api(tags = "公告首页")
public class AmsHomeController {
@Autowired
private AmsHomeService amsHomeService;
@ApiOperation("公告更多")
@PostMapping("/selectHomeNewsMore")
public Wrapper<PageInfo<AmsNewMoreVo>> selectHomeNewsMore(@ApiParam(value = "请求token", required = true) @RequestHeader("token") String token,
@RequestBody AmsNewsMoreDto amsNewsMoreDto) {
PageInfo<AmsNewMoreVo> list = amsHomeService.selectHomeNewsMore(token, amsNewsMoreDto);
return WrapMapper.ok(list);
}
}