<?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.ssm.mapper.system.SysUserMapper" >
  <resultMap id="BaseResultMap" type="com.ssm.model.system.SysUser" >
    <id column="UserID" property="userid" jdbcType="INTEGER" />
    <result column="UserName" property="username" jdbcType="VARCHAR" />
    <result column="UserNameEN" property="usernameen" jdbcType="VARCHAR" />
    <result column="EmployeeNo" property="employeeno" jdbcType="VARCHAR" />
    <result column="Gender" property="gender" jdbcType="VARCHAR" />
    <result column="Password" property="password" jdbcType="VARCHAR" />
<!--  <result column="DepID" property="depid" jdbcType="INTEGER" />  --> 
<!--  <result column="PositionID" property="positionid" jdbcType="INTEGER" />  -->  
    <result column="PhoneNumber" property="phonenumber" jdbcType="VARCHAR" />
    <result column="MobileNumber" property="mobilenumber" jdbcType="VARCHAR" />
    <result column="EmailAddress" property="emailaddress" jdbcType="VARCHAR" />
    <result column="Area" property="area" jdbcType="VARCHAR" />
    <result column="LineManagerID" property="linemanagerid" jdbcType="VARCHAR" />
    <result column="Entrydate" property="entrydate" jdbcType="TIMESTAMP" />
    <result column="BirthDay" property="birthday" jdbcType="TIMESTAMP" />
    <result column="HeadImageUrl" property="headimageurl" jdbcType="VARCHAR" />
    <result column="OwnedCompany" property="ownedcompany" jdbcType="VARCHAR" />
    <result column="WorkLocation" property="worklocation" jdbcType="VARCHAR" />
    <result column="Address" property="address" jdbcType="VARCHAR" />
    <result column="LastLoginDate" property="lastlogindate" jdbcType="TIMESTAMP" />
    <result column="LastLoginIP" property="lastloginip" jdbcType="VARCHAR" />
    <result column="LoginCounts" property="logincounts" jdbcType="INTEGER" />
    <result column="IsEnabled" property="isenabled" jdbcType="BIT" />
    <result column="IsDeleted" property="isdeleted" jdbcType="BIT" />
    <result column="CreatedUserID" property="createduserid" jdbcType="INTEGER" />
    <result column="CreatedDatetime" property="createddatetime" jdbcType="TIMESTAMP" />
    <result column="LastUpdateUserID" property="lastupdateuserid" jdbcType="INTEGER" />
    <result column="LastUpdateDatetime" property="lastupdatedatetime" jdbcType="TIMESTAMP" />
    <!-- 会存在N+1问题 , 影响系统效率 -->
 <!-- <association column="PositionID" javaType="com.ssm.model.system.SysPosition"   property="sysPosition"  select="getPosition" />  -->
