|
|
|
@ -15,12 +15,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
#if($table.sub) |
|
|
|
|
|
|
|
|
|
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result"> |
|
|
|
|
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" /> |
|
|
|
|
<collection property="${subclassName}List" ofType="${subClassName}" column="${subTableFkName}" select="select${subClassName}List" /> |
|
|
|
|
</resultMap> |
|
|
|
|
|
|
|
|
|
<resultMap type="${subClassName}" id="${subClassName}Result"> |
|
|
|
|
#foreach ($column in $subTable.columns) |
|
|
|
|
<result property="${column.javaField}" column="sub_${column.columnName}" /> |
|
|
|
|
<result property="${column.javaField}" column="${column.columnName}" /> |
|
|
|
|
#end |
|
|
|
|
</resultMap> |
|
|
|
|
#end |
|
|
|
@ -74,15 +74,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
left join ${tableName} p on p.${pkColumn.columnName} = t.${tree_parent_code} |
|
|
|
|
where t.${pkColumn.columnName} = #{${pkColumn.javaField}} |
|
|
|
|
#elseif($table.sub) |
|
|
|
|
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end, |
|
|
|
|
#foreach($column in $subTable.columns) b.$column.columnName as sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end |
|
|
|
|
|
|
|
|
|
from ${tableName} a |
|
|
|
|
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName} |
|
|
|
|
where a.${pkColumn.columnName} = #{${pkColumn.javaField}} |
|
|
|
|
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end |
|
|
|
|
from ${tableName} |
|
|
|
|
where ${pkColumn.columnName} = #{${pkColumn.javaField}} |
|
|
|
|
#end |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<select id="select${subClassName}List" resultType="${subClassName}" resultMap="${subClassName}Result"> |
|
|
|
|
select#foreach ($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end |
|
|
|
|
from ${subTableName} |
|
|
|
|
where ${subTableFkName} = #{${subTableFkName}} |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end> |
|
|
|
|
insert into ${tableName} |
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=","> |
|
|
|
|