<?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.user.UserMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.user.AclUser">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="user_role" jdbcType="INTEGER" property="userRole" />
    <result column="employee_no" jdbcType="VARCHAR" property="employeeNo" />
    <result column="company" jdbcType="INTEGER" property="company" />
    <result column="dept_id" jdbcType="BIGINT" property="deptId" />
    <result column="role_id" jdbcType="BIGINT" property="roleId" />
    <result column="login" jdbcType="VARCHAR" property="login" />
    <result column="password" jdbcType="VARCHAR" property="password" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="nickname" jdbcType="VARCHAR" property="nickname" />
    <result column="mobile_no" jdbcType="VARCHAR" property="mobileNo" typeHandler="com.yd.util.deshandler.DESTypeHandler"/>
    <result column="id_no" jdbcType="VARCHAR" property="idNo" typeHandler="com.yd.util.deshandler.DESTypeHandler"/>
    <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime" />
    <result column="logout_time" jdbcType="TIMESTAMP" property="logoutTime" />
    <result column="login_source" jdbcType="INTEGER" property="loginSource" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="email" jdbcType="VARCHAR" property="email" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
  </resultMap>
  <sql id="Base_Column_List">
    id, user_role, employee_no, company, dept_id, role_id, login, password, name, nickname, 
    mobile_no, id_no, last_login_time, logout_time, login_source, is_active, email, created_at, 
    created_by, updated_at, updated_by
  </sql>
  <select id="findByIds" resultType="com.yd.dal.entity.user.AclUser"  resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List" />
     from ag_acl_user
     where id in
     <foreach collection="userIdList" index="index" item="item" open="(" separator="," close=")">
       #{item}
     </foreach>
  </select>  
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_acl_user
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_user
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.yd.dal.entity.user.AclUser">
    insert into ag_acl_user (id, user_role, employee_no, 
      company, dept_id, role_id, 
      login, password, name, 
      nickname, mobile_no, id_no, 
      last_login_time, logout_time, login_source, 
      is_active, email, created_at, 
      created_by, updated_at, updated_by
      )
    values (#{id,jdbcType=BIGINT}, #{userRole,jdbcType=INTEGER}, #{employeeNo,jdbcType=VARCHAR}, 
      #{company,jdbcType=INTEGER}, #{deptId,jdbcType=BIGINT}, #{roleId,jdbcType=BIGINT}, 
      #{login,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
      #{nickname,jdbcType=VARCHAR}, #{mobileNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler}, #{idNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler}, 
      #{lastLoginTime,jdbcType=TIMESTAMP}, #{logoutTime,jdbcType=TIMESTAMP}, #{loginSource,jdbcType=INTEGER}, 
      #{isActive,jdbcType=INTEGER}, #{email,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.yd.dal.entity.user.AclUser">
    insert into ag_acl_user
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="userRole != null">
        user_role,
      </if>
      <if test="employeeNo != null">
        employee_no,
      </if>
      <if test="company != null">
        company,
      </if>
      <if test="deptId != null">
        dept_id,
      </if>
      <if test="roleId != null">
        role_id,
      </if>
      <if test="login != null">
        login,
      </if>
      <if test="password != null">
        password,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="nickname != null">
        nickname,
      </if>
      <if test="mobileNo != null">
        mobile_no,
      </if>
      <if test="idNo != null">
        id_no,
      </if>
      <if test="lastLoginTime != null">
        last_login_time,
      </if>
      <if test="logoutTime != null">
        logout_time,
      </if>
      <if test="loginSource != null">
        login_source,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="email != null">
        email,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="userRole != null">
        #{userRole,jdbcType=INTEGER},
      </if>
      <if test="employeeNo != null">
        #{employeeNo,jdbcType=VARCHAR},
      </if>
      <if test="company != null">
        #{company,jdbcType=INTEGER},
      </if>
      <if test="deptId != null">
        #{deptId,jdbcType=BIGINT},
      </if>
      <if test="roleId != null">
        #{roleId,jdbcType=BIGINT},
      </if>
      <if test="login != null">
        #{login,jdbcType=VARCHAR},
      </if>
      <if test="password != null">
        #{password,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="nickname != null">
        #{nickname,jdbcType=VARCHAR},
      </if>
      <if test="mobileNo != null">
        #{mobileNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler},
      </if>
      <if test="idNo != null">
        #{idNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler},
      </if>
      <if test="lastLoginTime != null">
        #{lastLoginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="logoutTime != null">
        #{logoutTime,jdbcType=TIMESTAMP},
      </if>
      <if test="loginSource != null">
        #{loginSource,jdbcType=INTEGER},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="email != null">
        #{email,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.user.AclUser">
    update ag_acl_user
    <set>
      <if test="userRole != null">
        user_role = #{userRole,jdbcType=INTEGER},
      </if>
      <if test="employeeNo != null">
        employee_no = #{employeeNo,jdbcType=VARCHAR},
      </if>
      <if test="company != null">
        company = #{company,jdbcType=INTEGER},
      </if>
      <if test="deptId != null">
        dept_id = #{deptId,jdbcType=BIGINT},
      </if>
      <if test="roleId != null">
        role_id = #{roleId,jdbcType=BIGINT},
      </if>
      <if test="login != null">
        login = #{login,jdbcType=VARCHAR},
      </if>
      <if test="password != null">
        password = #{password,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="nickname != null">
        nickname = #{nickname,jdbcType=VARCHAR},
      </if>
      <if test="mobileNo != null">
        mobile_no = #{mobileNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler},
      </if>
      <if test="idNo != null">
        id_no = #{idNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler},
      </if>
      <if test="lastLoginTime != null">
        last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="logoutTime != null">
        logout_time = #{logoutTime,jdbcType=TIMESTAMP},
      </if>
      <if test="loginSource != null">
        login_source = #{loginSource,jdbcType=INTEGER},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="email != null">
        email = #{email,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.user.AclUser">
    update ag_acl_user
    set user_role = #{userRole,jdbcType=INTEGER},
      employee_no = #{employeeNo,jdbcType=VARCHAR},
      company = #{company,jdbcType=INTEGER},
      dept_id = #{deptId,jdbcType=BIGINT},
      role_id = #{roleId,jdbcType=BIGINT},
      login = #{login,jdbcType=VARCHAR},
      password = #{password,jdbcType=VARCHAR},
      name = #{name,jdbcType=VARCHAR},
      nickname = #{nickname,jdbcType=VARCHAR},
      mobile_no = #{mobileNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler},
      id_no = #{idNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler},
      last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
      logout_time = #{logoutTime,jdbcType=TIMESTAMP},
      login_source = #{loginSource,jdbcType=INTEGER},
      is_active = #{isActive,jdbcType=INTEGER},
      email = #{email,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>