<?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="com.engine.organization.mapper.extend.ExtMapper">

    <insert id="insertTable" parameterType="com.engine.organization.entity.extend.param.ExtendInfoParams"
            keyProperty="id"
            keyColumn="id" useGeneratedKeys="true">
        insert into ${tableName} (
        <foreach collection="params" item="value" index="key" separator=",">
            ${key}
        </foreach>
        )
        values (
        <foreach collection="params" item="value" index="key" separator=",">
            #{value}
        </foreach>
        )
    </insert>

    <insert id="insertTable" parameterType="com.engine.organization.entity.extend.param.ExtendInfoParams"
            databaseId="oracle">
        <selectKey keyProperty="id" resultType="long" order="AFTER">
            select ${sequenceName}.currval from dual
        </selectKey>

        insert into ${tableName} (
        <foreach collection="params" item="value" index="key" separator=",">
            ${key}
        </foreach>
        )
        values (
        <foreach collection="params" item="value" index="key" separator=",">
            #{value}
        </foreach>
        )
    </insert>
    <insert id="insertExtTable" parameterType="com.engine.organization.entity.extend.param.ExtendInfoParams">
        insert into ${tableName} (
        <foreach collection="params" item="value" index="key" separator=",">
            ${key}
        </foreach>
        )
        values (
        <foreach collection="params" item="value" index="key" separator=",">
            #{value}
        </foreach>
        )
    </insert>

    <update id="updateTable" parameterType="com.engine.organization.entity.extend.param.ExtendInfoParams">
        update ${tableName} set
        <foreach collection="params" item="value" index="key" separator=",">
            ${key} = #{value}
        </foreach>
        where id = #{id}
    </update>
    <delete id="deleteByID">
        delete
        from ${tableName}
        where id = #{id}
    </delete>

    <select id="listExt" parameterType="com.engine.organization.entity.extend.param.ExtendInfoParams" resultType="map">
        select ${fields}
        from ${tableName}
        where delete_type = 0
          and id = #{id}
    </select>

    <select id="countExtById" parameterType="com.engine.organization.entity.extend.param.ExtendInfoParams"
            resultType="java.lang.Integer">
        select count(1)
        from ${tableName}
        where delete_type = 0
          and id = #{id}
    </select>
</mapper>