<?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="${mapperPackage}.${className}Mapper">
|
#set($jin="#{")
|
#set($dao ="${")
|
#set($newline="
|
")
|
<resultMap id="BaseResultMap" type="${doPackage}.${className}DO">
|
<id column="OID" jdbcType="VARCHAR" property="oid" />
|
#foreach($attr in $attributes)
|
#if($attr.id != "oid")
|
<result column="$attr.idUpper" property="$attr.id" jdbcType="$attr.jdbcType"/>
|
#end
|
#end
|
</resultMap>
|
<resultMap id="BaseResultMapHasRefer" type="${doPackage}.${className}DO" extends="BaseResultMap">
|
#foreach($attr in $referAttributes)
|
<result column="$attr.idUpper" property="$attr.id" jdbcType="$attr.jdbcType"/>
|
#end
|
</resultMap>
|
<sql id="base_query_column">
|
#foreach($attr in $attributes)
|
$attr.idUpper #if($foreach.hasNext),#end #if($velocityCount%5==0) $newline #end
|
#end
|
</sql>
|
<sql id="tableName">
|
${tableName}
|
</sql>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
|
delete from <include refid="tableName"/>
|
where OID = $jin oid,jdbcType=VARCHAR}
|
</delete>
|
<insert id="insert" parameterType="${doPackage}.${className}DO" >
|
insert into <include refid="tableName"/> (
|
#foreach($attr in $attributes) $attr.idUpper #if($foreach.hasNext),#end #if($velocityCount%5==0) $newline #end
|
#end )
|
values (
|
#foreach($attr in $attributes)
|
$jin $attr.id,jdbcType=$attr.jdbcType}#if($foreach.hasNext),#end #if($velocityCount%5==0) $newline #end
|
#end )
|
</insert>
|
<insert id="batchInsert" useGeneratedKeys="false" >
|
insert into <include refid="tableName"/> (
|
#foreach($attr in $attributes) $attr.idUpper #if($foreach.hasNext),#end #if($velocityCount%5==0) $newline #end
|
#end )
|
<foreach collection="records" item="item" separator="union all" >
|
(select
|
#foreach($attr in $attributes)
|
$jin item.$attr.id,jdbcType=$attr.jdbcType}#if($foreach.hasNext),#end #if($velocityCount%5==0) $newline #end
|
#end
|
FROM DUAL)
|
</foreach>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="${doPackage}.${className}DO" >
|
update <include refid="tableName"/> set
|
#foreach($attr in $attributes)
|
#if($attr.id !="oid")
|
$attr.idUpper = $jin $attr.id,jdbcType=$attr.jdbcType}#if($foreach.hasNext),#end #if($velocityCount%5==0) $newline #end
|
#end
|
#end
|
where OID = $jin oid,jdbcType=VARCHAR}
|
</update>
|
<update id="batchUpdate" parameterType="java.util.Collection">
|
<foreach collection="records" item="item" index="index" open="begin" close=";end;" separator=";">
|
update <include refid="tableName"/> set
|
#foreach($attr in $attributes)
|
#if($attr.id !="oid")
|
$attr.idUpper = $jin item.$attr.id,jdbcType=$attr.jdbcType}#if($foreach.hasNext),#end #if($velocityCount%5==0) $newline #end
|
#end
|
#end
|
where OID = $jin item.oid,jdbcType=VARCHAR}
|
</foreach>
|
</update>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
|
select <include refid="base_query_column"/>
|
from <include refid="tableName"/>
|
where OID = $jin oid,jdbcType=VARCHAR}
|
</select>
|
<select id="selectByPrimaryKeys" resultMap="BaseResultMap">
|
select <include refid="base_query_column" />
|
from <include refid="tableName" />
|
where OID in ( $dao oids,jdbcType=VARCHAR})
|
</select>
|
<select id="selectByPrimaryKeyCollection" resultMap="BaseResultMap">
|
select <include refid="base_query_column" />
|
from <include refid="tableName" />
|
<where>
|
<foreach collection="oids" item="item" index="arrayindex" open=" OID in ( " close=")" >
|
$jin item,jdbcType=VARCHAR}
|
<if test="(arrayindex != oids.size() -1)">
|
,
|
</if>
|
</foreach>
|
</where>
|
</select>
|
<select id="selectAll" resultMap="BaseResultMap" >
|
select <include refid="base_query_column"/>
|
from <include refid="tableName"/>
|
</select>
|
<select id="selectByWrapper" resultMap="BaseResultMap">
|
$dao wrapper.selectFieldSql} from <include refid="tableName"/> $dao wrapper.tableNick} $dao wrapper.linkTableSql}
|
<where>
|
$dao wrapper.whereSql}
|
</where>
|
</select>
|
<select id="countByWrapper" resultType="java.lang.Long">
|
select count(*) from ( $dao wrapper.selectFieldSql} from <include refid="tableName"/> $dao wrapper.tableNick} $dao wrapper.linkTableSql}
|
<where>
|
$dao wrapper.whereSql}
|
</where> )
|
</select>
|
<select id="selectNameByOid" resultType="java.lang.String">
|
select NAME from <include refid="tableName" />
|
where OID = $jin oid,jdbcType=VARCHAR}
|
</select>
|
<delete id="batchDeleteByOids" >
|
delete from <include refid="tableName" />
|
<where>
|
<foreach collection="oids" item="item" index="arrayindex" open=" oid in ( " close=")" >
|
$jin item,jdbcType=VARCHAR}
|
<if test="(arrayindex != oids.size() -1)">
|
,
|
</if>
|
</foreach>
|
</where>
|
</delete>
|
#if(${hasEnable})
|
<update id="batchUpdateLcStatus" >
|
update <include refid="tableName"/>
|
set lcstatus = $jin lcStatus,jdbcType=VARCHAR}, ts=sysdate
|
where
|
<foreach collection="oids" item="item" index="arrayindex" open=" oid in ( " close=")" >
|
$jin item,jdbcType=VARCHAR}
|
<if test="(arrayindex != oids.size() -1)">
|
,
|
</if>
|
</foreach>
|
</update>
|
<update id="updateLcStatus">
|
update <include refid="tableName"/>
|
set lcstatus = $jin lcStatus,jdbcType=VARCHAR}, ts=sysdate
|
where oid =$jin oid,jdbcType=VARCHAR}
|
</update>
|
#end
|
#if(${hasParentField})
|
<select id="selectAllLevelChild" parameterType="java.lang.String" resultMap="BaseResultMap">
|
select <include refid="base_query_column"/> FROM <include refid="tableName"/>
|
START WITH ${parentFieldName} = $jin oid,jdbcType=VARCHAR} CONNECT BY PRIOR OID=${parentFieldName}
|
</select>
|
<select id="selectAllLevelChildOid" parameterType="java.lang.String" resultType="java.lang.String">
|
select OID FROM <include refid="tableName"/>
|
START WITH ${parentFieldName} = $jin oid,jdbcType=VARCHAR} CONNECT BY PRIOR OID=${parentFieldName}
|
</select>
|
<select id="countAllLevelChildOid" resultType="java.lang.Long">
|
select count(OID) FROM <include refid="tableName"/>
|
START WITH ${parentFieldName} = $jin oid,jdbcType=VARCHAR} CONNECT BY PRIOR OID=${parentFieldName}
|
</select>
|
#end
|
</mapper>
|