mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	update 代码模板 适配新改动
This commit is contained in:
		@@ -3,7 +3,6 @@ package ${packageName}.service;
 | 
			
		||||
import ${packageName}.domain.${ClassName};
 | 
			
		||||
import ${packageName}.domain.vo.${ClassName}Vo;
 | 
			
		||||
import ${packageName}.domain.bo.${ClassName}Bo;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
 | 
			
		||||
#if($table.crud || $table.sub)
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import com.ruoyi.common.core.domain.PageQuery;
 | 
			
		||||
@@ -18,44 +17,44 @@ import java.util.List;
 | 
			
		||||
 * @author ${author}
 | 
			
		||||
 * @date ${datetime}
 | 
			
		||||
 */
 | 
			
		||||
public interface I${ClassName}Service extends IServicePlus<${ClassName}, ${ClassName}Vo> {
 | 
			
		||||
	/**
 | 
			
		||||
	 * 查询单个
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField});
 | 
			
		||||
public interface I${ClassName}Service {
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询单个
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField});
 | 
			
		||||
 | 
			
		||||
#if($table.crud || $table.sub)
 | 
			
		||||
	/**
 | 
			
		||||
	 * 查询列表
 | 
			
		||||
	 */
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询列表
 | 
			
		||||
     */
 | 
			
		||||
    TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery);
 | 
			
		||||
#end
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 查询列表
 | 
			
		||||
	 */
 | 
			
		||||
	List<${ClassName}Vo> queryList(${ClassName}Bo bo);
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询列表
 | 
			
		||||
     */
 | 
			
		||||
    List<${ClassName}Vo> queryList(${ClassName}Bo bo);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据新增业务对象插入${functionName}
 | 
			
		||||
	 * @param bo ${functionName}新增业务对象
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	Boolean insertByBo(${ClassName}Bo bo);
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据新增业务对象插入${functionName}
 | 
			
		||||
     * @param bo ${functionName}新增业务对象
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean insertByBo(${ClassName}Bo bo);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据编辑业务对象修改${functionName}
 | 
			
		||||
	 * @param bo ${functionName}编辑业务对象
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	Boolean updateByBo(${ClassName}Bo bo);
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据编辑业务对象修改${functionName}
 | 
			
		||||
     * @param bo ${functionName}编辑业务对象
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean updateByBo(${ClassName}Bo bo);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 校验并删除数据
 | 
			
		||||
	 * @param ids 主键集合
 | 
			
		||||
	 * @param isValid 是否校验,true-删除前校验,false-不校验
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	Boolean deleteWithValidByIds(Collection<${pkColumn.javaType}> ids, Boolean isValid);
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验并删除数据
 | 
			
		||||
     * @param ids 主键集合
 | 
			
		||||
     * @param isValid 是否校验,true-删除前校验,false-不校验
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean deleteWithValidByIds(Collection<${pkColumn.javaType}> ids, Boolean isValid);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,8 +6,8 @@ import com.ruoyi.common.utils.StringUtils;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import com.ruoyi.common.core.domain.PageQuery;
 | 
			
		||||
#end
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
			
		||||
@@ -27,19 +27,22 @@ import java.util.Collection;
 | 
			
		||||
 * @author ${author}
 | 
			
		||||
 * @date ${datetime}
 | 
			
		||||
 */
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
@Service
 | 
			
		||||
public class ${ClassName}ServiceImpl extends ServicePlusImpl<${ClassName}Mapper, ${ClassName}, ${ClassName}Vo> implements I${ClassName}Service {
 | 
			
		||||
public class ${ClassName}ServiceImpl implements I${ClassName}Service {
 | 
			
		||||
 | 
			
