<?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.house365.ws.dao.mapper.NewHouseCityMapper">

    <resultMap id="infoMap" type="com.house365.beans.entity.NewHouseCityEntity">
        <result property="id" column="id"/>
        <result property="cityCode" column="city_code"/>
        <result property="cityName" column="city_name"/>
        <result property="isSame" column="is_same"/>
    </resultMap>

    <insert id="save" parameterType="com.house365.beans.entity.NewHouseCityEntity">
        INSERT INTO new_house_city (
            city_code,
            city_name
        )
        VALUES (
            #{cityCode},
            #{cityName}
        )
    </insert>

    <update id="update" parameterType="com.house365.beans.entity.NewHouseCityEntity">
        UPDATE new_house_city
        SET
        is_same = #{isSame}
        WHERE id = #{id}
    </update>

    <select id="queryByConditions" resultMap="infoMap" parameterType="map">
        SELECT *
        FROM new_house_city
        where 1 = 1
        <if test="cityName != null and cityName != ''">
            AND city_name = #{cityName}
        </if>
        <if test="cityCode != null and cityCode != ''">
            AND city_code = #{cityCode}
        </if>
    </select>

</mapper>