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; /** * @Description: ${tableVo.ftlDescription} * @Author: ${author} * @Date: ${.now?string["yyyy-MM-dd"]} * @Version: V1.0 */ @Service @Slf4j public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service { @Resource private InternationalizationService internationalizationService; /** * 自定义分页 */ @Override 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> 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; } }