<?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.ruoyi.system.mapper.grid.GridRegionMapper">
  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.grid.GridRegion">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="wg_type" jdbcType="VARCHAR" property="wgType" />
    <result column="wg_code" jdbcType="VARCHAR" property="wgCode" />
    <result column="wg_name" jdbcType="VARCHAR" property="wgName" />
    <result column="wg_parent_id" jdbcType="VARCHAR" property="wgParentId" />
    <result column="wg_area" jdbcType="VARCHAR" property="wgArea" />
    <result column="wg_centre_coordinate" jdbcType="VARCHAR" property="wgCentreCoordinate" />
    <result column="wg_principal" jdbcType="VARCHAR" property="wgPrincipal" />
    <result column="create_time" jdbcType="VARCHAR" property="createTime" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_time" jdbcType="VARCHAR" property="updateTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="level" jdbcType="VARCHAR" property="level" />
    <result column="is_valid" jdbcType="VARCHAR" property="isValid" />
    <result column="ylzd1" jdbcType="VARCHAR" property="ylzd1" />
    <result column="ylzd2" jdbcType="VARCHAR" property="ylzd2" />
    <result column="ylzd3" jdbcType="VARCHAR" property="ylzd3" />
    <result column="ylzd4" jdbcType="VARCHAR" property="ylzd4" />
    <result column="ylzd5" jdbcType="VARCHAR" property="ylzd5" />
    <result column="wg_purpose" jdbcType="VARCHAR" property="wgPurpose" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.ruoyi.system.domain.grid.GridRegion">
    <result column="wg_coordinate" jdbcType="LONGVARCHAR" property="wgCoordinate" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, wg_type, wg_code, wg_name, wg_parent_id, wg_area, wg_centre_coordinate,
    wg_principal, create_time, create_by, update_time, update_by, level, is_valid, ylzd1, 
    ylzd2, ylzd3, ylzd4, ylzd5, wg_purpose
  </sql>
  <sql id="Blob_Column_List">
    wg_coordinate
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.ruoyi.system.domain.grid.GridRegionExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from grid_region
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="com.ruoyi.system.domain.grid.GridRegionExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from grid_region
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from grid_region
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from grid_region
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.ruoyi.system.domain.grid.GridRegionExample">
    delete from grid_region
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.ruoyi.system.domain.grid.GridRegion">
    insert into grid_region (id, wg_type,
      wg_code, wg_name, wg_parent_id, 
      wg_area, wg_centre_coordinate, wg_principal, 
      create_time, create_by, update_time, 
      update_by, level, is_valid, 
      ylzd1, ylzd2, ylzd3, 
      ylzd4, ylzd5, wg_purpose, 
      wg_coordinate)
    values (#{id,jdbcType=VARCHAR}, #{wgType,jdbcType=VARCHAR},
      #{wgCode,jdbcType=VARCHAR}, #{wgName,jdbcType=VARCHAR}, #{wgParentId,jdbcType=VARCHAR}, 
      #{wgArea,jdbcType=VARCHAR}, #{wgCentreCoordinate,jdbcType=VARCHAR}, #{wgPrincipal,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=VARCHAR}, 
      #{updateBy,jdbcType=VARCHAR}, #{level,jdbcType=VARCHAR}, #{isValid,jdbcType=VARCHAR}, 
      #{ylzd1,jdbcType=VARCHAR}, #{ylzd2,jdbcType=VARCHAR}, #{ylzd3,jdbcType=VARCHAR}, 
      #{ylzd4,jdbcType=VARCHAR}, #{ylzd5,jdbcType=VARCHAR}, #{wgPurpose,jdbcType=VARCHAR}, 
      #{wgCoordinate,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.ruoyi.system.domain.grid.GridRegion">
    insert into grid_region
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="wgType != null">
        wg_type,
      </if>
      <if test="wgCode != null">
        wg_code,
      </if>
      <if test="wgName != null">
        wg_name,
      </if>
      <if test="wgParentId != null">
        wg_parent_id,
      </if>
      <if test="wgArea != null">
        wg_area,
      </if>
      <if test="wgCentreCoordinate != null">
        wg_centre_coordinate,
      </if>
      <if test="wgPrincipal != null">
        wg_principal,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="level != null">
        level,
      </if>
      <if test="isValid != null">
        is_valid,
      </if>
      <if test="ylzd1 != null">
        ylzd1,
      </if>
      <if test="ylzd2 != null">
        ylzd2,
      </if>
      <if test="ylzd3 != null">
        ylzd3,
      </if>
      <if test="ylzd4 != null">
        ylzd4,
      </if>
      <if test="ylzd5 != null">
        ylzd5,
      </if>
      <if test="wgPurpose != null">
        wg_purpose,
      </if>
      <if test="wgCoordinate != null">
        wg_coordinate,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="wgType != null">
        #{wgType,jdbcType=VARCHAR},
      </if>
      <if test="wgCode != null">
        #{wgCode,jdbcType=VARCHAR},
      </if>
      <if test="wgName != null">
        #{wgName,jdbcType=VARCHAR},
      </if>
      <if test="wgParentId != null">
        #{wgParentId,jdbcType=VARCHAR},
      </if>
      <if test="wgArea != null">
        #{wgArea,jdbcType=VARCHAR},
      </if>
      <if test="wgCentreCoordinate != null">
        #{wgCentreCoordinate,jdbcType=VARCHAR},
      </if>
      <if test="wgPrincipal != null">
        #{wgPrincipal,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=VARCHAR},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="level != null">
        #{level,jdbcType=VARCHAR},
      </if>
      <if test="isValid != null">
        #{isValid,jdbcType=VARCHAR},
      </if>
      <if test="ylzd1 != null">
        #{ylzd1,jdbcType=VARCHAR},
      </if>
      <if test="ylzd2 != null">
        #{ylzd2,jdbcType=VARCHAR},
      </if>
      <if test="ylzd3 != null">
        #{ylzd3,jdbcType=VARCHAR},
      </if>
      <if test="ylzd4 != null">
        #{ylzd4,jdbcType=VARCHAR},
      </if>
      <if test="ylzd5 != null">
        #{ylzd5,jdbcType=VARCHAR},
      </if>
      <if test="wgPurpose != null">
        #{wgPurpose,jdbcType=VARCHAR},
      </if>
      <if test="wgCoordinate != null">
        #{wgCoordinate,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.ruoyi.system.domain.grid.GridRegionExample" resultType="java.lang.Long">
    select count(*) from grid_region
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update grid_region
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.wgType != null">
        wg_type = #{record.wgType,jdbcType=VARCHAR},
      </if>
      <if test="record.wgCode != null">
        wg_code = #{record.wgCode,jdbcType=VARCHAR},
      </if>
      <if test="record.wgName != null">
        wg_name = #{record.wgName,jdbcType=VARCHAR},
      </if>
      <if test="record.wgParentId != null">
        wg_parent_id = #{record.wgParentId,jdbcType=VARCHAR},
      </if>
      <if test="record.wgArea != null">
        wg_area = #{record.wgArea,jdbcType=VARCHAR},
      </if>
      <if test="record.wgCentreCoordinate != null">
        wg_centre_coordinate = #{record.wgCentreCoordinate,jdbcType=VARCHAR},
      </if>
      <if test="record.wgPrincipal != null">
        wg_principal = #{record.wgPrincipal,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=VARCHAR},
      </if>
      <if test="record.createBy != null">
        create_by = #{record.createBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=VARCHAR},
      </if>
      <if test="record.updateBy != null">
        update_by = #{record.updateBy,jdbcType=VARCHAR},
      </if>
      <if test="record.level != null">
        level = #{record.level,jdbcType=VARCHAR},
      </if>
      <if test="record.isValid != null">
        is_valid = #{record.isValid,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd1 != null">
        ylzd1 = #{record.ylzd1,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd2 != null">
        ylzd2 = #{record.ylzd2,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd3 != null">
        ylzd3 = #{record.ylzd3,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd4 != null">
        ylzd4 = #{record.ylzd4,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd5 != null">
        ylzd5 = #{record.ylzd5,jdbcType=VARCHAR},
      </if>
      <if test="record.wgPurpose != null">
        wg_purpose = #{record.wgPurpose,jdbcType=VARCHAR},
      </if>
      <if test="record.wgCoordinate != null">
        wg_coordinate = #{record.wgCoordinate,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update grid_region
    set id = #{record.id,jdbcType=VARCHAR},
      wg_type = #{record.wgType,jdbcType=VARCHAR},
      wg_code = #{record.wgCode,jdbcType=VARCHAR},
      wg_name = #{record.wgName,jdbcType=VARCHAR},
      wg_parent_id = #{record.wgParentId,jdbcType=VARCHAR},
      wg_area = #{record.wgArea,jdbcType=VARCHAR},
      wg_centre_coordinate = #{record.wgCentreCoordinate,jdbcType=VARCHAR},
      wg_principal = #{record.wgPrincipal,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=VARCHAR},
      create_by = #{record.createBy,jdbcType=VARCHAR},
      update_time = #{record.updateTime,jdbcType=VARCHAR},
      update_by = #{record.updateBy,jdbcType=VARCHAR},
      level = #{record.level,jdbcType=VARCHAR},
      is_valid = #{record.isValid,jdbcType=VARCHAR},
      ylzd1 = #{record.ylzd1,jdbcType=VARCHAR},
      ylzd2 = #{record.ylzd2,jdbcType=VARCHAR},
      ylzd3 = #{record.ylzd3,jdbcType=VARCHAR},
      ylzd4 = #{record.ylzd4,jdbcType=VARCHAR},
      ylzd5 = #{record.ylzd5,jdbcType=VARCHAR},
      wg_purpose = #{record.wgPurpose,jdbcType=VARCHAR},
      wg_coordinate = #{record.wgCoordinate,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update grid_region
    set id = #{record.id,jdbcType=VARCHAR},
      wg_type = #{record.wgType,jdbcType=VARCHAR},
      wg_code = #{record.wgCode,jdbcType=VARCHAR},
      wg_name = #{record.wgName,jdbcType=VARCHAR},
      wg_parent_id = #{record.wgParentId,jdbcType=VARCHAR},
      wg_area = #{record.wgArea,jdbcType=VARCHAR},
      wg_centre_coordinate = #{record.wgCentreCoordinate,jdbcType=VARCHAR},
      wg_principal = #{record.wgPrincipal,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=VARCHAR},
      create_by = #{record.createBy,jdbcType=VARCHAR},
      update_time = #{record.updateTime,jdbcType=VARCHAR},
      update_by = #{record.updateBy,jdbcType=VARCHAR},
      level = #{record.level,jdbcType=VARCHAR},
      is_valid = #{record.isValid,jdbcType=VARCHAR},
      ylzd1 = #{record.ylzd1,jdbcType=VARCHAR},
      ylzd2 = #{record.ylzd2,jdbcType=VARCHAR},
      ylzd3 = #{record.ylzd3,jdbcType=VARCHAR},
      ylzd4 = #{record.ylzd4,jdbcType=VARCHAR},
      ylzd5 = #{record.ylzd5,jdbcType=VARCHAR},
      wg_purpose = #{record.wgPurpose,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.system.domain.grid.GridRegion">
    update grid_region
    <set>
      <if test="wgType != null">
        wg_type = #{wgType,jdbcType=VARCHAR},
      </if>
      <if test="wgCode != null">
        wg_code = #{wgCode,jdbcType=VARCHAR},
      </if>
      <if test="wgName != null">
        wg_name = #{wgName,jdbcType=VARCHAR},
      </if>
      <if test="wgParentId != null">
        wg_parent_id = #{wgParentId,jdbcType=VARCHAR},
      </if>
      <if test="wgArea != null">
        wg_area = #{wgArea,jdbcType=VARCHAR},
      </if>
      <if test="wgCentreCoordinate != null">
        wg_centre_coordinate = #{wgCentreCoordinate,jdbcType=VARCHAR},
      </if>
      <if test="wgPrincipal != null">
        wg_principal = #{wgPrincipal,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=VARCHAR},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="level != null">
        level = #{level,jdbcType=VARCHAR},
      </if>
      <if test="isValid != null">
        is_valid = #{isValid,jdbcType=VARCHAR},
      </if>
      <if test="ylzd1 != null">
        ylzd1 = #{ylzd1,jdbcType=VARCHAR},
      </if>
      <if test="ylzd2 != null">
        ylzd2 = #{ylzd2,jdbcType=VARCHAR},
      </if>
      <if test="ylzd3 != null">
        ylzd3 = #{ylzd3,jdbcType=VARCHAR},
      </if>
      <if test="ylzd4 != null">
        ylzd4 = #{ylzd4,jdbcType=VARCHAR},
      </if>
      <if test="ylzd5 != null">
        ylzd5 = #{ylzd5,jdbcType=VARCHAR},
      </if>
      <if test="wgPurpose != null">
        wg_purpose = #{wgPurpose,jdbcType=VARCHAR},
      </if>
      <if test="wgCoordinate != null">
        wg_coordinate = #{wgCoordinate,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.ruoyi.system.domain.grid.GridRegion">
    update grid_region
    set wg_type = #{wgType,jdbcType=VARCHAR},
      wg_code = #{wgCode,jdbcType=VARCHAR},
      wg_name = #{wgName,jdbcType=VARCHAR},
      wg_parent_id = #{wgParentId,jdbcType=VARCHAR},
      wg_area = #{wgArea,jdbcType=VARCHAR},
      wg_centre_coordinate = #{wgCentreCoordinate,jdbcType=VARCHAR},
      wg_principal = #{wgPrincipal,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=VARCHAR},
      update_by = #{updateBy,jdbcType=VARCHAR},
      level = #{level,jdbcType=VARCHAR},
      is_valid = #{isValid,jdbcType=VARCHAR},
      ylzd1 = #{ylzd1,jdbcType=VARCHAR},
      ylzd2 = #{ylzd2,jdbcType=VARCHAR},
      ylzd3 = #{ylzd3,jdbcType=VARCHAR},
      ylzd4 = #{ylzd4,jdbcType=VARCHAR},
      ylzd5 = #{ylzd5,jdbcType=VARCHAR},
      wg_purpose = #{wgPurpose,jdbcType=VARCHAR},
      wg_coordinate = #{wgCoordinate,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ruoyi.system.domain.grid.GridRegion">
    update grid_region
    set  wg_type = #{wgType,jdbcType=VARCHAR},
      wg_code = #{wgCode,jdbcType=VARCHAR},
      wg_name = #{wgName,jdbcType=VARCHAR},
      wg_parent_id = #{wgParentId,jdbcType=VARCHAR},
      wg_area = #{wgArea,jdbcType=VARCHAR},
      wg_centre_coordinate = #{wgCentreCoordinate,jdbcType=VARCHAR},
      wg_principal = #{wgPrincipal,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=VARCHAR},
      update_by = #{updateBy,jdbcType=VARCHAR},
      level = #{level,jdbcType=VARCHAR},
      is_valid = #{isValid,jdbcType=VARCHAR},
      ylzd1 = #{ylzd1,jdbcType=VARCHAR},
      ylzd2 = #{ylzd2,jdbcType=VARCHAR},
      ylzd3 = #{ylzd3,jdbcType=VARCHAR},
      ylzd4 = #{ylzd4,jdbcType=VARCHAR},
      ylzd5 = #{ylzd5,jdbcType=VARCHAR},
      wg_purpose = #{wgPurpose,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="selectThirdGridByBaseId" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
    select * from grid_region where  wg_type='1' and level='3'
  </select>

  <select id="selectThirdGridNameByBaseId" parameterType="java.lang.String" resultMap="BaseResultMap">
    SELECT
      a.wg_code as wg_code,a.wg_parent_id as wg_parent_id,
      a.wg_name as wg_name,
      b.wg_name as parentWgName
    FROM
      grid_region a
        LEFT JOIN grid_region b ON a.wg_parent_id = b.wg_code and b.`level`='2' AND b. LEVEL = '2'
    WHERE
      a. LEVEL = '3'
      AND a.is_valid = '1'
      and a.wg_type='1'
    ORDER BY
      a.wg_parent_id,
      a.wg_code
  </select>
  <select id="getWgLevel" resultType="com.ruoyi.system.domain.grid.GridRegion">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from grid_region
    where wg_code = #{wgCode,jdbcType=VARCHAR} and is_valid = '1'
  </select>
  <select id="getRootWgCode" resultType="java.lang.String">
    select wg_code from grid_region where level=1 and wg_type = '1'
  </select>
  <select id="getWgNameByCode" resultType="java.lang.String">
    select wg_name  from grid_region where wg_code = #{wgCode,jdbcType=VARCHAR}
  </select>

    <select id="getByParams" resultType="com.ruoyi.system.domain.grid.GridRegion" parameterType="com.ruoyi.system.domain.grid.enums.GridRegionSearchParam">
      select
      <include refid="Base_Column_List" />
      ,
      <include refid="Blob_Column_List" />
      from grid_region where is_valid = '1'
      <if test="wgType != null and wgType != ''">
        and wg_type = #{wgType}
      </if>
      <if test="wgCodeLikes != null and wgCodeLikes.size() > 0">
        and (
        <foreach collection="wgCodeLikes" item="wgCode" open="(" close=")" separator="or">
          wg_code like CONCAT(#{wgCode}, '%')
        </foreach>
        )
      </if>
      <if test="isShow == false">
        and level != '4'
      </if>
      <if test="wgCodeIn != null and wgCodeIn.size() > 0">
        and wg_code in
        <foreach collection="wgCodeIn" item="wgCode" open="(" close=")" separator=",">
          #{wgCode}
        </foreach>
      </if>
      order by wg_code asc
    </select>
  <select id="countByParams" resultType="java.lang.Integer">
    select
    count(1)
    from grid_region where is_valid = '1'
    <if test="wgCodeLikes != null and wgCodeLikes.size() > 0">
      and (
      <foreach collection="wgCodeLikes" item="wgCode" open="(" close=")" separator="or">
        wg_code like CONCAT(#{wgCode}, '%')
      </foreach>
      )
    </if>
    <if test="level != null and level != ''">
      and level = #{level}
    </if>
  </select>
    <select id="getSecondOrThirdRegion" resultType="com.ruoyi.system.domain.grid.GridRegion">
      select
      <include refid="Base_Column_List" />
      from grid_region where is_valid = '1'
      <if test="wgCodeLikes != null and wgCodeLikes.size() > 0">
        and (
        <foreach collection="wgCodeLikes" item="wgCode" open="(" close=")" separator="or">
          wg_code like CONCAT(#{wgCode}, '%')
        </foreach>
        )
      </if>
      <if test="level !=2">
        and (
        <foreach collection="wgCodeLikes" item="wgCode" open="(" close=")" separator="and">
          wg_code != #{wgCode}
        </foreach>
        )
      </if>
      <if test="wgType != null and wgType != ''">
        and wg_type = #{wgType}
      </if>
      <if test="name != null and name != ''">
        and wg_name = #{name}
      </if>
      and level = #{level}
    </select>
  <select id="getWgTypeByWgCode" resultType="java.lang.String">
    select wg_type from grid_region
    where wg_code = #{wgCode}
  </select>
</mapper>