<?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="${mapper.clazz}">
|
<resultMap id="BaseResultMap"
|
type="${entity.clazz}">
|
<id column="${identify.column}" property="${identify.property}" jdbcType="${identify.jdbcType}"/>
|
<#list columnList as column>
|
<result column="${column.column}" property="${column.property}" jdbcType="${column.jdbcType}"/>
|
</#list>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
<trim suffixOverrides=",">
|
<#list columnList as column>${column.column},</#list>
|
</trim>
|
</sql>
|
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List"/>
|
from ${table} where ${identify.column} = <#noparse>#{</#noparse>id, jdbcType=${identify.jdbcType}}
|
</select>
|
|
<select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List"/>
|
from ${table} where ${identify.column} = <#noparse>#{</#noparse>id,jdbcType=${identify.jdbcType}} for update
|
</select>
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
delete from
|
${table} where ${identify.column} = <#noparse>#{</#noparse>id,jdbcType=${identify.jdbcType}}
|
</delete>
|
<insert id="insert"
|
parameterType="${entity.class}"
|
useGeneratedKeys="true" keyProperty="${identify.property}">
|
insert into
|
${table}
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<#list columnList as column>
|
${column.column}},
|
</#list>
|
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<#list columnList as column>
|
<#noparse>#{</#noparse>${column.property}},jdbcType=${column.jdbcType}},
|
</#list>
|
|
</trim>
|
|
</insert>
|
<insert id="insertSelective"
|
parameterType="${entity.class}"
|
useGeneratedKeys="true" keyProperty="${identify.property}">
|
insert into ${table}
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="${identify.property} != null">${identify.column},</if>
|
<#list columnList as column>
|
<if test="${column.property} != null">${column.column},</if>
|
</#list>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="${identify.property} != null"><#noparse>#{</#noparse>${identify.property},jdbcType=${identify.jdbcType}},</if>
|
<#list columnList as column>
|
<if test="${column.property} != null"><#noparse>#{</#noparse>${column.property},jdbcType=${column.jdbcType}},</if>
|
</#list>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey"
|
parameterType="${entity.class}">
|
update ${table}
|
<set>
|
<if test="${identify.property} != null">${identify.column} = <#noparse>#{</#noparse>${identify.property},jdbcType=${identify.jdbcType}},</if>
|
<#list columnList as column>
|
<if test="${column.property} != null">${column.column} = <#noparse>#{</#noparse>${column.property},jdbcType=${column.jdbcType}},</if>
|
</#list>
|
</set>
|
where ${identify.column} = <#noparse>#{</#noparse>${identify.property},jdbcType=${identify.jdbcType}}
|
</update>
|
<update id="updateByPrimaryKeySelective"
|
parameterType="${entity.class}">
|
update ${table}
|
<set>
|
<#list columnList as column>
|
<if test="${column.property} != null">${column.column} = <#noparse>#{</#noparse>${column.property},jdbcType=${column.jdbcType}},</if>
|
</#list>
|
</set>
|
where ${identify.column} = <#noparse>#{</#noparse>${identify.property},jdbcType=${identify.jdbcType}}
|
</update>
|
|
<sql id="listWhere">
|
<#list queryList as query>
|
<if test="query.${query.columnName}!=null">
|
<#if query.queryType=="equal">
|
and ${query.columnData.column} = <#noparse>#{</#noparse>query.${query.columnName}}
|
</#if>
|
<#if query.queryType=="start">
|
and ${query.columnData.column} like '<#noparse>#{</#noparse>query.${query.columnName}}%'
|
</#if>
|
<#if query.queryType=="end">
|
and ${query.columnData.column} like '%<#noparse>#{</#noparse>query.${query.columnName}}'
|
</#if>
|
<#if query.queryType=="contains">
|
and ${query.columnData.column} = '%<#noparse>#{</#noparse>query.${query.columnName}}%'
|
</#if>
|
</if>
|
</#list>
|
</sql>
|
|
<select id="list"
|
resultMap="BaseResultMap">
|
SELECT * FROM ${table}
|
<where>
|
<include refid="listWhere">
|
</include>
|
</where>
|
<if test="query.sortList!=null">
|
<foreach collection="query.sortList" open=" order by " separator="," item="item">
|
<#noparse>#{</#noparse>item}
|
</foreach>
|
</if>
|
limit <#noparse>#{</#noparse>query.start},<#noparse>#{</#noparse>query.count}
|
</select>
|
|
|
<select id="count"
|
resultType="java.lang.Long">
|
SELECT count(*) FROM ${table}
|
<where>
|
<include refid="listWhere">
|
</include>
|
</where>
|
</select>
|
|
|
</mapper>
|