<?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.pengzu.dao.BlogrollDao">
  <resultMap id="BaseResultMap" type="com.pengzu.entity.Blogroll">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="blogroll_name" jdbcType="VARCHAR" property="blogrollName" />
    <result column="blogroll_url" jdbcType="VARCHAR" property="blogrollUrl" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="blogroll_image_url" jdbcType="VARCHAR" property="blogrollImageUrl" />
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    <result column="modify_date" jdbcType="TIMESTAMP" property="modifyDate" />
    <result column="user_id" jdbcType="BIGINT" property="userId" />
    <result column="status" jdbcType="INTEGER" property="status" />
  </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, blogroll_name, blogroll_url, description, blogroll_image_url, create_date, modify_date, 
    user_id, status
  </sql>
  <select id="selectByExample" parameterType="com.pengzu.entity.BlogrollExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    'true' as QUERYID,
    <include refid="Base_Column_List" />
    from pengzucms.blogroll
    <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 pengzucms.blogroll
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from pengzucms.blogroll
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.pengzu.entity.BlogrollExample">
    delete from pengzucms.blogroll
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.pengzu.entity.Blogroll">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into pengzucms.blogroll (blogroll_name, blogroll_url, description,
      blogroll_image_url, create_date, modify_date, 
      user_id, status)
    values (#{blogrollName,jdbcType=VARCHAR}, #{blogrollUrl,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, 
      #{blogrollImageUrl,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{modifyDate,jdbcType=TIMESTAMP}, 
      #{userId,jdbcType=BIGINT}, #{status,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.pengzu.entity.Blogroll">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into pengzucms.blogroll
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="blogrollName != null">
        blogroll_name,
      </if>
      <if test="blogrollUrl != null">
        blogroll_url,
      </if>
      <if test="description != null">
        description,
      </if>
      <if test="blogrollImageUrl != null">
        blogroll_image_url,
      </if>
      <if test="createDate != null">
        create_date,
      </if>
      <if test="modifyDate != null">
        modify_date,
      </if>
      <if test="userId != null">
        user_id,
      </if>
      <if test="status != null">
        status,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="blogrollName != null">
        #{blogrollName,jdbcType=VARCHAR},
      </if>
      <if test="blogrollUrl != null">
        #{blogrollUrl,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="blogrollImageUrl != null">
        #{blogrollImageUrl,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="modifyDate != null">
        #{modifyDate,jdbcType=TIMESTAMP},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=BIGINT},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.pengzu.entity.BlogrollExample" resultType="java.lang.Long">
    select count(*) from pengzucms.blogroll
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update pengzucms.blogroll
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.blogrollName != null">
        blogroll_name = #{record.blogrollName,jdbcType=VARCHAR},
      </if>
      <if test="record.blogrollUrl != null">
        blogroll_url = #{record.blogrollUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.description != null">
        description = #{record.description,jdbcType=VARCHAR},
      </if>
      <if test="record.blogrollImageUrl != null">
        blogroll_image_url = #{record.blogrollImageUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.createDate != null">
        create_date = #{record.createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.modifyDate != null">
        modify_date = #{record.modifyDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.userId != null">
        user_id = #{record.userId,jdbcType=BIGINT},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update pengzucms.blogroll
    set id = #{record.id,jdbcType=BIGINT},
      blogroll_name = #{record.blogrollName,jdbcType=VARCHAR},
      blogroll_url = #{record.blogrollUrl,jdbcType=VARCHAR},
      description = #{record.description,jdbcType=VARCHAR},
      blogroll_image_url = #{record.blogrollImageUrl,jdbcType=VARCHAR},
      create_date = #{record.createDate,jdbcType=TIMESTAMP},
      modify_date = #{record.modifyDate,jdbcType=TIMESTAMP},
      user_id = #{record.userId,jdbcType=BIGINT},
      status = #{record.status,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.pengzu.entity.Blogroll">
    update pengzucms.blogroll
    <set>
      <if test="blogrollName != null">
        blogroll_name = #{blogrollName,jdbcType=VARCHAR},
      </if>
      <if test="blogrollUrl != null">
        blogroll_url = #{blogrollUrl,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="blogrollImageUrl != null">
        blogroll_image_url = #{blogrollImageUrl,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="modifyDate != null">
        modify_date = #{modifyDate,jdbcType=TIMESTAMP},
      </if>
      <if test="userId != null">
        user_id = #{userId,jdbcType=BIGINT},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.pengzu.entity.Blogroll">
    update pengzucms.blogroll
    set blogroll_name = #{blogrollName,jdbcType=VARCHAR},
      blogroll_url = #{blogrollUrl,jdbcType=VARCHAR},
      description = #{description,jdbcType=VARCHAR},
      blogroll_image_url = #{blogrollImageUrl,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      modify_date = #{modifyDate,jdbcType=TIMESTAMP},
      user_id = #{userId,jdbcType=BIGINT},
      status = #{status,jdbcType=INTEGER}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>