Pagination plug-in configuration
com.github.pagehelper
pagehelper
5.1.10
com.github.pagehelper
pagehelper-spring-boot-autoconfigure
1.2.10
Backend core code
1. The control layer Code
BusinessException exceptions are custom exception type
CommonResponseUtils, ConversionUtils is custom tools
The above code were not listed in this blog
* @Param commonRequest distal request
* @Return data returned to the front end
*/
@PostMapping(value = "/queryByCondition")
public CommonResponse> queryByCondition(@RequestBody CommonRequest commonRequest){
CommonRequestUtils.checkCommonRequest(commonRequest);
try {
OrganizationDTO dto = (OrganizationDTO) ConversionUtils.convertSimpleObject(commonRequest.getBody(),OrganizationDTO.class);
DtoPageInfo PageInfo = organizationService.queryByCondition (DBO);
List dtoList = dtoPageInfo.getList();
List vos = ConversionUtils.convertSimpleList(dtoList, OrganizationDataListVO.class);
PageInfo voPageInfo = (PageInfo) 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);
}
}
Entity class
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 {
/**
* institution name
*/
protected String name;
/**
* Agency Code
*/
protected String code;
/**
* principal
*/
protected String master;
/**
* Phone
*/
protected String tel;
/**
* Address
*/
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 {
/**
* institution name
*/
protected String name;
public OrganizationQueryConditionVO() {
}
}
2. The business layer codes
/**
*
* @param organizationDTO
* @return
* @throws ServiceException
*/
public PageInfo queryByCondition(OrganizationDTO organizationDTO) {
Condition condition = new Condition(Organization.class);
Example.Criteria criteria = condition.createCriteria();
if (!StringUtils.isEmpty(organizationDTO.getName())) {
criteria.andLike("name", organizationDTO.getName() + "%");
} Wuxi abortion costs http://www.xasgfk120.com/
condition.setOrderByClause("updated_time DESC");
PageHelper.startPage(organizationDTO.getPageNum(), organizationDTO.getPageSize());
List results = organizationDao.selectByExample(condition);
PageInfo organizationPageInfo = new PageInfo(results);
List dtos = null;
OrganizationDTO dto = null;
dtos = new ArrayList(results.size());
for (Organization result : results) {
dto = new OrganizationDTO();
BeanUtils.copyProperties (result, diol);
dtos.add(dto);
}
PageInfo organizationDtoPageInfo = new PageInfo();
BeanUtils.copyProperties (organizationPageInfo, organizationDtoPageInfo);
organizationDtoPageInfo.setList(dtos);
return organizationDtoPageInfo;
}
Entity class
OrganizationDTO
package com.bosssoft.bes.userpermission.pojo.dto;
import com.bosssoft.bes.userpermission.pojo.base.BaseDTO;
import java.util.List;
/**
* @author
* @date 2019-08-15 14:09
*/
public class OrganizationDTO extends BaseDTO {
/**
* Company list contained
*/
protected List companyDtoList;
/**
* institution name
*/
protected String name;
/**
* Agency Code
*/
protected String code;
/**
* principal
*/
protected String master;
/**
* Phone
*/
protected String tel;
/**
* Address
*/
protected String address;
public OrganizationDTO() {
}
}
Organization
package com.bosssoft.bes.userpermission.pojo.entity;
import com.bosssoft.bes.userpermission.pojo.base.BaseEntity;
import org.springframework.stereotype.Repository;
import javax.persistence.Table;
import java.io.Serializable;
/**
* @author
* @date 2019-08-15 10:49
*/
@Repository
@Table(name = "t_organization")
public class Organization extends BaseEntity implements Serializable {
//private static final long serialVersionUID = 1L;
/**
* institution name
*/
protected String name;
/**
* Agency Code
*/
protected String code;
/**
* principal
*/
protected String master;
/**
* Phone
*/
protected String tel;
/**
* Address
*/
protected String address;
public Organization() {
}
}
3. DAO layer
It refers to common mapper
The front end of the code
Import element pagination plug-in
handleSizeChange: When changing the amount of data displayed per page, the function is triggered, the page refresh and jump to the first page.
handleCurrentChange: Jump to page selected by the user
Inquire
increase
delete
modify
Yes
no
cancel
save
modify
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-size="currentPageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="recordNumber">