<?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.sys.dao.CityMapper" >
  <resultMap id="BaseResultMap" type="com.sys.model.City" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="city_id" property="cityId" jdbcType="VARCHAR" />
    <result column="city" property="city" jdbcType="VARCHAR" />
    <result column="province_id" property="provinceId" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, city_id, city, province_id
  </sql>
  <select id="selectByProvinceId" resultMap="BaseResultMap" parameterType="java.lang.String">
        select <include refid="Base_Column_List" /> from sys_cities 
        where province_id = #{provinceId,jdbcType=VARCHAR}
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from sys_cities
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from sys_cities
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.sys.model.City" >
    insert into sys_cities (id, city_id, city, 
      province_id)
    values (#{id,jdbcType=INTEGER}, #{cityId,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, 
      #{provinceId,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.sys.model.City" >
    insert into sys_cities
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="cityId != null" >
        city_id,
      </if>
      <if test="city != null" >
        city,
      </if>
      <if test="provinceId != null" >
        province_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="cityId != null" >
        #{cityId,jdbcType=VARCHAR},
      </if>
      <if test="city != null" >
        #{city,jdbcType=VARCHAR},
      </if>
      <if test="provinceId != null" >
        #{provinceId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.sys.model.City" >
    update sys_cities
    <set >
      <if test="cityId != null" >
        city_id = #{cityId,jdbcType=VARCHAR},
      </if>
      <if test="city != null" >
        city = #{city,jdbcType=VARCHAR},
      </if>
      <if test="provinceId != null" >
        province_id = #{provinceId,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sys.model.City" >
    update sys_cities
    set city_id = #{cityId,jdbcType=VARCHAR},
      city = #{city,jdbcType=VARCHAR},
      province_id = #{provinceId,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!-- 查询城市名 -->
  <select id="getCity" parameterType="java.lang.String" resultType="java.lang.String">
  select city from sys_cities where city_id=${cityId}
  </select>
</mapper>