疯狂的狮子li
2021-04-14 f093da99ecb963d19d62dc0f242f00b20bc8895c
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
@@ -1,11 +1,12 @@
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;
@@ -31,7 +32,7 @@
    @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
@@ -47,13 +48,15 @@
#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"));
        }
@@ -70,9 +73,17 @@
    * @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