2018-07-09 08:44:52 +08:00
|
|
|
<?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="${package}.mapper.${className}Mapper">
|
|
|
|
|
|
|
|
<resultMap type="${className}" id="${className}Result">
|
|
|
|
#foreach ($column in $columns)
|
|
|
|
<result property="${column.attrname}" column="${column.columnName}" />
|
|
|
|
#end
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<sql id="select${className}Vo">
|
|
|
|
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="select${className}List" parameterType="${className}" resultMap="${className}Result">
|
|
|
|
<include refid="select${className}Vo"/>
|
|
|
|
<where>
|
|
|
|
#foreach($column in $columns)
|
2018-09-28 17:18:18 +08:00
|
|
|
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname.trim() != '' #end"> and $column.columnName = #{$column.attrname}</if>
|
2018-07-09 08:44:52 +08:00
|
|
|
#end
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="select${className}ById" parameterType="${primaryKey.attrType}" resultMap="${className}Result">
|
|
|
|
<include refid="select${className}Vo"/>
|
|
|
|
where ${primaryKey.columnName} = #{${primaryKey.attrname}}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<insert id="insert${className}" parameterType="${className}"#if($primaryKey.extra == 'auto_increment') useGeneratedKeys="true" keyProperty="$primaryKey.attrname"#end>
|
2018-07-23 21:34:33 +08:00
|
|
|
insert into ${tableName}
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
2018-07-09 08:44:52 +08:00
|
|
|
#foreach($column in $columns)
|
|
|
|
#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment')
|
2018-09-28 17:18:18 +08:00
|
|
|
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">$column.columnName,</if>
|
2018-07-09 08:44:52 +08:00
|
|
|
#end
|
|
|
|
#end
|
2018-07-23 21:34:33 +08:00
|
|
|
</trim>
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
2018-07-09 08:44:52 +08:00
|
|
|
#foreach($column in $columns)
|
|
|
|
#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment')
|
2018-09-28 17:18:18 +08:00
|
|
|
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">#{$column.attrname},</if>
|
2018-07-09 08:44:52 +08:00
|
|
|
#end
|
|
|
|
#end
|
2018-07-23 21:34:33 +08:00
|
|
|
</trim>
|
2018-07-09 08:44:52 +08:00
|
|
|
</insert>
|
|
|
|
|
|
|
|
<update id="update${className}" parameterType="${className}">
|
2018-07-24 00:20:01 +08:00
|
|
|
update ${tableName}
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
2018-07-24 10:01:39 +08:00
|
|
|
#foreach($column in $columns)
|
|
|
|
#if($column.columnName != $primaryKey.columnName)
|
|
|
|
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">$column.columnName = #{$column.attrname},</if>
|
|
|
|
#end
|
|
|
|
#end
|
2018-07-24 00:20:01 +08:00
|
|
|
</trim>
|
2018-07-24 10:01:39 +08:00
|
|
|
where ${primaryKey.columnName} = #{${primaryKey.attrname}}
|
2018-07-09 08:44:52 +08:00
|
|
|
</update>
|
2018-07-24 00:20:01 +08:00
|
|
|
|
2018-07-09 08:44:52 +08:00
|
|
|
<delete id="delete${className}ById" parameterType="${primaryKey.attrType}">
|
|
|
|
delete from ${tableName} where ${primaryKey.columnName} = #{${primaryKey.attrname}}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<delete id="delete${className}ByIds" parameterType="String">
|
|
|
|
delete from ${tableName} where ${primaryKey.columnName} in
|
|
|
|
<foreach item="${primaryKey.attrname}" collection="array" open="(" separator="," close=")">
|
|
|
|
#{${primaryKey.attrname}}
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
</mapper>
|