<?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">
<!--suppress SqlDialectInspection -->
<mapper namespace="com.xhpc.card.mapper.TIccardLogMapper">
    <resultMap id="BaseResultMap" type="com.xhpc.card.pojo.TIccardLog">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="uniqueID" jdbcType="VARCHAR" property="uniqueid"/>
        <result column="type" jdbcType="TINYINT" property="type"/>
        <result column="operate" jdbcType="TINYINT" property="operate"/>
        <result column="operatorId" jdbcType="INTEGER" property="operatorid"/>
        <result column="log" jdbcType="VARCHAR" property="log"/>
        <result column="createTime" jdbcType="TIMESTAMP" property="createtime"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        , uniqueID, `type`, operate, operatorId, log, createTime
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_iccard_log
        where id = #{id,jdbcType=INTEGER}
    </select>
    <select id="selectByCondition" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        t_iccard_log
        <where>
            type = 0
            <if test="logStartTime!=null and logStartTime!='' ">
                AND createTime &gt;= #{logStartTime}
            </if>
            <if test="logEndTime!=null and logEndTime != '' ">
                AND createTime &lt;= #{logEndTime}
            </if>
            <if test="operateType!=null">
                AND operate = #{operateType}
            </if>
        </where>
        order by createTime desc
        LIMIT #{currentPage},#{items}
    </select>
    <select id="selectCountByCondition" resultType="java.lang.Long">
        SELECT
        count(id)
        FROM
        t_iccard_log
        <where>
            type = 0
            <if test="logStartTime!=null and logStartTime!=''">
                and createTime &gt;= #{logStartTime}
            </if>
            <if test="logEndTime!=null and logEndTime != ''">
                AND createTime &lt;= #{logEndTime}
            </if>
            <if test="operateType!=null">
                AND operate = #{operateType}
            </if>
        </where>
    </select>
    <select id="selectDeviceLogListByCondition" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        t_iccard_log
        WHERE
        type = 1
        <if test="operateType!=null">
            AND operate = #{operateType}
        </if>
        <if test="logStartTime!=null and logStartTime!='' ">
            AND createTime &gt;= #{logStartTime}
        </if>
        <if test="logEndTime!=null and logEndTime!='' ">
            AND createTime &lt;= #{logEndTime}
        </if>
        order by createTime desc
        limit #{currentPage},#{items}
    </select>
    <select id="selectCountOfDeviceLogListByCondition" resultType="java.lang.Long">
        SELECT
        count(id)
        FROM
        t_iccard_log
        WHERE
        type = 1
        <if test="operateType!=null">
            AND operate = #{operateType}
        </if>
        <if test="logStartTime!=null and logStartTime!='' ">
            AND createTime &gt;= #{logStartTime}
        </if>
        <if test="logEndTime!=null and logEndTime!='' ">
            AND createTime &lt;= #{logEndTime}
        </if>
    </select>
    <select id="selectRechargeLogByUniqueId" resultMap="BaseResultMap"
            parameterType="com.xhpc.card.domain.QueryRechargingRecordRequest">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        t_iccard_log
        WHERE
        type = 0
        and operate = 2
        and uniqueID = #{uniqueId}
        limit #{currentPage},#{items}
    </select>
    <select id="selectCountRechargeLogByUniqueId" resultType="java.lang.Long">
        SELECT count(id)
        FROM t_iccard_log
        WHERE operate = 2
          and uniqueID = #{uniqueId}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete
        from t_iccard_log
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xhpc.card.pojo.TIccardLog"
            useGeneratedKeys="true">
        insert into t_iccard_log (uniqueID, `type`, operate,
                                  operatorId, log, createTime)
        values (#{uniqueid,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{operate,jdbcType=TINYINT},
                #{operatorid,jdbcType=INTEGER}, #{log,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.xhpc.card.pojo.TIccardLog"
            useGeneratedKeys="true">
        insert into t_iccard_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uniqueid != null">
                uniqueID,
            </if>
            <if test="type != null">
                `type`,
            </if>
            <if test="operate != null">
                operate,
            </if>
            <if test="operatorid != null">
                operatorId,
            </if>
            <if test="log != null">
                log,
            </if>
            <if test="createtime != null">
                createTime,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="uniqueid != null">
                #{uniqueid,jdbcType=VARCHAR},
            </if>
            <if test="type != null">
                #{type,jdbcType=TINYINT},
            </if>
            <if test="operate != null">
                #{operate,jdbcType=TINYINT},
            </if>
            <if test="operatorid != null">
                #{operatorid,jdbcType=INTEGER},
            </if>
            <if test="log != null">
                #{log,jdbcType=VARCHAR},
            </if>
            <if test="createtime != null">
                #{createtime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.TIccardLog">
        update t_iccard_log
        <set>
            <if test="uniqueid != null">
                uniqueID = #{uniqueid,jdbcType=VARCHAR},
            </if>
            <if test="type != null">
                `type` = #{type,jdbcType=TINYINT},
            </if>
            <if test="operate != null">
                operate = #{operate,jdbcType=TINYINT},
            </if>
            <if test="operatorid != null">
                operatorId = #{operatorid,jdbcType=INTEGER},
            </if>
            <if test="log != null">
                log = #{log,jdbcType=VARCHAR},
            </if>
            <if test="createtime != null">
                createTime = #{createtime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.TIccardLog">
        update t_iccard_log
        set uniqueID   = #{uniqueid,jdbcType=VARCHAR},
            `type`     = #{type,jdbcType=TINYINT},
            operate    = #{operate,jdbcType=TINYINT},
            operatorId = #{operatorid,jdbcType=INTEGER},
            log        = #{log,jdbcType=VARCHAR},
            createTime = #{createtime,jdbcType=TIMESTAMP}
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>