<?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.ruoyi.model.mapper.AppletUsersTeacherMapper">
    
    <resultMap type="AppletUsersTeacher" id="AppletUsersTeacherResult">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="name" column="name"/>
        <result property="idCard" column="id_card"/>
        <result property="sex" column="sex"/>
        <result property="phone" column="phone"/>
        <result property="experience" column="experience"/>
        <result property="isHave" column="is_have"/>
        <result property="petType" column="pet_type"/>
        <result property="status" column="status"/>
        <result property="images" column="images"/>
        <result property="createTime" column="create_time"/>
        <result property="area" column="area"/>
        <result property="updateTime" column="update_time"/>
        <result property="address" column="address"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="age" column="age"/>
        <result property="license" column="license"/>

        <result property="userBrief" column="user_brief"/>
        <result property="thumbsUp" column="thumbs_up"/>
    </resultMap>

    <sql id="selectAppletUsersTeacherVo">
        select id, user_id, name, id_card, sex, phone, experience, is_have, pet_type, status, images, create_time, area, update_time, address, longitude, latitude, create_by, update_by, age, license, user_brief, thumbs_up  from applet_users_teacher
    </sql>

    <select id="selectAppletUsersTeacherList" parameterType="AppletUsersTeacher" resultMap="AppletUsersTeacherResult">
        <include refid="selectAppletUsersTeacherVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
            <if test="sex != null "> and sex = #{sex}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="experience != null  and experience != ''"> and experience = #{experience}</if>
            <if test="isHave != null "> and is_have = #{isHave}</if>
            <if test="petType != null "> and pet_type = #{petType}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="images != null  and images != ''"> and images = #{images}</if>
            <if test="area != null  and area != ''"> and area = #{area}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
            <if test="age != null "> and age = #{age}</if>
            <if test="license != null  and license != ''"> and license = #{license}</if>
            <if test="userBrief != null  and userBrief != ''"> and user_brief = #{userBrief}</if>
            <if test="thumbsUp != null "> and thumbs_up = #{thumbsUp}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectAppletUsersTeacherById" parameterType="AppletUsersTeacher" resultMap="AppletUsersTeacherResult">
        <include refid="selectAppletUsersTeacherVo"/>
        where id = #{id}
    </select>
    <select id="selectAppletUsersTeacherByUserId" parameterType="AppletUsersTeacher" resultMap="AppletUsersTeacherResult">
        <include refid="selectAppletUsersTeacherVo"/>
        where user_id = #{userId}
    </select>


    <insert id="insertAppletUsersTeacher" parameterType="AppletUsersTeacher">
        insert into applet_users_teacher
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="name != null">name,</if>
            <if test="idCard != null">id_card,</if>
            <if test="sex != null">sex,</if>
            <if test="phone != null">phone,</if>
            <if test="experience != null">experience,</if>
            <if test="isHave != null">is_have,</if>
            <if test="petType != null">pet_type,</if>
            <if test="status != null">status,</if>
            <if test="images != null">images,</if>
            <if test="createTime != null">create_time,</if>
            <if test="area != null">area,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="address != null">address,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="age != null">age,</if>
            <if test="license != null">license,</if>
            <if test="userBrief != null">user_brief,</if>
            <if test="thumbsUp != null">thumbs_up,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="name != null">#{name},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="sex != null">#{sex},</if>
            <if test="phone != null">#{phone},</if>
            <if test="experience != null">#{experience},</if>
            <if test="isHave != null">#{isHave},</if>
            <if test="petType != null">#{petType},</if>
            <if test="status != null">#{status},</if>
            <if test="images != null">#{images},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="area != null">#{area},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="address != null">#{address},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="age != null">#{age},</if>
            <if test="license != null">#{license},</if>
            <if test="userBrief != null">user_brief,</if>
            <if test="thumbsUp != null">thumbs_up,</if>
        </trim>
    </insert>

    <update id="updateAppletUsersTeacher" parameterType="AppletUsersTeacher">
        update applet_users_teacher
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="experience != null">experience = #{experience},</if>
            <if test="isHave != null">is_have = #{isHave},</if>
            <if test="petType != null">pet_type = #{petType},</if>
            <if test="status != null">status = #{status},</if>
            <if test="images != null">images = #{images},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="area != null">area = #{area},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="address != null">address = #{address},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="age != null">age = #{age},</if>
            <if test="license != null">license = #{license},</if>
            <if test="userBrief != null">user_brief = #{userBrief},</if>
            <if test="thumbsUp != null">thumbs_up = #{thumbsUp},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppletUsersTeacherById" parameterType="Long">
        delete from applet_users_teacher where id = #{id}
    </delete>

    <delete id="deleteAppletUsersTeacherByIds" parameterType="String">
        delete from applet_users_teacher where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>