| | |
| | | package ${packageName}.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.github.pagehelper.Page; |
| | | import ${packageName}.bo.${ClassName}AddBo; |
| | | import ${packageName}.bo.${ClassName}QueryBo; |
| | | import ${packageName}.bo.${ClassName}EditBo; |
| | |
| | | @Override |
| | | public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){ |
| | | ${ClassName} db = this.baseMapper.selectById(${pkColumn.javaField}); |
| | | return entity2Vo(Collections.singletonList(db)).get(0); |
| | | return BeanUtil.toBean(db, ${ClassName}Vo.class); |
| | | } |
| | | |
| | | @Override |
| | |
| | | #set($mpMethod=$column.queryType.toLowerCase()) |
| | | #if($queryType != 'BETWEEN') |
| | | #if($javaType == 'String') |
| | | #set($condition='StringUtils.isNotBlank(bo.get'+$AttrName+'())') |
| | | #set($condition='StrUtil.isNotBlank(bo.get'+$AttrName+'())') |
| | | #else |
| | | #set($condition='bo.get'+$AttrName+'() != null') |
| | | #end |
| | | lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName()); |
| | | #else |
| | | Map<String, Object> params = ${className}.getParams(); |
| | | 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")); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | private List<${ClassName}Vo> entity2Vo(Collection<${ClassName}> collection) { |
| | | return collection.stream() |
| | | 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; |
| | | } |
| | | |
| | | @Override |