<?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.AppUserLoginMapper">

    <select id="selectbyPhones" resultType="com.github.wxiaoqi.security.admin.entity.AppUserLogin">
        select `id`,`username` from `app_user_login` where `username` in
        <foreach collection="phones" item="phone" open="(" close=")" separator=",">
            #{phone}
        </foreach>
    </select>

    <update id="bindOpenId" parameterType="com.github.wxiaoqi.security.admin.entity.AppUserLogin">
        UPDATE  app_user_login SET wx_openid=#{wxOpenid},unionid=#{unionid},openid=#{openid} where  id=#{id}
    </update>

    <select id="selectAllExistUserIds" resultType="integer">
        SELECT  `id` FROM `app_user_login`  WHERE `isdel`=0;
    </select>
    <select id="getUserByUsernameAndRealName" resultType="com.github.wxiaoqi.security.admin.entity.AppUserLogin">
        select l.* from app_user_login l left  join app_user_detail d on l.id=d.userid where 1=1

        <if test="username!=null ">
         and   l.username like concat('%',#{username},'%')
        </if>

        <if test="realName !=null">
            and   d.realname like concat('%',#{realName},'%')
        </if>
    </select>
</mapper>