<?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.system.mapper.SysScenicMapper">
    
    <resultMap type="SysScenic" id="SysScenicResult">
        <result property="scenicId"    column="scenic_id"    />
        <result property="cityId"    column="city_id"    />
        <result property="city"    column="city"    />
        <result property="scenic"    column="scenic"    />
        <result property="preview"    column="preview"    />
    </resultMap>

    <sql id="selectSysScenicVo">
        select scenic_id, city_id, city, scenic, preview from sys_scenic
    </sql>

    <select id="selectSysScenicList" parameterType="SysScenic" resultMap="SysScenicResult">
        <include refid="selectSysScenicVo"/>
        <where>  
            <if test="cityId != null "> and city_id = #{cityId}</if>
            <if test="city != null  and city != ''"> and city = #{city}</if>
            <if test="scenic != null  and scenic != ''"> and scenic = #{scenic}</if>
        </where>
    </select>
    
    <select id="selectSysScenicByScenicId" parameterType="Long" resultMap="SysScenicResult">
        <include refid="selectSysScenicVo"/>
        where scenic_id = #{scenicId}
    </select>
        
    <insert id="insertSysScenic" parameterType="SysScenic" useGeneratedKeys="true" keyProperty="scenicId">
        insert into sys_scenic
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cityId != null">city_id,</if>
            <if test="city != null and city != ''">city,</if>
            <if test="scenic != null and scenic != ''">scenic,</if>
            <if test="preview != null and preview != ''">preview,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cityId != null">#{cityId},</if>
            <if test="city != null and city != ''">#{city},</if>
            <if test="scenic != null and scenic != ''">#{scenic},</if>
            <if test="preview != null and preview != ''">#{preview},</if>
         </trim>
    </insert>

    <update id="updateSysScenic" parameterType="SysScenic">
        update sys_scenic
        <trim prefix="SET" suffixOverrides=",">
            <if test="cityId != null">city_id = #{cityId},</if>
            <if test="city != null and city != ''">city = #{city},</if>
            <if test="scenic != null and scenic != ''">scenic = #{scenic},</if>
            <if test="preview != null and preview != ''">preview = #{preview},</if>
        </trim>
        where scenic_id = #{scenicId}
    </update>

    <delete id="deleteSysScenicByScenicId" parameterType="Long">
        delete from sys_scenic where scenic_id = #{scenicId}
    </delete>

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