<?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.AreaMapper" >
  <resultMap id="BaseResultMap" type="com.sys.model.Area" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="area_id" property="areaId" jdbcType="VARCHAR" />
    <result column="area" property="area" jdbcType="VARCHAR" />
    <result column="city_id" property="cityId" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, area_id, area, city_id
  </sql>
  <select id="selectByCityId" resultMap="BaseResultMap" parameterType="java.lang.String">
        select <include refid="Base_Column_List" /> from sys_areas 
        where city_id = #{cityId,jdbcType=VARCHAR}
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from sys_areas
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from sys_areas
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.sys.model.Area" >
    insert into sys_areas (id, area_id, area, 
      city_id)
    values (#{id,jdbcType=INTEGER}, #{areaId,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR}, 
      #{cityId,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.sys.model.Area" >
    insert into sys_areas
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="areaId != null" >
        area_id,
      </if>
      <if test="area != null" >
        area,
      </if>
      <if test="cityId != null" >
        city_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="areaId != null" >
        #{areaId,jdbcType=VARCHAR},
      </if>
      <if test="area != null" >
        #{area,jdbcType=VARCHAR},
      </if>
      <if test="cityId != null" >
        #{cityId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.sys.model.Area" >
    update sys_areas
    <set >
      <if test="areaId != null" >
        area_id = #{areaId,jdbcType=VARCHAR},
      </if>
      <if test="area != null" >
        area = #{area,jdbcType=VARCHAR},
      </if>
      <if test="cityId != null" >
        city_id = #{cityId,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sys.model.Area" >
    update sys_areas
    set area_id = #{areaId,jdbcType=VARCHAR},
      area = #{area,jdbcType=VARCHAR},
      city_id = #{cityId,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!-- 查询地区 -->
  <select id="getArea" parameterType="java.lang.String" resultType="java.lang.String">
  SELECT area FROM sys_areas WHERE area_id=#{areaId}
  </select>
</mapper>