<?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.cool.store.mapper.HyIntendDevZoneInfoMapper">
  <resultMap id="BaseResultMap" type="com.cool.store.entity.HyIntendDevZoneInfoDO">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="zone_name" jdbcType="VARCHAR" property="zoneName" />
    <result column="associated_region_id" jdbcType="VARCHAR" property="associatedRegionId" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="last_allot_user_id" jdbcType="VARCHAR" property="lastAllotUserId" />
    <result column="deleted" jdbcType="TINYINT" property="deleted" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
    <result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
  </resultMap>
  <sql id="Base_Column_List">
    id, zone_name, associated_region_id, type, last_allot_user_id, deleted, create_time,
    update_time, create_user_id, update_user_id
  </sql>

  <select id="selectById" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"></include>
    from hy_intend_dev_zone_info
    where id = #{id}
  </select>

  <insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
    insert into hy_intend_dev_zone_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="record.zoneName != null">
        zone_name,
      </if>
      <if test="record.associatedRegionId != null">
        associated_region_id,
      </if>
      <if test="record.type != null">
        type,
      </if>
      <if test="record.lastAllotUserId != null">
        last_allot_user_id,
      </if>
      <if test="record.deleted != null">
        deleted,
      </if>
      <if test="record.createTime != null">
        create_time,
      </if>
      <if test="record.updateTime != null">
        update_time,
      </if>
      <if test="record.createUserId != null">
        create_user_id,
      </if>
      <if test="record.updateUserId != null">
        update_user_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="record.zoneName != null">
        #{record.zoneName},
      </if>
      <if test="record.associatedRegionId != null">
        #{record.associatedRegionId},
      </if>
      <if test="record.type != null">
        #{record.type},
      </if>
      <if test="record.lastAllotUserId != null">
        #{record.lastAllotUserId},
      </if>
      <if test="record.deleted != null">
        #{record.deleted},
      </if>
      <if test="record.createTime != null">
        #{record.createTime},
      </if>
      <if test="record.updateTime != null">
        #{record.updateTime},
      </if>
      <if test="record.createUserId != null">
        #{record.createUserId},
      </if>
      <if test="record.updateUserId != null">
        #{record.updateUserId},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective">
    update hy_intend_dev_zone_info
    <set>
      <if test="record.zoneName != null">
        zone_name = #{record.zoneName},
      </if>
      <if test="record.associatedRegionId != null">
        associated_region_id = #{record.associatedRegionId},
      </if>
      <if test="record.type != null">
        type = #{record.type},
      </if>
      <if test="record.lastAllotUserId != null">
        last_allot_user_id = #{record.lastAllotUserId},
      </if>
      <if test="record.deleted != null">
        deleted = #{record.deleted},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime},
      </if>
      <if test="record.createUserId != null">
        create_user_id = #{record.createUserId},
      </if>
      <if test="record.updateUserId != null">
        update_user_id = #{record.updateUserId},
      </if>
    </set>
    where id = #{record.id}
  </update>


  <select id="getHyIntendDevZoneInfoList" resultMap="BaseResultMap">
    select
    *
    from hy_intend_dev_zone_info
    where type = #{type}
    and deleted = 0
  </select>
  
  <select id="getZoneInfoByRegionIds" resultMap="BaseResultMap">
    select 
      <include refid="Base_Column_List"/>
    from
      hy_intend_dev_zone_info
    where
      deleted = 0 and <foreach collection="regionIds" separator="or" open="(" close=")" item="regionId">associated_region_id like concat("%", #{regionId}, "%")</foreach>
  </select>


  <select id="selectByIds" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"></include>
    from hy_intend_dev_zone_info
    <where>
      <if test="ids !=null and ids.size>0">
        <foreach collection="ids" item="id" open="and id in (" close=")" separator=",">
          #{id}
        </foreach>
      </if>
    </where>
  </select>
</mapper>