利用PageHelper进行后端分页

利用PageHelper进行后端分页,第1张

利用PageHelper进行后端分页

    @ApiOperation(value = "医疗地图医院列表",notes = "医疗地图医院列表")
    @PostMapping(value="/hospitalList")
    @JwtToken
    public RespResult<PageInfo<HospitalVo>> hospitalList(@RequestBody @Valid HospitalDto hospitalDto) {
        return new RespResult<>().ok(hospitalService.queryHospitalList(hospitalDto));
    }
    public PageInfo<HospitalVo> queryHospitalList(HospitalDto hospitalDto){
        PageHelper.startPage(Integer.parseInt(hospitalDto.getPageNum().toString()),Integer.parseInt(hospitalDto.getPageSize().toString()));
        List<HospitalVo> hospitalList = hospitalMapper.queryHospitalList(hospitalDto);
        PageInfo<HospitalVo> pagehospitalList = new PageInfo<HospitalVo>(hospitalList);
        return pagehospitalList;
    }
package com.applets.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value = "接口返回结果",description = "接口返回结果")
public class RespResult<T> {

    @ApiModelProperty(value = "返回状态:0成功,1失败,2token过期,3token非法,4非法用户")
    private int code;

    @ApiModelProperty(value = "返回信息")
    private String message;

    @ApiModelProperty(value = "返回结果数据")
    private T result;

    public RespResult(int code, String message, T result) {
        this.code = code;
        this.message = message;
        this.result = result;
    }

    public RespResult() {
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public  RespResult ok(){
        return new RespResult(RespStatus.SUCCESS.getCode(),RespStatus.SUCCESS.getDescribe(),null);
    }

    public  RespResult ok(T data){
        return new RespResult(RespStatus.SUCCESS.getCode(),RespStatus.SUCCESS.getDescribe(),data);
    }

    public  RespResult ok(String msg,T data){
        return new RespResult(RespStatus.SUCCESS.getCode(),msg,data);
    }

    public  RespResult fail(){
        return new RespResult(RespStatus.ERROR.getCode(),RespStatus.ERROR.getDescribe(),null);
    }

    public  RespResult fail(String msg){
        return new RespResult(RespStatus.ERROR.getCode(),msg,null);
    }

    public  RespResult fail(String msg,T data){
        return new RespResult(RespStatus.ERROR.getCode(),msg,data);
    }

    public  RespResult userInvalid(){
        return new RespResult(RespStatus.USER_INVALID.getCode(),RespStatus.USER_INVALID.getDescribe(),null);
    }

    public  RespResult userInvalid(String msg){
        return new RespResult(RespStatus.USER_INVALID.getCode(),msg,null);
    }

    public  RespResult tokenInvalid(){
        return new RespResult(RespStatus.TOKEN_INVALID.getCode(),RespStatus.TOKEN_INVALID.getDescribe(),null);
    }

    public  RespResult tokenInvalid(String msg){
        return new RespResult(RespStatus.TOKEN_INVALID.getCode(),msg,null);
    }

    public  RespResult tokenExpired(){
        return new RespResult(RespStatus.TOKEN_EXPIRED.getCode(),RespStatus.TOKEN_EXPIRED.getDescribe(),null);
    }

    public  RespResult tokenExpired(String msg){
        return new RespResult(RespStatus.TOKEN_EXPIRED.getCode(),msg,null);
    }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/729736.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存