<?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.community.huiju.dao.TaUserMapper" >

  <select id="selectUserApprove" resultType="com.community.huiju.model.TaUser" parameterType="com.community.huiju.model.TaUser">
    SELECT
    t.user_name,
    t.login_name ,
    t.gender ,
    boi.id_card ,
    boi.unit ,
    boi. LEVEL,
    room_no,
    boi.create_date,
    t.verify_status
    FROM
    ta_user t
    LEFT JOIN tp_building_owner_info boi ON t.building_owner_info_id = boi.id
    LEFT JOIN ta_sys_user_role sur ON t.id=sur.user_id
    WHERE
    andsur.role_id=1 and t.status=1 and t.verify_status=1
  </select>

  <select id="selectByTel" resultType="com.community.huiju.model.TaUser">
    select
    *
    from ta_user
    where login_name = #{loginName,jdbcType=VARCHAR}
    and verify_status = 0
  </select>

  <update id="batchUpdate" parameterType="java.util.ArrayList">
    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
      update ta_user
      <set>
        verify_status=${item.verifyStatus},
        building_owner_info_id = #{item.buildingOwnerInfoId}
      </set>
      where id = ${item.id}
    </foreach>
  </update>
  <select id="getUserID" parameterType="map" resultType="integer">
    select id from ta_user where login_name=#{ownerTel,jdbcType=VARCHAR};
  </select>
  <select id="selectUser" parameterType="integer" resultType="com.community.huiju.model.TaUser">
    select
    *
    from ta_user
    where parent_id=#{id,jdbcType=INTEGER};
  </select>

  <update id="batchUpdateRole" parameterType="java.util.ArrayList">
    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
      update ta_sys_user_role
      <set>
        role_id= 1
      </set>
      where user_id = ${item.id} and community_id = ${item.communityId}
    </foreach>
  </update>

  <update id="batchUpdateRole" parameterType="java.util.ArrayList">
    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
      update ta_sys_user_role
      <set>
        role_id= 1
      </set>
      where user_id = ${item.id} and community_id = ${item.communityId}
    </foreach>
  </update>

  <select id="selectLongNameAndcommunityId"  resultType="string">
    select
    user_name
    from ta_user
    where id=#{createUser,jdbcType=VARCHAR}
  </select>

</mapper>