|
@@ -2,7 +2,11 @@ package ${packageName}.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+#if($table.crud || $table.sub)
|
|
import com.ruoyi.common.utils.PageUtils;
|
|
import com.ruoyi.common.utils.PageUtils;
|
|
|
|
+import com.ruoyi.common.core.page.PagePlus;
|
|
|
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
+#end
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -17,6 +21,7 @@ import ${packageName}.service.I${ClassName}Service;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Collection;
|
|
|
|
|
|
/**
|
|
/**
|
|
* ${functionName}Service业务层处理
|
|
* ${functionName}Service业务层处理
|
|
@@ -29,12 +34,23 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){
|
|
public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){
|
|
- ${ClassName} db = this.baseMapper.selectById(${pkColumn.javaField});
|
|
|
|
- return BeanUtil.toBean(db, ${ClassName}Vo.class);
|
|
|
|
|
|
+ return getVoById(${pkColumn.javaField}, ${ClassName}Vo.class);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#if($table.crud || $table.sub)
|
|
|
|
+ @Override
|
|
|
|
+ public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}QueryBo bo) {
|
|
|
|
+ PagePlus<${ClassName}, ${ClassName}Vo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ${ClassName}Vo.class);
|
|
|
|
+ return PageUtils.buildDataInfo(result);
|
|
|
|
+ }
|
|
|
|
+#end
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) {
|
|
public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) {
|
|
|
|
+ return listVo(buildQueryWrapper(bo), ${ClassName}Vo.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}QueryBo bo) {
|
|
Map<String, Object> params = bo.getParams();
|
|
Map<String, Object> params = bo.getParams();
|
|
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
|
|
#foreach($column in $columns)
|
|
#foreach($column in $columns)
|
|
@@ -58,21 +74,21 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
|
|
#end
|
|
#end
|
|
#end
|
|
#end
|
|
#end
|
|
#end
|
|
- return PageUtils.buildDataInfo(page(PageUtils.buildPagePlus(), lqw));
|
|
|
|
|
|
+ return lqw;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Boolean insertByAddBo(${ClassName}AddBo bo) {
|
|
public Boolean insertByAddBo(${ClassName}AddBo bo) {
|
|
${ClassName} add = BeanUtil.toBean(bo, ${ClassName}.class);
|
|
${ClassName} add = BeanUtil.toBean(bo, ${ClassName}.class);
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
- return this.save(add);
|
|
|
|
|
|
+ return save(add);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Boolean updateByEditBo(${ClassName}EditBo bo) {
|
|
public Boolean updateByEditBo(${ClassName}EditBo bo) {
|
|
${ClassName} update = BeanUtil.toBean(bo, ${ClassName}.class);
|
|
${ClassName} update = BeanUtil.toBean(bo, ${ClassName}.class);
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
- return this.updateById(update);
|
|
|
|
|
|
+ return updateById(update);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -89,6 +105,6 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
|
|
if(isValid){
|
|
if(isValid){
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
}
|
|
}
|
|
- return this.removeByIds(ids);
|
|
|
|
|
|
+ return removeByIds(ids);
|
|
}
|
|
}
|
|
}
|
|
}
|