<?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.AppTouristMapper">
    
    <resultMap type="AppTourist" id="AppTouristResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="icon"    column="icon"    />
    </resultMap>

    <sql id="selectAppTouristVo">
        select id, name, icon from app_tourist
    </sql>

    <select id="selectAppTouristList" parameterType="AppTourist" resultMap="AppTouristResult">
        <include refid="selectAppTouristVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="icon != null  and icon != ''"> and icon = #{icon}</if>
        </where>
    </select>
    
    <select id="selectAppTouristById" parameterType="Long" resultMap="AppTouristResult">
        <include refid="selectAppTouristVo"/>
        where id = #{id}
    </select>
    <select id="getAppTouristLimitOne" resultType="com.ruoyi.model.domain.AppTourist">
        <include refid="selectAppTouristVo"/>
    </select>

    <insert id="insertAppTourist" parameterType="AppTourist">
        insert into app_tourist
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="icon != null">icon,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="icon != null">#{icon},</if>
         </trim>
    </insert>

    <update id="updateAppTourist" parameterType="AppTourist">
        update app_tourist
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="icon != null">icon = #{icon},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppTouristById" parameterType="Long">
        delete from app_tourist where id = #{id}
    </delete>

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