<?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.liquidnet.service.smile.mapper.SmileUserMapper">

    <resultMap id="smileUserCheckDao" type="com.liquidnet.service.smile.entity.dao.SmileUserCheckDao">
        <result column="uid" property="uid"/>
        <result column="img" property="img"/>
        <result column="name" property="name"/>
        <result column="birthday" property="birthday"/>
        <result column="sex" property="sex"/>
        <result column="province_id" property="provinceId"/>
        <result column="province" property="province"/>
        <result column="city_id" property="cityId"/>
        <result column="city" property="city"/>
        <result column="area_id" property="areaId"/>
        <result column="area" property="area"/>
        <result column="address" property="address"/>
        <result column="state" property="state"/>
    </resultMap>

    <select id="strip" resultType="Integer">
        select count from smile_user where org_id = #{orgId};
    </select>

    <select id="selectUserNameById" resultType="String">
        select name from  smile_user where id = #{id};
    </select>

    <update id="updateUserSchoolBySchoolId">
        update smile_user set school_name = #{schoolName}  where school_id = #{schoolId};
    </update>

    <select id="selectUserList" parameterType="java.util.Map" resultType="com.liquidnet.service.smile.entity.SmileUser">
        select * from smile_user
        <where>
            <if test="phone!=''">
                AND phone Like concat('%',#{phone},'%')
            </if>
        </where>
    </select>

    <select id="selectUserCheck" parameterType="java.util.Map" resultMap="smileUserCheckDao">
        SELECT
            su.uid,
            su.img,
            su.`NAME`,
            su.birthday,
            su.sex,
            su.phone,
            su.identity,
            su.school_name,
            su.province_id,
            su.province,
            su.city_id,
            su.city,
            su.area_id,
            su.area,
            su.address,
            suc.`state`
        FROM
            smile_user su,
            smile_user_check suc
        WHERE
            su.uid = suc.uid
        <where>
            <if test="phone!=''">
                AND phone like concat('%',#{phone},'%')
            </if>
        </where>

    </select>
</mapper>
