<?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.house365.ws.dao.mapper.WxUserMapper">

    <resultMap id="infoMap" type="com.house365.beans.entity.WxUserEntity">
        <result property="id" column="id"/>
        <result property="wxId" column="wx_id"/>
        <result property="userName" column="user_name"/>
        <result property="department" column="department"/>
        <result property="position" column="position"/>
        <result property="mobile" column="mobile"/>
        <result property="isDelete" column="is_delete"/>
    </resultMap>

    <insert id="save" parameterType="com.house365.beans.entity.WxUserEntity">
        INSERT INTO wx_user (
            wx_id,
            user_name,
            department,
            position,
            mobile,
            is_delete
        )
        VALUES (
            #{wxId},
            #{userName},
            #{department},
            #{position},
            #{mobile},
            #{isDelete}
        )
    </insert>

    <select id="queryByConditions" resultMap="infoMap" parameterType="map">
        SELECT *
        FROM wx_user
        where is_delete = 0
        <if test="userName != null and userName != ''">
            AND user_name LIKE CONCAT('%',#{userName},'%')
        </if>
        <if test="mobile != null and mobile != ''">
            AND mobile = #{mobile}
        </if>
        <if test="wxId != null and wxId != ''">
            AND wx_id = #{wxId}
        </if>
    </select>

</mapper>