You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
5.4 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
</resultMap>
#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" />
</resultMap>
<resultMap type="${subClassName}" id="${subClassName}Result">
#foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="sub_${column.columnName}" />
#end
</resultMap>
#end
<sql id="select${ClassName}Vo">
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName}
</sql>
<select id="select${ClassName}Page" parameterType="${ClassName}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/>
<where>
#foreach($column in $columns)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
#if($column.queryType == "EQ")
<if test="entity.$javaField != null #if($javaType == 'String' ) and entity.$javaField.trim() != ''#end"> and $columnName = #{entity.$javaField}</if>
#elseif($queryType == "NE")
<if test="entity.$javaField != null #if($javaType == 'String' ) and entity.$javaField.trim() != ''#end"> and $columnName != #{entity.$javaField}</if>
#elseif($queryType == "GT")
<if test="entity.$javaField != null #if($javaType == 'String' ) and entity.$javaField.trim() != ''#end"> and $columnName &gt; #{entity.$javaField}</if>
#elseif($queryType == "GTE")
<if test="entity.$javaField != null #if($javaType == 'String' ) and entity.$javaField.trim() != ''#end"> and $columnName &gt;= #{entity.$javaField}</if>
#elseif($queryType == "LT")
<if test="entity.$javaField != null #if($javaType == 'String' ) and entity.$javaField.trim() != ''#end"> and $columnName &lt; #{entity.$javaField}</if>
#elseif($queryType == "LTE")
<if test="entity.$javaField != null #if($javaType == 'String' ) and entity.$javaField.trim() != ''#end"> and $columnName &lt;= #{entity.$javaField}</if>
#elseif($queryType == "LIKE")
<if test="entity.$javaField != null #if($javaType == 'String' ) and entity.$javaField.trim() != ''#end"> and $columnName like concat('%', #{entity.$javaField}, '%')</if>
#elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
#end
#end
#end
</where>
</select>
<select id="select${ClassName}List" parameterType="${packageName}.domain.${ClassName}"
resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/>
<where>
#foreach($column in $columns)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
#if($column.queryType == "EQ")
<if test="$javaField != null #if($javaType == 'String') and $javaField.trim() != ''#end">
and $columnName = #{$javaField}
</if>
#elseif($queryType == "NE")
<if test="$javaField != null #if($javaType == 'String') and $javaField.trim() != ''#end">
and $columnName != #{$javaField}
</if>
#elseif($queryType == "GT")
<if test="$javaField != null #if($javaType == 'String') and $javaField.trim() != ''#end">
and $columnName &gt; #{$javaField}
</if>
#elseif($queryType == "GTE")
<if test="$javaField != null #if($javaType == 'String') and $javaField.trim() != ''#end">
and $columnName &gt;= #{$javaField}
</if>
#elseif($queryType == "LT")
<if test="$javaField != null #if($javaType == 'String') and $javaField.trim() != ''#end">
and $columnName &lt; #{$javaField}
</if>
#elseif($queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String') and $javaField.trim() != ''#end">
and $columnName &lt;= #{$javaField}
</if>
#elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String') and $javaField.trim() != ''#end">
and $columnName like concat('%', #{$javaField}, '%')
</if>
#elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''">
and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}
</if>
#end
#end
#end
</where>
</select>
</mapper>