| | |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.ruoyi.common.utils.PageUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import ${packageName}.vo.${ClassName}Vo; |
| | | import ${packageName}.service.I${ClassName}Service; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * ${functionName}Service业务层处理 |
| | |
| | | @Override |
| | | public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){ |
| | | ${ClassName} db = this.baseMapper.selectById(${pkColumn.javaField}); |
| | | return BeanUtil.toBean(db, ${ClassName}Vo.class) |
| | | return BeanUtil.toBean(db, ${ClassName}Vo.class); |
| | | } |
| | | |
| | | @Override |
| | | public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) { |
| | | Map<String, Object> params = bo.getParams(); |
| | | LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery(); |
| | | #foreach($column in $columns) |
| | | #if($column.query) |
| | |
| | | #end |
| | | lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName()); |
| | | #else |
| | | Object dataScope = bo.getParams().get("dataScope"); |
| | | lqw.apply(dataScope != null, dataScope != null ? dataScope.toString() : null); |
| | | Map<String, Object> params = bo.getParams(); |
| | | if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) { |
| | | lqw.between(${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName")); |
| | | } |
| | | lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null, |
| | | ${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName")); |
| | | #end |
| | | #end |
| | | #end |
| | | return entity2Vo(this.list(lqw)); |
| | | } |
| | | |
| | | /** |
| | | * 实体类转化成视图对象 |
| | | * |
| | | * @param collection 实体类集合 |
| | | * @return |
| | | */ |
| | | private List<${ClassName}Vo> entity2Vo(Collection<${ClassName}> collection) { |
| | | List<${ClassName}Vo> voList = collection.stream() |
| | | .map(any -> BeanUtil.toBean(any, ${ClassName}Vo.class)) |
| | | .collect(Collectors.toList()); |
| | | if (collection instanceof Page) { |
| | | Page<${ClassName}> page = (Page<${ClassName}>)collection; |
| | | Page<${ClassName}Vo> pageVo = new Page<>(); |
| | | BeanUtil.copyProperties(page,pageVo); |
| | | pageVo.addAll(voList); |
| | | voList = pageVo; |
| | | } |
| | | return voList; |
| | | return PageUtils.buildDataInfo(page(PageUtils.buildPagePlus(), lqw)); |
| | | } |
| | | |
| | | @Override |