master
周文涛 2 years ago
parent 18828f7d2e
commit b3ee832037

@ -63,8 +63,8 @@ public class ${entityName}Controller extends BaseController {
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
startPage();
List<${entityName}> list = ${entityName?uncap_first}Service.list();
return getDataTable(list);
TableDataInfo tableDataInfo = ${entityName?uncap_first}Service.pageList(query${entityName}VO);
return tableDataInfo;
}
/**

@ -1,6 +1,11 @@
package ${bussiPackage}.service;
import com.enjoy.common.core.web.page.TableDataInfo;
import ${bussiPackage}.dto.${entityName}DTO;
import ${bussiPackage}.vo.Query${entityName}VO;
import ${bussiPackage}.${entityPackage}.${entityName};
import com.baomidou.mybatisplus.extension.service.IService;
/**
@ -10,5 +15,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @Version: V1.0
*/
public interface I${entityName}Service extends IService<${entityName}> {
/**
* 自定义分页
*/
public TableDataInfo pageList(Query${entityName}VO query${entityName}VO);
}

@ -1,11 +1,28 @@
package ${bussiPackage}.service.impl;
import com.enjoy.oqc.utils.BeanHkUtils;
import com.enjoy.common.core.i18n.InternationalizationService;
import com.enjoy.common.core.constant.Constants;
import com.enjoy.common.core.constant.HttpStatus;
import com.enjoy.common.core.web.page.TableDataInfo;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import ${bussiPackage}.${entityPackage}.${entityName};
import ${bussiPackage}.dto.${entityName}DTO;
import ${bussiPackage}.vo.Query${entityName}VO;
import ${bussiPackage}.mapper.${entityName}Mapper;
import ${bussiPackage}.service.I${entityName}Service;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: ${tableVo.ftlDescription}
@ -14,6 +31,39 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
* @Version: V1.0
*/
@Service
@Slf4j
public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
@Resource
private InternationalizationService internationalizationService;
/**
* 自定义分页
*/
public TableDataInfo pageList(Query${entityName}VO query${entityName}VO){
TableDataInfo rspData=new TableDataInfo();
try{
List<${entityName}DTO> list=new ArrayList();
QueryWrapper<${entityName}> queryWrapper=new QueryWrapper();
<#list originalColumns as po>
<#if po.fieldColumn == 'create_time'>
queryWrapper.orderByDesc("create_time");
<#else>
</#if>
</#list>
List<${entityName}> dbEntityList = this.list(queryWrapper);
if(dbEntityList!=null &&dbEntityList.size()>0){
dbEntityList.stream().forEach(entity->{
${entityName}DTO ${uncap_first}DTO=new ${entityName}DTO();
BeanHkUtils.copyProperties(entity,${uncap_first}DTO);
list.add(${uncap_first}DTO);
});
}
rspData.setCode(HttpStatus.SUCCESS);
rspData.setRows(list);
rspData.setMsg(internationalizationService.getMessage(Constants.QUERY_SUCCESS));
rspData.setTotal(new PageInfo(list).getTotal());
}catch(Exception e){
log.error("获取 分页异常:",e);
}
return rspData;
}
}

Loading…
Cancel
Save