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