<?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.github.wxiaoqi.security.admin.mapper.AppUserDetailMapper">
  <resultMap id="AppUserVoMap" type="com.github.wxiaoqi.security.admin.vo.AppUserVo">
    <result column="id" property="id" />
    <result column="userid" property="userid" />
    <result column="im_userid" property="imUserid" />
    <result column="username" property="username" />
    <result column="wx_openid"  property="wxOpenid" />
    <result column="unionid"  property="unionid" />
    <result column="openid"  property="openid" />
    <result column="status"  property="status" />
    <result column="id_number"  property="idNumber" />
    <result column="certification_status"  property="certificationStatus" />
    <result column="is_member"  property="isMember" />
    <result column="nickname"  property="nickname" />
    <result column="realname"  property="realname" />
    <result column="headimgurl"  property="headimgurl" />
    <result column="birthday"  property="birthday" />
    <result column="email"  property="email" />
    <result column="sex"  property="sex" />
    <result column="person_sign"  property="personSign" />
    <result column="remark" property="remark" />
  </resultMap>


  <!--  获取用户信息 -->
  <select id="getUserInfo" resultMap="AppUserVoMap">
    select l.im_userid,l.username,l.wx_openid,l.unionid,l.openid,l.status,l.id_number,l.certification_status,d.*  from app_user_login l
    left join  app_user_detail d
    on d.userid = l.id
     where d.userid = #{userId}  limit 1
  </select>

  <select id="selectAppUserManage" parameterType="Integer" resultMap="AppUserVoMap">
    select l.im_userid,l.username,l.wx_openid,l.unionid,l.openid,l.status,l.id_number,l.certification_status,d.*  from app_user_login l
    left join  app_user_detail d
    on d.userid = l.id where 1=1

      <if test="id != null">
        and  d.id =#{id}
      </if>

      <if test="userid != null" >
        and d.userid = #{userId}
      </if>

    <if test="username != null" >
      and l.username=#{username}
    </if>


    <if test="imUserd != null" >
      and l.im_userid=#{imUserid}
    </if>

    <if test="wxOpenid != null" >
      and l.wx_openid=#{wxOpenid}
    </if>

    <if test="unionid != null" >
      and l.unionid=#{unionid}
    </if>

    <if test="openid != null" >
      and l.openid=#{openid}
    </if>

    <if test="status != null" >
      and l.status=#{status}
    </if>

    <if test="idNumber != null" >
      and l.id_number=#{idNumber}
    </if>

    <if test="certificationStatus != null" >
      and l.certification_status=#{certificationStatus}
    </if>

    <if test="isMember != null" >
      and d.is member=#{isMember}
    </if>

    <if test="nickname != null" >
      and d.nickname=#{nickname}
    </if>

    <if test="realname != null" >
      and d.realname=#{realname}
    </if>

    <if test="email != null" >
      and d.email=#{email}
    </if>

    <if test="sex != null" >
      and d.sex=#{sex}
    </if>


    <if test="birthday != null" >
      and d.birthday=#{birthday}
    </if>


    <if test="personSign != null" >
      and d.person_sign=#{personSign}
    </if>

    <if test="remark != null" >
      and d.remark=#{remark}
    </if>


  </select>


</mapper>