<?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.brilliance.isc.mda.dao.SlgMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Slg">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="logtyp" column="logtyp" jdbcType="VARCHAR"/>
        <result property="loginr" column="loginr" jdbcType="VARCHAR"/>
        <result property="fct" column="fct" jdbcType="VARCHAR"/>
        <result property="dattim" column="dattim" jdbcType="DATE"/>
        <result property="usr" column="usr" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,logtyp,loginr,fct,dattim,usr,ver
    </sql>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap">
        select
            <include refid="Base_Column_List" />
        from slg
        where inr = #{inr,jdbcType=VARCHAR}
    </select>

    <delete id="deleteByPrimaryKey">
        delete from slg
        where inr = #{inr,jdbcType=VARCHAR}
    </delete>

    <insert id="insert">
        insert into slg (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{logtyp,jdbcType=VARCHAR},
            #{loginr,jdbcType=VARCHAR},
            #{fct,jdbcType=VARCHAR},
            #{dattim,jdbcType=DATE},
            #{usr,jdbcType=VARCHAR},
            #{ver,jdbcType=VARCHAR},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into slg
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="logtyp != null">logtyp,</if>
            <if test="loginr != null">loginr,</if>
            <if test="fct != null">fct,</if>
            <if test="dattim != null">dattim,</if>
            <if test="usr != null">usr,</if>
            <if test="ver != null">ver,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR}, </if>
            <if test="logtyp != null">#{logtyp,jdbcType=VARCHAR}, </if>
            <if test="loginr != null">#{loginr,jdbcType=VARCHAR}, </if>
            <if test="fct != null">#{fct,jdbcType=VARCHAR}, </if>
            <if test="dattim != null">#{dattim,jdbcType=DATE}, </if>
            <if test="usr != null">#{usr,jdbcType=VARCHAR}, </if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR}, </if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update slg
        <set>
            <if test="logtyp != null">logtyp = #{logtyp,jdbcType=VARCHAR},</if>
            <if test="loginr != null">loginr = #{loginr,jdbcType=VARCHAR},</if>
            <if test="fct != null">fct = #{fct,jdbcType=VARCHAR},</if>
            <if test="dattim != null">dattim = #{dattim,jdbcType=DATE},</if>
            <if test="usr != null">usr = #{usr,jdbcType=VARCHAR},</if>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update slg
        <set>
            logtyp = #{logtyp,jdbcType=VARCHAR},
            loginr = #{loginr,jdbcType=VARCHAR},
            fct = #{fct,jdbcType=VARCHAR},
            dattim = #{dattim,jdbcType=DATE},
            usr = #{usr,jdbcType=VARCHAR},
            ver = #{ver,jdbcType=VARCHAR},
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <delete id="deleteByIds">
        delete from act where inr in
        <foreach item="item" index="index" collection="collection" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>

    <update id="dyncUpdate">
        update slg
        <set>
            <if test="module.logtyp != null">logtyp = #{module.logtyp,jdbcType=VARCHAR},</if>
            <if test="module.loginr != null">loginr = #{module.loginr,jdbcType=VARCHAR},</if>
            <if test="module.fct != null">fct = #{module.fct,jdbcType=VARCHAR},</if>
            <if test="module.dattim != null">dattim = #{module.dattim,jdbcType=DATE},</if>
            <if test="module.usr != null">usr = #{module.usr,jdbcType=VARCHAR},</if>
            <if test="module.ver != null">ver = #{module.ver,jdbcType=VARCHAR},</if>
        </set>
        ${conditions}
    </update>

    <delete id="dyncDelete">
        ${sql}
    </delete>

    <select id="dyncRead" resultMap="BaseResultMap">
        ${sql}
    </select>

    <insert id="insertHistory">
        insert into SLG(INR, LOGTYP, LOGINR, FCT, DATTIM, USR, VER)
        select lpad(COUSLG.nextval,8,'0'),AAA.* from( select #{item.logtyp,jdbcType=VARCHAR}, #{item.loginr,jdbcType=VARCHAR}, #{item.fct,jdbcType=VARCHAR}, TO_TIMESTAMP(#{item.dattim}, '%Y-%m-%d %H:%i:%S.%f'), #{item.usr,jdbcType=VARCHAR}, #{item.ver,jdbcType=VARCHAR}
        from dual
        ) AAA
    </insert>
    <select id="selectByLogtypAndLoginrAndVer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from slg
        where
        logtyp = #{logtyp,jdbcType=VARCHAR}
        AND loginr = #{loginr,jdbcType=VARCHAR}
        AND ver = #{ver,jdbcType=VARCHAR}
    </select>

</mapper>