<?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.yd.dal.mapper.customer.AclCustomerLogMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AclCustomerLog">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="customer_id" jdbcType="BIGINT" property="customerId" />
    <result column="session_id" jdbcType="VARCHAR" property="sessionId" />
    <result column="from_ip" jdbcType="VARCHAR" property="fromIp" />
    <result column="from_plateform" jdbcType="INTEGER" property="fromPlateform" />
    <result column="from_hostname" jdbcType="VARCHAR" property="fromHostname" />
    <result column="login_time" jdbcType="TIMESTAMP" property="loginTime" />
    <result column="logout_time" jdbcType="TIMESTAMP" property="logoutTime" />
    <result column="is_success" jdbcType="INTEGER" property="isSuccess" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
  </resultMap>
  <sql id="Base_Column_List">
    id, customer_id, session_id, from_ip, from_plateform, from_hostname, login_time, 
    logout_time, is_success, created_at, created_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_acl_customer_log
    where id = #{id,jdbcType=BIGINT}
  </select>

  <select id="findLogInfoByCustomerId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_acl_customer_log
    where customer_id = #{customerId,jdbcType=BIGINT}
  </select>


  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_customer_log
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclCustomerLog" useGeneratedKeys="true">
    insert into ag_acl_customer_log (customer_id, session_id, from_ip, 
      from_plateform, from_hostname, login_time, from_system_name,mobile_no,message,login_name,
      logout_time, is_success, created_at, 
      created_by)
    values (#{customerId,jdbcType=BIGINT}, #{sessionId,jdbcType=VARCHAR}, #{fromIp,jdbcType=VARCHAR}, 
      #{fromPlateform,jdbcType=INTEGER}, #{fromHostname,jdbcType=VARCHAR}, #{loginTime,jdbcType=TIMESTAMP},
       #{fromSystemName,jdbcType=VARCHAR}, #{mobileNo,jdbcType=VARCHAR}, #{message,jdbcType=VARCHAR},#{loginName,jdbcType=VARCHAR},
      #{logoutTime,jdbcType=TIMESTAMP}, #{isSuccess,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP},
      #{createdBy,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclCustomerLog" useGeneratedKeys="true">
    insert into ag_acl_customer_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="sessionId != null">
        session_id,
      </if>
      <if test="fromIp != null">
        from_ip,
      </if>
      <if test="fromPlateform != null">
        from_plateform,
      </if>
      <if test="fromHostname != null">
        from_hostname,
      </if>
      <if test="loginTime != null">
        login_time,
      </if>
      <if test="logoutTime != null">
        logout_time,
      </if>
      <if test="isSuccess != null">
        is_success,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        #{customerId,jdbcType=BIGINT},
      </if>
      <if test="sessionId != null">
        #{sessionId,jdbcType=VARCHAR},
      </if>
      <if test="fromIp != null">
        #{fromIp,jdbcType=VARCHAR},
      </if>
      <if test="fromPlateform != null">
        #{fromPlateform,jdbcType=INTEGER},
      </if>
      <if test="fromHostname != null">
        #{fromHostname,jdbcType=VARCHAR},
      </if>
      <if test="loginTime != null">
        #{loginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="logoutTime != null">
        #{logoutTime,jdbcType=TIMESTAMP},
      </if>
      <if test="isSuccess != null">
        #{isSuccess,jdbcType=INTEGER},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.customer.AclCustomerLog">
    update ag_acl_customer_log
    <set>
      <if test="customerId != null">
        customer_id = #{customerId,jdbcType=BIGINT},
      </if>
      <if test="sessionId != null">
        session_id = #{sessionId,jdbcType=VARCHAR},
      </if>
      <if test="fromIp != null">
        from_ip = #{fromIp,jdbcType=VARCHAR},
      </if>
      <if test="fromPlateform != null">
        from_plateform = #{fromPlateform,jdbcType=INTEGER},
      </if>
      <if test="fromHostname != null">
        from_hostname = #{fromHostname,jdbcType=VARCHAR},
      </if>
      <if test="loginTime != null">
        login_time = #{loginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="logoutTime != null">
        logout_time = #{logoutTime,jdbcType=TIMESTAMP},
      </if>
      <if test="isSuccess != null">
        is_success = #{isSuccess,jdbcType=INTEGER},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.customer.AclCustomerLog">
    update ag_acl_customer_log
    set customer_id = #{customerId,jdbcType=BIGINT},
      session_id = #{sessionId,jdbcType=VARCHAR},
      from_ip = #{fromIp,jdbcType=VARCHAR},
      from_plateform = #{fromPlateform,jdbcType=INTEGER},
      from_hostname = #{fromHostname,jdbcType=VARCHAR},
      login_time = #{loginTime,jdbcType=TIMESTAMP},
      logout_time = #{logoutTime,jdbcType=TIMESTAMP},
      is_success = #{isSuccess,jdbcType=INTEGER},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="findLogInfoByMobileNo" resultType="Long">
    select max(id) from ag_acl_customer_log
    where mobile_no = #{mobileNo,jdbcType=VARCHAR}
  </select>

</mapper>
