|
@ -12,9 +12,9 @@ import org.springframework.stereotype.Service; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import com.lzbi.common.utils.DateUtils; |
|
|
import com.lzbi.common.utils.DateUtils; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import ${packageName}.domain.${subClassName}Dao; |
|
|
import ${packageName}.domain.${subClassName}; |
|
|
#end |
|
|
#end |
|
|
import ${packageName}.domain.${ClassName}Dao; |
|
|
import ${packageName}.domain.${ClassName}; |
|
|
import ${packageName}.mapper.${ClassName}Mapper; |
|
|
import ${packageName}.mapper.${ClassName}Mapper; |
|
|
import com.baomidou.mybatisplus.extension.service.IService; |
|
|
import com.baomidou.mybatisplus.extension.service.IService; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
@ -25,7 +25,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
* @date ${datetime} |
|
|
* @date ${datetime} |
|
|
*/ |
|
|
*/ |
|
|
@Service |
|
|
@Service |
|
|
public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${ClassName}Dao> implements IService<${ClassName}Dao> |
|
|
public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements IService<${ClassName}> |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -34,70 +34,70 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class |
|
|
* @param ${pkColumn.javaField} ${functionName}主键 |
|
|
* @param ${pkColumn.javaField} ${functionName}主键 |
|
|
* @return ${functionName} |
|
|
* @return ${functionName} |
|
|
*/ |
|
|
*/ |
|
|
public ${ClassName}Dao select${ClassName}DaoBy${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) |
|
|
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) |
|
|
{ |
|
|
{ |
|
|
return baseMapper.select${ClassName}DaoBy${pkColumn.capJavaField}(${pkColumn.javaField}); |
|
|
return baseMapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询${functionName}列表 |
|
|
* 查询${functionName}列表 |
|
|
* |
|
|
* |
|
|
* @param ${className}Dao ${functionName} |
|
|
* @param ${className} ${functionName} |
|
|
* @return ${functionName} |
|
|
* @return ${functionName} |
|
|
*/ |
|
|
*/ |
|
|
public List<${ClassName}Dao> select${ClassName}DaoList(${ClassName}Dao ${className}Dao) |
|
|
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) |
|
|
{ |
|
|
{ |
|
|
return baseMapper.select${ClassName}DaoList(${className}Dao); |
|
|
return baseMapper.select${ClassName}List(${className}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 新增${functionName} |
|
|
* 新增${functionName} |
|
|
* |
|
|
* |
|
|
* @param ${className}Dao ${functionName} |
|
|
* @param ${className} ${functionName} |
|
|
* @return 结果 |
|
|
* @return 结果 |
|
|
*/ |
|
|
*/ |
|
|
#if($table.sub) |
|
|
#if($table.sub) |
|
|
@Transactional |
|
|
@Transactional |
|
|
#end |
|
|
#end |
|
|
|
|
|
|
|
|
public int insert${ClassName}Dao(${ClassName}Dao ${className}Dao) |
|
|
public int insert${ClassName}(${ClassName} ${className}) |
|
|
{ |
|
|
{ |
|
|
#foreach ($column in $columns) |
|
|
#foreach ($column in $columns) |
|
|
#if($column.javaField == 'createdTime') |
|
|
#if($column.javaField == 'createdTime') |
|
|
${className}Dao.setCreatedTime(DateUtils.getNowDate()); |
|
|
${className}.setCreatedTime(DateUtils.getNowDate()); |
|
|
#end |
|
|
#end |
|
|
#end |
|
|
#end |
|
|
#if($table.sub) |
|
|
#if($table.sub) |
|
|
int rows = baseMapper.insert${ClassName}Dao(${className}Dao); |
|
|
int rows = baseMapper.insert${ClassName}(${className}); |
|
|
insert${subClassName}Dao(${className}Dao); |
|
|
insert${subClassName}(${className}); |
|
|
return rows; |
|
|
return rows; |
|
|
#else |
|
|
#else |
|
|
return baseMapper.insert${ClassName}Dao(${className}Dao); |
|
|
return baseMapper.insert${ClassName}(${className}); |
|
|
#end |
|
|
#end |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 修改${functionName} |
|
|
* 修改${functionName} |
|
|
* |
|
|
* |
|
|
* @param ${className}Dao ${functionName} |
|
|
* @param ${className} ${functionName} |
|
|
* @return 结果 |
|
|
* @return 结果 |
|
|
*/ |
|
|
*/ |
|
|
#if($table.sub) |
|
|
#if($table.sub) |
|
|
@Transactional |
|
|
@Transactional |
|
|
#end |
|
|
#end |
|
|
|
|
|
|
|
|
public int update${ClassName}Dao(${ClassName}Dao ${className}Dao) |
|
|
public int update${ClassName}(${ClassName} ${className}) |
|
|
{ |
|
|
{ |
|
|
#foreach ($column in $columns) |
|
|
#foreach ($column in $columns) |
|
|
#if($column.javaField == 'updatedTime') |
|
|
#if($column.javaField == 'updatedTime') |
|
|
${className}Dao.setUpdatedTime(DateUtils.getNowDate()); |
|
|
${className}.setUpdatedTime(DateUtils.getNowDate()); |
|
|
#end |
|
|
#end |
|
|
#end |
|
|
#end |
|
|
#if($table.sub) |
|
|
#if($table.sub) |
|
|
baseMapper.delete${subClassName}By${subTableFkClassName}(${className}Dao.get${pkColumn.capJavaField}()); |
|
|
baseMapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); |
|
|
insert${subClassName}Dao(${className}Dao); |
|
|
insert${subClassName}(${className}); |
|
|
#end |
|
|
#end |
|
|
return baseMapper.update${ClassName}Dao(${className}Dao); |
|
|
return baseMapper.update${ClassName}(${className}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -110,12 +110,12 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class |
|
|
@Transactional |
|
|
@Transactional |
|
|
#end |
|
|
#end |
|
|
|
|
|
|
|
|
public int delete${ClassName}DaoBy${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) |
|
|
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) |
|
|
{ |
|
|
{ |
|
|
#if($table.sub) |
|
|
#if($table.sub) |
|
|
baseMapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s); |
|
|
baseMapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s); |
|
|
#end |
|
|
#end |
|
|
return baseMapper.delete${ClassName}DaoBy${pkColumn.capJavaField}s(${pkColumn.javaField}s); |
|
|
return baseMapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -128,28 +128,28 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class |
|
|
@Transactional |
|
|
@Transactional |
|
|
#end |
|
|
#end |
|
|
|
|
|
|
|
|
public int delete${ClassName}DaoBy${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) |
|
|
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) |
|
|
{ |
|
|
{ |
|
|
#if($table.sub) |
|
|
#if($table.sub) |
|
|
baseMapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); |
|
|
baseMapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); |
|
|
#end |
|
|
#end |
|
|
return baseMapper.delete${ClassName}DaoBy${pkColumn.capJavaField}(${pkColumn.javaField}); |
|
|
return baseMapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); |
|
|
} |
|
|
} |
|
|
#if($table.sub) |
|
|
#if($table.sub) |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 新增${subTable.functionName}信息 |
|
|
* 新增${subTable.functionName}信息 |
|
|
* |
|
|
* |
|
|
* @param ${className}Dao ${functionName}对象 |
|
|
* @param ${className} ${functionName}对象 |
|
|
*/ |
|
|
*/ |
|
|
public void insert${subClassName}Dao(${ClassName}Dao ${className}Dao) |
|
|
public void insert${subClassName}(${ClassName} ${className}) |
|
|
{ |
|
|
{ |
|
|
List<${subClassName}Dao> ${subclassName}DaoList = ${className}Dao.get${subClassName}DaoList(); |
|
|
List<${subClassName}> ${subclassName}DaoList = ${className}.get${subClassName}List(); |
|
|
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); |
|
|
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); |
|
|
if (StringUtils.isNotNull(${subclassName}DaoList)) |
|
|
if (StringUtils.isNotNull(${subclassName}DaoList)) |
|
|
{ |
|
|
{ |
|
|
List<${subClassName}Dao> list = new ArrayList<${subClassName}Dao>(); |
|
|
List<${subClassName}> list = new ArrayList<${subClassName}>(); |
|
|
for (${subClassName}Dao ${subclassName}Dao : ${subclassName}DaoList) |
|
|
for (${subClassName} ${subclassName}Dao : ${subclassName}DaoList) |
|
|
{ |
|
|
{ |
|
|
${subclassName}Dao.set${subTableFkClassName}(${pkColumn.javaField}); |
|
|
${subclassName}Dao.set${subTableFkClassName}(${pkColumn.javaField}); |
|
|
list.add(${subclassName}Dao); |
|
|
list.add(${subclassName}Dao); |
|
|