		||||
    private final ${ClassName}Mapper baseMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){
 | 
			
		||||
        return getVoById(${pkColumn.javaField});
 | 
			
		||||
        return baseMapper.selectVoById(${pkColumn.javaField});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if($table.crud || $table.sub)
 | 
			
		||||
    @Override
 | 
			
		||||
    public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery) {
 | 
			
		||||
        LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
 | 
			
		||||
        Page<${ClassName}Vo> result = pageVo(pageQuery.build(), lqw);
 | 
			
		||||
        Page<${ClassName}Vo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
 | 
			
		||||
        return TableDataInfo.build(result);
 | 
			
		||||
    }
 | 
			
		||||
#end
 | 
			
		||||
@@ -47,7 +50,7 @@ public class ${ClassName}ServiceImpl extends ServicePlusImpl<${ClassName}Mapper,
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<${ClassName}Vo> queryList(${ClassName}Bo bo) {
 | 
			
		||||
        LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
 | 
			
		||||
        return listVo(lqw);
 | 
			
		||||
        return baseMapper.selectVoList(lqw);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}Bo bo) {
 | 
			
		||||
@@ -81,7 +84,7 @@ public class ${ClassName}ServiceImpl extends ServicePlusImpl<${ClassName}Mapper,
 | 
			
		||||
    public Boolean insertByBo(${ClassName}Bo bo) {
 | 
			
		||||
        ${ClassName} add = BeanUtil.toBean(bo, ${ClassName}.class);
 | 
			
		||||
        validEntityBeforeSave(add);
 | 
			
		||||
        boolean flag = save(add);
 | 
			
		||||
        boolean flag = baseMapper.insert(add);
 | 
			
		||||
#set($pk=$pkColumn.javaField.substring(0,1).toUpperCase() + ${pkColumn.javaField.substring(1)})
 | 
			
		||||
        if (flag) {
 | 
			
		||||
            bo.set$pk(add.get$pk());
 | 
			
		||||
@@ -93,7 +96,7 @@ public class ${ClassName}ServiceImpl extends ServicePlusImpl<${ClassName}Mapper,
 | 
			
		||||
    public Boolean updateByBo(${ClassName}Bo bo) {
 | 
			
		||||
        ${ClassName} update = BeanUtil.toBean(bo, ${ClassName}.class);
 | 
			
		||||
        validEntityBeforeSave(update);
 | 
			
		||||
        return updateById(update);
 | 
			
		||||
        return baseMapper.updateById(update);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -110,6 +113,6 @@ public class ${ClassName}ServiceImpl extends ServicePlusImpl<${ClassName}Mapper,
 | 
			
		||||
        if(isValid){
 | 
			
		||||
            //TODO 做一些业务上的校验,判断是否需要校验
 | 
			
		||||
        }
 | 
			
		||||
        return removeByIds(ids);
 | 
			
		||||
        return baseMapper.deleteBatchIds(ids) > 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ import java.util.Date;
 | 
			
		||||
@ExcelIgnoreUnannotated
 | 
			
		||||
public class ${ClassName}Vo {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = 1L;
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
#foreach ($column in $columns)
 | 
			
		||||
#if($column.isList)
 | 
			
		||||
@@ -42,13 +42,13 @@ public class ${ClassName}Vo {
 | 
			
		||||
    @ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
 | 
			
		||||
    @ExcelDictFormat(dictType = "${column.dictType}")
 | 
			
		||||
#elseif($parentheseIndex != -1)
 | 
			
		||||
	@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
 | 
			
		||||
    @ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
 | 
			
		||||
    @ExcelDictFormat(readConverterExp = "$column.readConverterExp()")
 | 
			
		||||
#else
 | 
			
		||||
	@ExcelProperty(value = "${comment}")
 | 
			
		||||
    @ExcelProperty(value = "${comment}")
 | 
			
		||||
#end
 | 
			
		||||
	@ApiModelProperty("$column.columnComment")
 | 
			
		||||
	private $column.javaType $column.javaField;
 | 
			
		||||
    @ApiModelProperty("$column.columnComment")
 | 
			
		||||
    private $column.javaType $column.javaField;
 | 
			
		||||
 | 
			
		||||
#end
 | 
			
		||||
#end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user