<?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.SysCityMapper">
    
    <resultMap type="SysCity" id="SysCityResult">
        <result property="cityId"    column="city_id"    />
        <result property="city"    column="city"    />
    </resultMap>

    <sql id="selectSysCityVo">
        select city_id, city from sys_city
    </sql>

    <select id="selectSysCityList" parameterType="SysCity" resultMap="SysCityResult">
        <include refid="selectSysCityVo"/>
        <where>  
            <if test="city != null  and city != ''"> and city = #{city}</if>
        </where>
    </select>
    
    <select id="selectSysCityByCityId" parameterType="Long" resultMap="SysCityResult">
        <include refid="selectSysCityVo"/>
        where city_id = #{cityId}
    </select>
        
    <insert id="insertSysCity" parameterType="SysCity" useGeneratedKeys="true" keyProperty="cityId">
        insert into sys_city
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="city != null and city != ''">city,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="city != null and city != ''">#{city},</if>
         </trim>
    </insert>

    <update id="updateSysCity" parameterType="SysCity">
        update sys_city
        <trim prefix="SET" suffixOverrides=",">
            <if test="city != null and city != ''">city = #{city},</if>
        </trim>
        where city_id = #{cityId}
    </update>

    <delete id="deleteSysCityByCityId" parameterType="Long">
        delete from sys_city where city_id = #{cityId}
    </delete>

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