<?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.ss.city.mapper.CityCodeMapper">

    <resultMap type="CityCode" id="RlCityCodeResult">
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
    </resultMap>

    <sql id="selectRlCityCodeVo">
        select code, name from ss_city_code
    </sql>

    <select id="selectRlCityCodeList" parameterType="CityCode" resultMap="RlCityCodeResult">
        <include refid="selectRlCityCodeVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
        </where>
    </select>

    <select id="selectRlCityCodeByCode" parameterType="Long" resultMap="RlCityCodeResult">
        <include refid="selectRlCityCodeVo"/>
        where code = #{code}
    </select>

    <insert id="insertRlCityCode" parameterType="CityCode">
        insert into ss_city_code
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="name != null">name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="name != null">#{name},</if>
         </trim>
    </insert>

    <update id="updateRlCityCode" parameterType="CityCode">
        update ss_city_code
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
        </trim>
        where code = #{code}
    </update>

    <delete id="deleteRlCityCodeBycode" parameterType="Long">
        delete from ss_city_code where code = #{code}
    </delete>

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