当前位置 主页 > 网站技术 > 代码类 >

    Vue分页插件的前后端配置与使用

    栏目:代码类 时间:2019-10-20 09:03

    本文实例为大家分享了Vue分页插件的前后端配置与使用,供大家参考,具体内容如下

    分页插件的配置

    <dependency>
     <groupId>com.github.pagehelper</groupId>
     <artifactId>pagehelper</artifactId>
     <version>5.1.10</version>
    </dependency>
    <dependency>
     <groupId>com.github.pagehelper</groupId>
     <artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
     <version>1.2.10</version>
    </dependency>

    后端中的核心代码

    1. 控制层代码

    BusinessException异常是自定义的异常类型
    CommonResponseUtils、ConversionUtils是自定义的工具类

    以上代码在本博客均未列出

    * @param commonRequest 前端请求
     * @return 返回给前端的数据
     */
    @PostMapping(value = "/queryByCondition")
    public CommonResponse<PageInfo<OrganizationDataListVO>> queryByCondition(@RequestBody CommonRequest<OrganizationQueryConditionVO> commonRequest){
     CommonRequestUtils.checkCommonRequest(commonRequest);
     try {
     OrganizationDTO dto = (OrganizationDTO) ConversionUtils.convertSimpleObject(commonRequest.getBody(),OrganizationDTO.class);
     PageInfo<OrganizationDTO> dtoPageInfo = organizationService.queryByCondition(dto);
     List<OrganizationDTO> dtoList = dtoPageInfo.getList();
     List<OrganizationDataListVO> vos = ConversionUtils.convertSimpleList(dtoList, OrganizationDataListVO.class);
     PageInfo<OrganizationDataListVO> voPageInfo = (PageInfo<OrganizationDataListVO>) ConversionUtils.convertSimpleObject(dtoPageInfo, PageInfo.class);
     voPageInfo.setList(vos);
     return CommonResponseUtils.makeSuccessCommonResponse(voPageInfo, "0", null, null, null);
     } catch (ServiceException exception) {
     throw new BusinessException(exception);
     } catch (IllegalAccessException | InstantiationException e) {
     throw new BusinessException(SystemExceptionEnum.SYSTEM_ERROR);
     }
    }

    实体类

    OrganizationDataListVO

    package com.bosssoft.bes.userpermission.pojo.vo;
    
    import com.bosssoft.bes.userpermission.pojo.base.DataListVO;
    
    import java.io.Serializable;
    
    /**
     * @author 
     * @date 2019-08-25 18:43
     */
    public class OrganizationDataListVO extends DataListVO implements Serializable {
    
     /**
     * 机构名称
     */
     protected String name;
    
     /**
     * 机构代码
     */
     protected String code;
    
     /**
     * 负责人
     */
     protected String master;
    
     /**
     * 电话
     */
     protected String tel;
    
     /**
     * 地址
     */
     protected String address;
    
     public OrganizationDataListVO() {
     }
    
    }

    OrganizationQueryConditionVO

    package com.bosssoft.bes.userpermission.pojo.vo;
    
    import com.bosssoft.bes.userpermission.pojo.base.QueryConditionVO;
    
    import java.io.Serializable;
    
    /**
     * @author 
     * @date 2019-08-15 14:05
    
     */
    public class OrganizationQueryConditionVO extends QueryConditionVO implements Serializable {
    
     /**
     * 机构名称
     */
     protected String name;
    
     public OrganizationQueryConditionVO() {
     }
    
     
    }