<?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.yd.dal.mapper.meta.MdCityMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.meta.MdCity">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="province_id" jdbcType="BIGINT" property="provinceId" />
    <result column="product_id" jdbcType="BIGINT" property="productId" />
    <result column="city_name" jdbcType="VARCHAR" property="cityName" />
    <result column="city_name_en" jdbcType="VARCHAR" property="cityNameEn" />
    <result column="city_code" jdbcType="VARCHAR" property="cityCode" />
    <result column="city_line" jdbcType="VARCHAR" property="cityLine" />
    <result column="global_code" jdbcType="VARCHAR" property="globalCode" />
    <result column="zip_code" jdbcType="VARCHAR" property="zipCode" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="insurer_id" jdbcType="BIGINT" property="insurerId" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
  </resultMap>
  <sql id="Base_Column_List">
    id, province_id, product_id, city_name, city_name_en, city_code, city_line, global_code, 
    zip_code, is_active, insurer_id, created_at, created_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_md_city
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="findByInsurerId" resultType="com.yd.dal.entity.meta.MdCity">
    select
    <include refid="Base_Column_List" />
    from ag_md_city
    where insurer_id = #{insurerId,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_md_city
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdCity" useGeneratedKeys="true">
    insert into ag_md_city (province_id, product_id, city_name, 
      city_name_en, city_code, city_line, 
      global_code, zip_code, is_active, 
      insurer_id, created_at, created_by
      )
    values (#{provinceId,jdbcType=BIGINT}, #{productId,jdbcType=BIGINT}, #{cityName,jdbcType=VARCHAR}, 
      #{cityNameEn,jdbcType=VARCHAR}, #{cityCode,jdbcType=VARCHAR}, #{cityLine,jdbcType=VARCHAR}, 
      #{globalCode,jdbcType=VARCHAR}, #{zipCode,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER}, 
      #{insurerId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdCity" useGeneratedKeys="true">
    insert into ag_md_city
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="provinceId != null">
        province_id,
      </if>
      <if test="productId != null">
        product_id,
      </if>
      <if test="cityName != null">
        city_name,
      </if>
      <if test="cityNameEn != null">
        city_name_en,
      </if>
      <if test="cityCode != null">
        city_code,
      </if>
      <if test="cityLine != null">
        city_line,
      </if>
      <if test="globalCode != null">
        global_code,
      </if>
      <if test="zipCode != null">
        zip_code,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="insurerId != null">
        insurer_id,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="provinceId != null">
        #{provinceId,jdbcType=BIGINT},
      </if>
      <if test="productId != null">
        #{productId,jdbcType=BIGINT},
      </if>
      <if test="cityName != null">
        #{cityName,jdbcType=VARCHAR},
      </if>
      <if test="cityNameEn != null">
        #{cityNameEn,jdbcType=VARCHAR},
      </if>
      <if test="cityCode != null">
        #{cityCode,jdbcType=VARCHAR},
      </if>
      <if test="cityLine != null">
        #{cityLine,jdbcType=VARCHAR},
      </if>
      <if test="globalCode != null">
        #{globalCode,jdbcType=VARCHAR},
      </if>
      <if test="zipCode != null">
        #{zipCode,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="insurerId != null">
        #{insurerId,jdbcType=BIGINT},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.meta.MdCity">
    update ag_md_city
    <set>
      <if test="provinceId != null">
        province_id = #{provinceId,jdbcType=BIGINT},
      </if>
      <if test="productId != null">
        product_id = #{productId,jdbcType=BIGINT},
      </if>
      <if test="cityName != null">
        city_name = #{cityName,jdbcType=VARCHAR},
      </if>
      <if test="cityNameEn != null">
        city_name_en = #{cityNameEn,jdbcType=VARCHAR},
      </if>
      <if test="cityCode != null">
        city_code = #{cityCode,jdbcType=VARCHAR},
      </if>
      <if test="cityLine != null">
        city_line = #{cityLine,jdbcType=VARCHAR},
      </if>
      <if test="globalCode != null">
        global_code = #{globalCode,jdbcType=VARCHAR},
      </if>
      <if test="zipCode != null">
        zip_code = #{zipCode,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="insurerId != null">
        insurer_id = #{insurerId,jdbcType=BIGINT},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.meta.MdCity">
    update ag_md_city
    set province_id = #{provinceId,jdbcType=BIGINT},
      product_id = #{productId,jdbcType=BIGINT},
      city_name = #{cityName,jdbcType=VARCHAR},
      city_name_en = #{cityNameEn,jdbcType=VARCHAR},
      city_code = #{cityCode,jdbcType=VARCHAR},
      city_line = #{cityLine,jdbcType=VARCHAR},
      global_code = #{globalCode,jdbcType=VARCHAR},
      zip_code = #{zipCode,jdbcType=VARCHAR},
      is_active = #{isActive,jdbcType=INTEGER},
      insurer_id = #{insurerId,jdbcType=BIGINT},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>