Commit 296225c3 authored by 耿迪迪's avatar 耿迪迪

分页框架自动生成工具修改 gengdidi

parent 29299ece
package com.zehong.common.utils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;
/**
* @description:github Pagehelper工具
* @Author:yuyufeng
* @Date:2019/7/22 10:38
*/
public class PageInfoUtil {
public static <P, D> PageInfo<D> pageInfo2PageInfoDTO(PageInfo<P> pageInfoPO, Class<D> dClass) {
Page<D> page = new Page<>(pageInfoPO.getPageNum(), pageInfoPO.getPageSize());
page.setTotal(pageInfoPO.getTotal());
for (P p : pageInfoPO.getList()) {
D d = null;
try {
d = dClass.newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
BeanUtils.copyProperties(p, d);
page.add(d);
}
return new PageInfo<>(page);
}
}
......@@ -37,6 +37,17 @@ public class ${ClassName}Controller extends BaseController
private I${ClassName}Service ${className}Service;
/**
* ${functionName}分页查询
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:pageList')")
@GetMapping("/pageList")
public TableDataInfo pageList(${ClassName} ${className}){
startPage();
PageInfo<${ClassName}> page = ${className}Service.select${ClassName}Page(${className});
return getDataTable(page);
}
/**
* 查询${functionName}列表
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
......
......@@ -27,6 +27,14 @@ public interface I${ClassName}Service
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 查询${functionName}分页列表
*
* @param ${className} ${functionName}
* @return ${functionName}分页集合
*/
public List<${ClassName}> select${ClassName}Page(${ClassName} ${className});
/**
* 新增${functionName}
*
......
......@@ -3,6 +3,7 @@ package ${packageName}.service.impl;
import java.util.List;
#foreach ($column in $columns)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import com.github.pagehelper.PageInfo;
import com.zehong.common.utils.DateUtils;
#break
#end
......@@ -55,6 +56,18 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
return ${className}Mapper.select${ClassName}List(${className});
}
/**
* 查询${functionName}分页列表
*
* @param ${className} ${functionName}
* @return ${functionName}
*/
@Override
public PageInfo<${ClassName}> select${ClassName}List(${ClassName} ${className})
{
return new PageInfo<>(${className}Mapper.select${ClassName}List(${className}));
}
/**
* 新增${functionName}
*
......
import request from '@/utils/request'
// 查询${functionName}列表
export function page${BusinessName}(query) {
return request({
url: '/${moduleName}/${businessName}/pageList',
method: 'get',
params: query
})
}
// 查询${functionName}列表
export function list${BusinessName}(query) {
return request({
......
......@@ -458,7 +458,7 @@ export default {
}
#end
#end
list${BusinessName}(this.queryParams).then(response => {
page${BusinessName}(this.queryParams).then(response => {
this.${businessName}List = response.rows;
this.total = response.total;
this.loading = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment