<?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.framework.recovery.mapper.RecCityMapper">
    
    <resultMap type="RecCity" id="RecCityResult">
        <result property="id"    column="id"    />
        <result property="city"    column="city"    />
        <result property="createBy"    column="create_by"    />
        <result property="createDate"    column="create_date"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateDate"    column="update_date"    />
    </resultMap>

    <sql id="selectRecCityVo">
        select id, city, create_by, create_date, update_by, update_date from rec_city
    </sql>

    <select id="selectRecCityList" parameterType="RecCity" resultMap="RecCityResult">
        <include refid="selectRecCityVo"/>
        <where>  
            <if test="city != null  and city != ''"> and city = #{city}</if>
            <if test="createDate != null "> and create_date = #{createDate}</if>
            <if test="updateDate != null "> and update_date = #{updateDate}</if>
        </where>
    </select>
    
    <select id="selectRecCityById" parameterType="Long" resultMap="RecCityResult">
        <include refid="selectRecCityVo"/>
        where id = #{id}
    </select>

    <insert id="insertRecCity" parameterType="RecCity" useGeneratedKeys="true" keyProperty="id">
        insert into rec_city
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="city != null">city,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createDate != null">create_date,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateDate != null">update_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="city != null">#{city},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createDate != null">#{createDate},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateDate != null">#{updateDate},</if>
         </trim>
    </insert>

    <update id="updateRecCity" parameterType="RecCity">
        update rec_city
        <trim prefix="SET" suffixOverrides=",">
            <if test="city != null">city = #{city},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createDate != null">create_date = #{createDate},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateDate != null">update_date = #{updateDate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRecCityById" parameterType="Long">
        delete from rec_city where id = #{id}
    </delete>

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