<?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.lightinit.hsdatashow.mapper.AreaFireRankingMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdatashow.entity.AreaFireRanking">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="region_id" jdbcType="BIGINT" property="regionId" />
    <result column="data_year" jdbcType="INTEGER" property="dataYear" />
    <result column="category" jdbcType="VARCHAR" property="category" />
    <result column="proportion" jdbcType="DOUBLE" property="proportion" />
    <result column="growth" jdbcType="DECIMAL" property="growth" />
    <result column="photo" jdbcType="VARCHAR" property="photo" />
    <result column="icon" jdbcType="VARCHAR" property="icon" />
    <result column="latitude" jdbcType="VARCHAR" property="latitude" />
    <result column="longitude" jdbcType="VARCHAR" property="longitude" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="deleted_at" jdbcType="TIMESTAMP" property="deletedAt" />
    <result column="deleted_by" jdbcType="BIGINT" property="deletedBy" />
  </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, region_id, data_year, category, proportion, growth, photo, icon, latitude, longitude, 
    created_at, created_by, deleted_at, deleted_by
  </sql>
  <select id="selectByExample" parameterType="com.lightinit.hsdatashow.entity.AreaFireRankingExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from area_fire_ranking
    <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.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from area_fire_ranking
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from area_fire_ranking
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdatashow.entity.AreaFireRankingExample">
    delete from area_fire_ranking
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdatashow.entity.AreaFireRanking">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into area_fire_ranking (region_id, data_year, category, 
      proportion, growth, photo, 
      icon, latitude, longitude, 
      created_at, created_by, deleted_at, 
      deleted_by)
    values (#{regionId,jdbcType=BIGINT}, #{dataYear,jdbcType=INTEGER}, #{category,jdbcType=VARCHAR}, 
      #{proportion,jdbcType=DOUBLE}, #{growth,jdbcType=DECIMAL}, #{photo,jdbcType=VARCHAR}, 
      #{icon,jdbcType=VARCHAR}, #{latitude,jdbcType=VARCHAR}, #{longitude,jdbcType=VARCHAR}, 
      #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{deletedAt,jdbcType=TIMESTAMP}, 
      #{deletedBy,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdatashow.entity.AreaFireRanking">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into area_fire_ranking
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="regionId != null">
        region_id,
      </if>
      <if test="dataYear != null">
        data_year,
      </if>
      <if test="category != null">
        category,
      </if>
      <if test="proportion != null">
        proportion,
      </if>
      <if test="growth != null">
        growth,
      </if>
      <if test="photo != null">
        photo,
      </if>
      <if test="icon != null">
        icon,
      </if>
      <if test="latitude != null">
        latitude,
      </if>
      <if test="longitude != null">
        longitude,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="deletedAt != null">
        deleted_at,
      </if>
      <if test="deletedBy != null">
        deleted_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="regionId != null">
        #{regionId,jdbcType=BIGINT},
      </if>
      <if test="dataYear != null">
        #{dataYear,jdbcType=INTEGER},
      </if>
      <if test="category != null">
        #{category,jdbcType=VARCHAR},
      </if>
      <if test="proportion != null">
        #{proportion,jdbcType=DOUBLE},
      </if>
      <if test="growth != null">
        #{growth,jdbcType=DECIMAL},
      </if>
      <if test="photo != null">
        #{photo,jdbcType=VARCHAR},
      </if>
      <if test="icon != null">
        #{icon,jdbcType=VARCHAR},
      </if>
      <if test="latitude != null">
        #{latitude,jdbcType=VARCHAR},
      </if>
      <if test="longitude != null">
        #{longitude,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        #{deletedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdatashow.entity.AreaFireRankingExample" resultType="java.lang.Long">
    select count(*) from area_fire_ranking
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update area_fire_ranking
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.regionId != null">
        region_id = #{record.regionId,jdbcType=BIGINT},
      </if>
      <if test="record.dataYear != null">
        data_year = #{record.dataYear,jdbcType=INTEGER},
      </if>
      <if test="record.category != null">
        category = #{record.category,jdbcType=VARCHAR},
      </if>
      <if test="record.proportion != null">
        proportion = #{record.proportion,jdbcType=DOUBLE},
      </if>
      <if test="record.growth != null">
        growth = #{record.growth,jdbcType=DECIMAL},
      </if>
      <if test="record.photo != null">
        photo = #{record.photo,jdbcType=VARCHAR},
      </if>
      <if test="record.icon != null">
        icon = #{record.icon,jdbcType=VARCHAR},
      </if>
      <if test="record.latitude != null">
        latitude = #{record.latitude,jdbcType=VARCHAR},
      </if>
      <if test="record.longitude != null">
        longitude = #{record.longitude,jdbcType=VARCHAR},
      </if>
      <if test="record.createdAt != null">
        created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=BIGINT},
      </if>
      <if test="record.deletedAt != null">
        deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deletedBy != null">
        deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update area_fire_ranking
    set id = #{record.id,jdbcType=BIGINT},
      region_id = #{record.regionId,jdbcType=BIGINT},
      data_year = #{record.dataYear,jdbcType=INTEGER},
      category = #{record.category,jdbcType=VARCHAR},
      proportion = #{record.proportion,jdbcType=DOUBLE},
      growth = #{record.growth,jdbcType=DECIMAL},
      photo = #{record.photo,jdbcType=VARCHAR},
      icon = #{record.icon,jdbcType=VARCHAR},
      latitude = #{record.latitude,jdbcType=VARCHAR},
      longitude = #{record.longitude,jdbcType=VARCHAR},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.lightinit.hsdatashow.entity.AreaFireRanking">
    update area_fire_ranking
    <set>
      <if test="regionId != null">
        region_id = #{regionId,jdbcType=BIGINT},
      </if>
      <if test="dataYear != null">
        data_year = #{dataYear,jdbcType=INTEGER},
      </if>
      <if test="category != null">
        category = #{category,jdbcType=VARCHAR},
      </if>
      <if test="proportion != null">
        proportion = #{proportion,jdbcType=DOUBLE},
      </if>
      <if test="growth != null">
        growth = #{growth,jdbcType=DECIMAL},
      </if>
      <if test="photo != null">
        photo = #{photo,jdbcType=VARCHAR},
      </if>
      <if test="icon != null">
        icon = #{icon,jdbcType=VARCHAR},
      </if>
      <if test="latitude != null">
        latitude = #{latitude,jdbcType=VARCHAR},
      </if>
      <if test="longitude != null">
        longitude = #{longitude,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        deleted_by = #{deletedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdatashow.entity.AreaFireRanking">
    update area_fire_ranking
    set region_id = #{regionId,jdbcType=BIGINT},
      data_year = #{dataYear,jdbcType=INTEGER},
      category = #{category,jdbcType=VARCHAR},
      proportion = #{proportion,jdbcType=DOUBLE},
      growth = #{growth,jdbcType=DECIMAL},
      photo = #{photo,jdbcType=VARCHAR},
      icon = #{icon,jdbcType=VARCHAR},
      latitude = #{latitude,jdbcType=VARCHAR},
      longitude = #{longitude,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <!--sun-->
  <select id="getAreFireRank" resultType="com.lightinit.hsdatashow.model.admin.ChartModel">
    SELECT category AS NAME,proportion AS VALUE
    FROM area_fire_ranking
    WHERE data_year =YEAR(DATE_ADD(NOW(),INTERVAL -1 YEAR))
    ORDER BY proportion
  </select>
</mapper>