143 lines
7.2 KiB
Plaintext
143 lines
7.2 KiB
Plaintext
|
<?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="com.ruoyi.system.domain.${ClassName}" id="${ClassName}Result">
|
||
|
#foreach ($column in $columns)
|
||
|
<result property="${column.javaField}" column="${column.columnName}" />
|
||
|
#end
|
||
|
#if($table.tree)
|
||
|
<result property="parentName" column="parent_name" />
|
||
|
#end
|
||
|
</resultMap>
|
||
|
#if($table.sub)
|
||
|
|
||
|
<resultMap id="${ClassName}${subClassName}Result" type="com.ruoyi.system.domain.${ClassName}" extends="${ClassName}Result">
|
||
|
<collection property="${subclassName}List" notNullColumn="${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="${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}List" parameterType="com.ruoyi.system.domain.${ClassName}" resultMap="${ClassName}Result">
|
||
|
<include refid="select${ClassName}Vo"/>
|
||
|
<where>
|
||
|
<if test="id != null "> and id = #{id}</if>
|
||
|
#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 > #{$javaField}</if>
|
||
|
#elseif($queryType == "GTE")
|
||
|
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
||
|
#elseif($queryType == "LT")
|
||
|
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
||
|
#elseif($queryType == "LTE")
|
||
|
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$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")
|
||
|
|
||
|
#end
|
||
|
#end
|
||
|
#end
|
||
|
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and create_time between #{params.beginTime} and #{params.endTime}</if>
|
||
|
</where>
|
||
|
order by id desc
|
||
|
</select>
|
||
|
|
||
|
<select id="find${ClassName}" parameterType="com.ruoyi.system.domain.${ClassName}" resultMap="${ClassName}Result">
|
||
|
<include refid="select${ClassName}Vo"/>
|
||
|
<where>
|
||
|
<if test="id != null "> and id = #{id}</if>
|
||
|
#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 > #{$javaField}</if>
|
||
|
#elseif($queryType == "GTE")
|
||
|
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
||
|
#elseif($queryType == "LT")
|
||
|
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
||
|
#elseif($queryType == "LTE")
|
||
|
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$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>
|
||
|
limit 1
|
||
|
</select>
|
||
|
|
||
|
<select id="select${ClassName}ById" parameterType="Integer" resultMap="${ClassName}Result">
|
||
|
<include refid="select${ClassName}Vo"/>
|
||
|
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||
|
</select>
|
||
|
|
||
|
<insert id="insert${ClassName}" parameterType="com.ruoyi.system.domain.${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
||
|
insert into ${tableName}
|
||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
|
#foreach($column in $columns)
|
||
|
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
||
|
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if>
|
||
|
#end
|
||
|
#end
|
||
|
</trim>
|
||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
|
#foreach($column in $columns)
|
||
|
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
||
|
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if>
|
||
|
#end
|
||
|
#end
|
||
|
</trim>
|
||
|
</insert>
|
||
|
|
||
|
<update id="update${ClassName}" parameterType="com.ruoyi.system.domain.${ClassName}">
|
||
|
update ${tableName}
|
||
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
#foreach($column in $columns)
|
||
|
#if($column.columnName != $pkColumn.columnName)
|
||
|
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
|
||
|
#end
|
||
|
#end
|
||
|
</trim>
|
||
|
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||
|
</update>
|
||
|
|
||
|
<delete id="delete${ClassName}ByIds" parameterType="String">
|
||
|
delete from ${tableName} where ${pkColumn.columnName} in
|
||
|
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
|
||
|
#{${pkColumn.javaField}}
|
||
|
</foreach>
|
||
|
</delete>
|
||
|
|
||
|
</mapper>
|