<?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.goldenwater.gx.mapper.GxExchangeLogMapper">

    <resultMap type="com.goldenwater.gx.domain.GxExchangeLog" id="GxExchangeLogResult">
        <id     property="id"          column="id"           />
        <result property="bizCode"     column="biz_code"     />
        <result property="bizName"     column="biz_name"     />
        <result property="logTime"     column="log_time"     />
        <result property="content"     column="content"      />
        <result property="dnum"        column="dnum"         />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"  column="create_time"  />
        <result property="delFlag"     column="del_flag"     />
    </resultMap>

    <select id="selectGxExchangeLogList" parameterType="com.goldenwater.gx.domain.GxExchangeLog" resultMap="GxExchangeLogResult">
        select id, biz_code, biz_name, log_time, content, dnum, create_by, create_time, del_flag
        from gx_exchange_log
        where del_flag = '0'
        <if test="bizCode != null and bizCode != ''">
            AND biz_code = #{bizCode}
        </if>
        <if test="bizName != null and bizName != ''">
            AND biz_name like '%' || #{bizName} || '%'
        </if>
        <if test="params.beginTime != null and params.beginTime != ''">
            AND log_time &gt;= TO_DATE(#{params.beginTime}, 'YYYY-MM-DD')
        </if>
        <if test="params.endTime != null and params.endTime != ''">
            AND log_time &lt;= TO_DATE(#{params.endTime}, 'YYYY-MM-DD')
        </if>
        order by log_time desc
    </select>

    <select id="selectGxExchangeLogById" parameterType="Long" resultMap="GxExchangeLogResult">
        select id, biz_code, biz_name, log_time, content, dnum, create_by, create_time, del_flag
        from gx_exchange_log
        where id = #{id} and del_flag = '0'
    </select>

    <insert id="insertGxExchangeLog" parameterType="com.goldenwater.gx.domain.GxExchangeLog" useGeneratedKeys="true" keyProperty="id">
        insert into gx_exchange_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bizCode != null and bizCode != ''">biz_code,</if>
            <if test="bizName != null">biz_name,</if>
            <if test="logTime != null">log_time,</if>
            <if test="content != null">content,</if>
            <if test="dnum != null">dnum,</if>
            <if test="createBy != null">create_by,</if>
            create_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bizCode != null and bizCode != ''">#{bizCode},</if>
            <if test="bizName != null">#{bizName},</if>
            <if test="logTime != null">#{logTime},</if>
            <if test="content != null">#{content},</if>
            <if test="dnum != null">#{dnum},</if>
            <if test="createBy != null">#{createBy},</if>
            SYSDATE
        </trim>
    </insert>

    <update id="deleteGxExchangeLogById" parameterType="Long">
        update gx_exchange_log set del_flag = '1' where id = #{id}
    </update>

    <update id="deleteGxExchangeLogByIds" parameterType="Long">
        update gx_exchange_log set del_flag = '1' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

</mapper>