<!--  <association column="DepID"   property="sysDepartment"  select="getDepartment" />  -->
	<association  javaType="com.ssm.model.system.SysPosition"   
 		property="sysPosition" resultMap="com.ssm.mapper.system.SysPositionMapper.BaseResultMap"  />
 	<association  javaType="com.ssm.model.system.SysDepartment"   
 		property="sysDepartment" resultMap="com.ssm.mapper.system.SysDepartmentMapper.BaseResultMap"  />
 	<collection property="roleList" ofType="com.ssm.model.system.SysRole">
		<id property="roleId" column="roleid" />
		<result property="roleName" column="rolename" />
	</collection>		
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <select id="getPosition" parameterType="int" resultType="com.ssm.model.system.SysPosition">
  	SELECT * FROM SysPosition WHERE PositionID=#{id}
  </select>
  <select id="getDepartment" parameterType="int" resultType="com.ssm.model.system.SysDepartment">
  	SELECT * FROM SysDepartment WHERE DepID=#{id}
  </select>
  <select id="selectPerssion" resultType="int">
  	SELECT count(*) from SysRoleMenu s ,SysUserRole sr , SysMenu sm
	WHERE s.RoleID = sr.RoleID AND sr.UserID=#{userid}
	AND s.MenuID = sm.MenuID  AND sm.IsDelete = 0 AND sm.IsEnable = 0
	AND sm.MenuUrl= #{menuUrl} 
  </select>
  <sql id="Base_Column_List" >
    UserID, UserName, UserNameEN, EmployeeNo, Gender, Password, DepID, PositionID, PhoneNumber, 
    MobileNumber, EmailAddress, Area, LineManagerID, Entrydate, BirthDay, HeadImageUrl, 
    OwnedCompany, WorkLocation, Address, LastLoginDate, LastLoginIP, LoginCounts, IsEnabled, 
    IsDeleted, CreatedUserID, CreatedDatetime, LastUpdateUserID, LastUpdateDatetime
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.ssm.model.system.SysUserExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from SysUser
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  
  <select id="selectByCondition" resultMap="BaseResultMap" parameterType="java.lang.String" >
  	select su.userid, su.username, su.positionid, su.employeeno,
    su.mobilenumber, su.emailaddress,
    sp.positionname,su.isEnabled , sd.DepName 
  	from SysUser su 
  	LEFT JOIN SysPosition sp ON su.PositionID = sp.PositionID
  	LEFT JOIN SysDepartment sd ON su.DepID = sd.DepID

	where su.isDeleted = 0
		<if test="username != null  ">  
			and su.username like CONCAT('%',#{username},'%')
			
	    </if>
	    <if test="employeeno != null  ">  
	    	and su.employeeno like CONCAT('%',#{employeeno},'%')
	    </if>  
    order by su.userid asc
  </select>
  
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from SysUser
    where UserID = #{userid,jdbcType=INTEGER}
  </select>
  
  <select id="findByEmployeeno" resultMap="BaseResultMap" parameterType="java.lang.String">
  	select 
    <include refid="Base_Column_List" />
    from SysUser
    where EmployeeNo = #{employeeno}
  </select>
  
  <select id="findByEmployeenoAndPasswod" resultMap="BaseResultMap" parameterType="java.lang.String">
  	select 
  	<include refid="Base_Column_List" />
    from SysUser
    where EmployeeNo = #{employeeno} and Password = #{password}
  </select>
  
  <update id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    update  SysUser set IsDeleted = 1
    where UserID = #{userid,jdbcType=INTEGER}
  </update>
  <delete id="deleteByExample" parameterType="com.ssm.model.system.SysUserExample" >
    delete from SysUser
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <delete id="deleteUserRole" parameterType="java.lang.Integer">
  	delete from SysUserRole
  	where UserID = #{userid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.ssm.model.system.SysUser" >
    insert into SysUser (UserID, UserName, UserNameEN, 
      EmployeeNo, Gender, Password, 
      DepID, PositionID, PhoneNumber, 
      MobileNumber, EmailAddress, Area, 
      LineManagerID, Entrydate, BirthDay, 
      HeadImageUrl, OwnedCompany, WorkLocation, 
      Address, LastLoginDate, LastLoginIP,  
      LoginCounts, IsEnabled, IsDeleted, 
      CreatedUserID, CreatedDatetime, LastUpdateUserID, 
      LastUpdateDatetime)
    values (#{userid,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{usernameen,jdbcType=VARCHAR}, 
      #{employeeno,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, 
      #{sysDepartment.depid,jdbcType=INTEGER}, #{sysPosition.positionid,jdbcType=INTEGER}, #{phonenumber,jdbcType=VARCHAR}, 
      #{mobilenumber,jdbcType=VARCHAR}, #{emailaddress,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR}, 
      #{linemanagerid,jdbcType=VARCHAR}, #{entrydate,jdbcType=TIMESTAMP}, #{birthday,jdbcType=TIMESTAMP}, 
      #{headimageurl,jdbcType=VARCHAR}, #{ownedcompany,jdbcType=VARCHAR}, #{worklocation,jdbcType=VARCHAR}, 
      #{address,jdbcType=VARCHAR}, #{lastlogindate,jdbcType=TIMESTAMP}, #{lastloginip,jdbcType=VARCHAR}, 
      #{logincounts,jdbcType=INTEGER}, #{isenabled,jdbcType=BIT}, #{isdeleted,jdbcType=BIT}, 
      #{createduserid,jdbcType=INTEGER}, #{createddatetime,jdbcType=TIMESTAMP}, #{lastupdateuserid,jdbcType=INTEGER}, 
      #{lastupdatedatetime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.ssm.model.system.SysUser" >
 	<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="userid">
		 SELECT LAST_INSERT_ID()
	</selectKey>
    insert into SysUser
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="userid != null" >
        UserID,
      </if>
      <if test="username != null" >
        UserName,
      </if>
      <if test="usernameen != null" >
        UserNameEN,
      </if>
      <if test="employeeno != null" >
        EmployeeNo,
      </if>
      <if test="gender != null" >
        Gender,
      </if>
      <if test="password != null" >
        Password,
      </if>
      <if test="sysDepartment != null and sysDepartment.depid != null" >
        DepID,
      </if>
      <if test="sysPosition != null and sysPosition.positionid != null" >
        PositionID,
      </if>
      <if test="phonenumber != null" >
        PhoneNumber,
      </if>
      <if test="mobilenumber != null" >
        MobileNumber,
      </if>
      <if test="emailaddress != null" >
        EmailAddress,
      </if>
      <if test="area != null" >
        Area,
      </if>
      <if test="linemanagerid != null" >
        LineManagerID,
      </if>
      <if test="entrydate != null" >
        Entrydate,
      </if>
      <if test="birthday != null" >
        BirthDay,
      </if>
      <if test="headimageurl != null" >
        HeadImageUrl,
      </if>
      <if test="ownedcompany != null" >
        OwnedCompany,
      </if>
      <if test="worklocation != null" >
        WorkLocation,
      </if>
      <if test="address != null" >
        Address,
      </if>
      <if test="lastlogindate != null" >
        LastLoginDate,
      </if>
      <if test="lastloginip != null" >
        LastLoginIP,
      </if>
      <if test="logincounts != null" >
        LoginCounts,
      </if>
      <if test="isenabled != null" >
        IsEnabled,
      </if>
      <if test="isdeleted != null" >
        IsDeleted,
      </if>
      <if test="createduserid != null" >
        CreatedUserID,
      </if>
      <if test="createddatetime != null" >
        CreatedDatetime,
      </if>
      <if test="lastupdateuserid != null" >
        LastUpdateUserID,
      </if>
      <if test="lastupdatedatetime != null" >
        LastUpdateDatetime,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="userid != null" >
        #{userid,jdbcType=INTEGER},
      </if>
      <if test="username != null" >
        #{username,jdbcType=VARCHAR},
      </if>
      <if test="usernameen != null" >
        #{usernameen,jdbcType=VARCHAR},
      </if>
      <if test="employeeno != null" >
        #{employeeno,jdbcType=VARCHAR},
      </if>
      <if test="gender != null" >
        #{gender,jdbcType=VARCHAR},
      </if>
      <if test="password != null" >
        #{password,jdbcType=VARCHAR},
      </if>
      <if test="sysDepartment != null and  sysDepartment.depid != null" >
        #{sysDepartment.depid,jdbcType=INTEGER},
      </if>
      <if test="sysPosition != null and sysPosition.positionid != null" >
        #{sysPosition.positionid,jdbcType=INTEGER},
      </if>
      <if test="phonenumber != null" >
        #{phonenumber,jdbcType=VARCHAR},
      </if>
      <if test="mobilenumber != null" >
        #{mobilenumber,jdbcType=VARCHAR},
      </if>
      <if test="emailaddress != null" >
        #{emailaddress,jdbcType=VARCHAR},
      </if>
      <if test="area != null" >
        #{area,jdbcType=VARCHAR},
      </if>
      <if test="linemanagerid != null" >
        #{linemanagerid,jdbcType=VARCHAR},
      </if>
      <if test="entrydate != null" >
        #{entrydate,jdbcType=TIMESTAMP},
      </if>
      <if test="birthday != null" >
        #{birthday,jdbcType=TIMESTAMP},
      </if>
      <if test="headimageurl != null" >
        #{headimageurl,jdbcType=VARCHAR},
      </if>
      <if test="ownedcompany != null" >
        #{ownedcompany,jdbcType=VARCHAR},
      </if>
      <if test="worklocation != null" >
        #{worklocation,jdbcType=VARCHAR},
      </if>
      <if test="address != null" >
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="lastlogindate != null" >
        #{lastlogindate,jdbcType=TIMESTAMP},
      </if>
      <if test="lastloginip != null" >
        #{lastloginip,jdbcType=VARCHAR},
      </if>
      <if test="logincounts != null" >
        #{logincounts,jdbcType=INTEGER},
      </if>
      <if test="isenabled != null" >
        #{isenabled,jdbcType=BIT},
      </if>
      <if test="isdeleted != null" >
        #{isdeleted,jdbcType=BIT},
      </if>
      <if test="createduserid != null" >
        #{createduserid,jdbcType=INTEGER},
      </if>
      <if test="createddatetime != null" >
        #{createddatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="lastupdateuserid != null" >
        #{lastupdateuserid,jdbcType=INTEGER},
      </if>
      <if test="lastupdatedatetime != null" >
        #{lastupdatedatetime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <insert id="insertUserRole" parameterType="java.lang.Integer">
  	insert into SysUserRole(UserID, RoleID)
  	values(#{userid,jdbcType=INTEGER}, #{roleid, jdbcType=INTEGER})
  </insert>
  <select id="countByExample" parameterType="com.ssm.model.system.SysUserExample" resultType="java.lang.Integer" >
    select count(*) from SysUser
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update SysUser
    <set >
      <if test="record.userid != null" >
        UserID = #{record.userid,jdbcType=INTEGER},
      </if>
      <if test="record.username != null" >
        UserName = #{record.username,jdbcType=VARCHAR},
      </if>
      <if test="record.usernameen != null" >
        UserNameEN = #{record.usernameen,jdbcType=VARCHAR},
      </if>
      <if test="record.employeeno != null" >
        EmployeeNo = #{record.employeeno,jdbcType=VARCHAR},
      </if>
      <if test="record.gender != null" >
        Gender = #{record.gender,jdbcType=VARCHAR},
      </if>
      <if test="record.password != null" >
        Password = #{record.password,jdbcType=VARCHAR},
      </if>
      <if test="record.depid != null" >
        DepID = #{record.depid,jdbcType=INTEGER},
      </if>
      <if test="record.positionid != null" >
        PositionID = #{record.positionid,jdbcType=INTEGER},
      </if>
      <if test="record.phonenumber != null" >
        PhoneNumber = #{record.phonenumber,jdbcType=VARCHAR},
      </if>
      <if test="record.mobilenumber != null" >
        MobileNumber = #{record.mobilenumber,jdbcType=VARCHAR},
      </if>
      <if test="record.emailaddress != null" >
        EmailAddress = #{record.emailaddress,jdbcType=VARCHAR},
      </if>
      <if test="record.area != null" >
        Area = #{record.area,jdbcType=VARCHAR},
      </if>
      <if test="record.linemanagerid != null" >
        LineManagerID = #{record.linemanagerid,jdbcType=VARCHAR},
      </if>
      <if test="record.entrydate != null" >
        Entrydate = #{record.entrydate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.birthday != null" >
        BirthDay = #{record.birthday,jdbcType=TIMESTAMP},
      </if>
      <if test="record.headimageurl != null" >
        HeadImageUrl = #{record.headimageurl,jdbcType=VARCHAR},
      </if>
      <if test="record.ownedcompany != null" >
        OwnedCompany = #{record.ownedcompany,jdbcType=VARCHAR},
      </if>
      <if test="record.worklocation != null" >
        WorkLocation = #{record.worklocation,jdbcType=VARCHAR},
      </if>
      <if test="record.address != null" >
        Address = #{record.address,jdbcType=VARCHAR},
      </if>
      <if test="record.lastlogindate != null" >
        LastLoginDate = #{record.lastlogindate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.lastloginip != null" >
        LastLoginIP = #{record.lastloginip,jdbcType=VARCHAR},
      </if>
      <if test="record.logincounts != null" >
        LoginCounts = #{record.logincounts,jdbcType=INTEGER},
      </if>
      <if test="record.isenabled != null" >
        IsEnabled = #{record.isenabled,jdbcType=BIT},
      </if>
      <if test="record.isdeleted != null" >
        IsDeleted = #{record.isdeleted,jdbcType=BIT},
      </if>
      <if test="record.createduserid != null" >
        CreatedUserID = #{record.createduserid,jdbcType=INTEGER},
      </if>
      <if test="record.createddatetime != null" >
        CreatedDatetime = #{record.createddatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.lastupdateuserid != null" >
        LastUpdateUserID = #{record.lastupdateuserid,jdbcType=INTEGER},
      </if>
      <if test="record.lastupdatedatetime != null" >
        LastUpdateDatetime = #{record.lastupdatedatetime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update SysUser
    set UserID = #{record.userid,jdbcType=INTEGER},
      UserName = #{record.username,jdbcType=VARCHAR},
      UserNameEN = #{record.usernameen,jdbcType=VARCHAR},
      EmployeeNo = #{record.employeeno,jdbcType=VARCHAR},
      Gender = #{record.gender,jdbcType=VARCHAR},
      Password = #{record.password,jdbcType=VARCHAR},
      DepID = #{record.depid,jdbcType=INTEGER},
      PositionID = #{record.positionid,jdbcType=INTEGER},
      PhoneNumber = #{record.phonenumber,jdbcType=VARCHAR},
      MobileNumber = #{record.mobilenumber,jdbcType=VARCHAR},
      EmailAddress = #{record.emailaddress,jdbcType=VARCHAR},
      Area = #{record.area,jdbcType=VARCHAR},
      LineManagerID = #{record.linemanagerid,jdbcType=VARCHAR},
      Entrydate = #{record.entrydate,jdbcType=TIMESTAMP},
      BirthDay = #{record.birthday,jdbcType=TIMESTAMP},
      HeadImageUrl = #{record.headimageurl,jdbcType=VARCHAR},
      OwnedCompany = #{record.ownedcompany,jdbcType=VARCHAR},
      WorkLocation = #{record.worklocation,jdbcType=VARCHAR},
      Address = #{record.address,jdbcType=VARCHAR},
      LastLoginDate = #{record.lastlogindate,jdbcType=TIMESTAMP},
      LastLoginIP = #{record.lastloginip,jdbcType=VARCHAR},
      LoginCounts = #{record.logincounts,jdbcType=INTEGER},
      IsEnabled = #{record.isenabled,jdbcType=BIT},
      IsDeleted = #{record.isdeleted,jdbcType=BIT},
      CreatedUserID = #{record.createduserid,jdbcType=INTEGER},
      CreatedDatetime = #{record.createddatetime,jdbcType=TIMESTAMP},
      LastUpdateUserID = #{record.lastupdateuserid,jdbcType=INTEGER},
      LastUpdateDatetime = #{record.lastupdatedatetime,jdbcType=TIMESTAMP}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.ssm.model.system.SysUser" >
    update SysUser
    <set >
      <if test="username != null" >
        UserName = #{username,jdbcType=VARCHAR},
      </if>
      <if test="usernameen != null" >
        UserNameEN = #{usernameen,jdbcType=VARCHAR},
      </if>
      <if test="employeeno != null" >
        EmployeeNo = #{employeeno,jdbcType=VARCHAR},
      </if>
      <if test="gender != null" >
        Gender = #{gender,jdbcType=VARCHAR},
      </if>
      <if test="password != null" >
        Password = #{password,jdbcType=VARCHAR},
      </if>
      <if test="sysDepartment != null and sysDepartment.depid != null" >
        DepID = #{sysDepartment.depid,jdbcType=INTEGER},
      </if>
      <if test="sysPosition!=null and sysPosition.positionid != null" >
        PositionID = #{sysPosition.positionid,jdbcType=INTEGER},
      </if>
      <if test="phonenumber != null" >
        PhoneNumber = #{phonenumber,jdbcType=VARCHAR},
      </if>
      <if test="mobilenumber != null" >
        MobileNumber = #{mobilenumber,jdbcType=VARCHAR},
      </if>
      <if test="emailaddress != null" >
        EmailAddress = #{emailaddress,jdbcType=VARCHAR},
      </if>
      <if test="area != null" >
        Area = #{area,jdbcType=VARCHAR},
      </if>
      <if test="linemanagerid != null" >
        LineManagerID = #{linemanagerid,jdbcType=VARCHAR},
      </if>
      <if test="entrydate != null" >
        Entrydate = #{entrydate,jdbcType=TIMESTAMP},
      </if>
      <if test="birthday != null" >
        BirthDay = #{birthday,jdbcType=TIMESTAMP},
      </if>
      <if test="headimageurl != null" >
        HeadImageUrl = #{headimageurl,jdbcType=VARCHAR},
      </if>
      <if test="ownedcompany != null" >
        OwnedCompany = #{ownedcompany,jdbcType=VARCHAR},
      </if>
      <if test="worklocation != null" >
        WorkLocation = #{worklocation,jdbcType=VARCHAR},
      </if>
      <if test="address != null" >
        Address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="lastlogindate != null" >
        LastLoginDate = #{lastlogindate,jdbcType=TIMESTAMP},
      </if>
      <if test="lastloginip != null" >
        LastLoginIP = #{lastloginip,jdbcType=VARCHAR},
      </if>
      <if test="logincounts != null" >
        LoginCounts = #{logincounts,jdbcType=INTEGER},
      </if>
      <if test="isenabled != null" >
        IsEnabled = #{isenabled,jdbcType=BIT},
      </if>
      <if test="isdeleted != null" >
        IsDeleted = #{isdeleted,jdbcType=BIT},
      </if>
      <if test="createduserid != null" >
        CreatedUserID = #{createduserid,jdbcType=INTEGER},
      </if>
      <if test="createddatetime != null" >
        CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="lastupdateuserid != null" >
        LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
      </if>
      <if test="lastupdatedatetime != null" >
        LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where UserID = #{userid,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ssm.model.system.SysUser" >
    update SysUser
    set UserName = #{username,jdbcType=VARCHAR},
      UserNameEN = #{usernameen,jdbcType=VARCHAR},
      EmployeeNo = #{employeeno,jdbcType=VARCHAR},
      Gender = #{gender,jdbcType=VARCHAR},
      Password = #{password,jdbcType=VARCHAR},
      DepID = #{sysDepartment.depid,jdbcType=INTEGER},
      PositionID = #{sysPosition.positionid,jdbcType=INTEGER},
      PhoneNumber = #{phonenumber,jdbcType=VARCHAR},
      MobileNumber = #{mobilenumber,jdbcType=VARCHAR},
      EmailAddress = #{emailaddress,jdbcType=VARCHAR},
      Area = #{area,jdbcType=VARCHAR},
      LineManagerID = #{linemanagerid,jdbcType=VARCHAR},
      Entrydate = #{entrydate,jdbcType=TIMESTAMP},
      BirthDay = #{birthday,jdbcType=TIMESTAMP},
      HeadImageUrl = #{headimageurl,jdbcType=VARCHAR},
      OwnedCompany = #{ownedcompany,jdbcType=VARCHAR},
      WorkLocation = #{worklocation,jdbcType=VARCHAR},
      Address = #{address,jdbcType=VARCHAR},
      LastLoginDate = #{lastlogindate,jdbcType=TIMESTAMP},
      LastLoginIP = #{lastloginip,jdbcType=VARCHAR},
      LoginCounts = #{logincounts,jdbcType=INTEGER},
      IsEnabled = #{isenabled,jdbcType=BIT},
      IsDeleted = #{isdeleted,jdbcType=BIT},
      CreatedUserID = #{createduserid,jdbcType=INTEGER},
      CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
      LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
      LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP}
    where UserID = #{userid,jdbcType=INTEGER}
  </update>
  <select id="selectAllUser" resultMap="BaseResultMap">
  	SELECT * from SysUser s where s.IsDeleted = 0 AND s.IsEnabled = 0
  </select>
  <select id="selectUserRoleByUserIdAndRoldId" resultType="java.lang.Integer">
  	select COUNT(ssr.ID) from sysuserrole ssr where UserID=#{userid,jdbcType=INTEGER} and RoleID=#{roldid,jdbcType=INTEGER}
  </select>
</mapper>