您好,登錄后才能下訂單哦!
分頁插件的配置
com.github.pagehelper
pagehelper
5.1.10
com.github.pagehelper
pagehelper-spring-boot-autoconfigure
1.2.10
后端中的核心代碼
1. 控制層代碼
BusinessException異常是自定義的異常類型
CommonResponseUtils、ConversionUtils是自定義的工具類
以上代碼在本博客均未列出
* @param commonRequest 前端請求
* @return 返回給前端的數(shù)據(jù)
*/
@PostMapping(value = "/queryByCondition")
public CommonResponse> queryByCondition(@RequestBody CommonRequest commonRequest){
CommonRequestUtils.checkCommonRequest(commonRequest);
try {
OrganizationDTO dto = (OrganizationDTO) ConversionUtils.convertSimpleObject(commonRequest.getBody(),OrganizationDTO.class);
PageInfo dtoPageInfo = organizationService.queryByCondition(dto);
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);
}
}
實體類
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 {
/**
* 機構(gòu)名稱
*/
protected String name;
/**
* 機構(gòu)代碼
*/
protected String code;
/**
* 負(fù)責(zé)人
*/
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 {
/**
* 機構(gòu)名稱
*/
protected String name;
public OrganizationQueryConditionVO() {
}
}
2. 業(yè)務(wù)層代碼
/**
*
* @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() + "%");
}無錫人流費用 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, dto);
dtos.add(dto);
}
PageInfo organizationDtoPageInfo = new PageInfo();
BeanUtils.copyProperties(organizationPageInfo, organizationDtoPageInfo);
organizationDtoPageInfo.setList(dtos);
return organizationDtoPageInfo;
}
實體類
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 {
/**
* 所含公司列表
*/
protected List companyDtoList;
/**
* 機構(gòu)名稱
*/
protected String name;
/**
* 機構(gòu)代碼
*/
protected String code;
/**
* 負(fù)責(zé)人
*/
protected String master;
/**
* 電話
*/
protected String tel;
/**
* 地址
*/
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;
/**
* 機構(gòu)名稱
*/
protected String name;
/**
* 機構(gòu)代碼
*/
protected String code;
/**
* 負(fù)責(zé)人
*/
protected String master;
/**
* 電話
*/
protected String tel;
/**
* 地址
*/
protected String address;
public Organization() {
}
}
3. DAO層
引用了通用mapper
前端中的代碼
導(dǎo)入element分頁插件
handleSizeChange:當(dāng)改變每頁顯示的數(shù)據(jù)量時,觸發(fā)該函數(shù),頁面刷新,并跳轉(zhuǎn)到第一頁。
handleCurrentChange:跳轉(zhuǎn)到用戶所選擇的頁面
查詢
增加
刪除
修改
是
否
取 消
保 存
修 改
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-size="currentPageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="recordNumber">
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。