<?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="cn.superdesk.uniorder.dao.mapper.sys.notify.SysNotifyTemplateMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplate">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="template_id" jdbcType="INTEGER" property="templateId" />
    <result column="category_id" jdbcType="INTEGER" property="categoryId" />
    <result column="display_order" jdbcType="INTEGER" property="displayOrder" />
    <result column="is_enabled" jdbcType="TINYINT" property="isEnabled" />
    <result column="is_deleted" jdbcType="TINYINT" property="isDeleted" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplate">
    <result column="template_content" jdbcType="LONGVARCHAR" property="templateContent" />
  </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, template_id, category_id, display_order, is_enabled, is_deleted
  </sql>
  <sql id="Blob_Column_List">
    template_content
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplateExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from sys_notify_template
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplateExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from sys_notify_template
    <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="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from sys_notify_template
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from sys_notify_template
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplateExample">
    delete from sys_notify_template
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplate">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_notify_template (template_id, category_id, display_order, 
      is_enabled, is_deleted, template_content
      )
    values (#{templateId,jdbcType=INTEGER}, #{categoryId,jdbcType=INTEGER}, #{displayOrder,jdbcType=INTEGER}, 
      #{isEnabled,jdbcType=TINYINT}, #{isDeleted,jdbcType=TINYINT}, #{templateContent,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplate">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_notify_template
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="templateId != null">
        template_id,
      </if>
      <if test="categoryId != null">
        category_id,
      </if>
      <if test="displayOrder != null">
        display_order,
      </if>
      <if test="isEnabled != null">
        is_enabled,
      </if>
      <if test="isDeleted != null">
        is_deleted,
      </if>
      <if test="templateContent != null">
        template_content,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="templateId != null">
        #{templateId,jdbcType=INTEGER},
      </if>
      <if test="categoryId != null">
        #{categoryId,jdbcType=INTEGER},
      </if>
      <if test="displayOrder != null">
        #{displayOrder,jdbcType=INTEGER},
      </if>
      <if test="isEnabled != null">
        #{isEnabled,jdbcType=TINYINT},
      </if>
      <if test="isDeleted != null">
        #{isDeleted,jdbcType=TINYINT},
      </if>
      <if test="templateContent != null">
        #{templateContent,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplateExample" resultType="java.lang.Long">
    select count(*) from sys_notify_template
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update sys_notify_template
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.templateId != null">
        template_id = #{record.templateId,jdbcType=INTEGER},
      </if>
      <if test="record.categoryId != null">
        category_id = #{record.categoryId,jdbcType=INTEGER},
      </if>
      <if test="record.displayOrder != null">
        display_order = #{record.displayOrder,jdbcType=INTEGER},
      </if>
      <if test="record.isEnabled != null">
        is_enabled = #{record.isEnabled,jdbcType=TINYINT},
      </if>
      <if test="record.isDeleted != null">
        is_deleted = #{record.isDeleted,jdbcType=TINYINT},
      </if>
      <if test="record.templateContent != null">
        template_content = #{record.templateContent,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update sys_notify_template
    set id = #{record.id,jdbcType=BIGINT},
      template_id = #{record.templateId,jdbcType=INTEGER},
      category_id = #{record.categoryId,jdbcType=INTEGER},
      display_order = #{record.displayOrder,jdbcType=INTEGER},
      is_enabled = #{record.isEnabled,jdbcType=TINYINT},
      is_deleted = #{record.isDeleted,jdbcType=TINYINT},
      template_content = #{record.templateContent,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update sys_notify_template
    set id = #{record.id,jdbcType=BIGINT},
      template_id = #{record.templateId,jdbcType=INTEGER},
      category_id = #{record.categoryId,jdbcType=INTEGER},
      display_order = #{record.displayOrder,jdbcType=INTEGER},
      is_enabled = #{record.isEnabled,jdbcType=TINYINT},
      is_deleted = #{record.isDeleted,jdbcType=TINYINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplate">
    update sys_notify_template
    <set>
      <if test="templateId != null">
        template_id = #{templateId,jdbcType=INTEGER},
      </if>
      <if test="categoryId != null">
        category_id = #{categoryId,jdbcType=INTEGER},
      </if>
      <if test="displayOrder != null">
        display_order = #{displayOrder,jdbcType=INTEGER},
      </if>
      <if test="isEnabled != null">
        is_enabled = #{isEnabled,jdbcType=TINYINT},
      </if>
      <if test="isDeleted != null">
        is_deleted = #{isDeleted,jdbcType=TINYINT},
      </if>
      <if test="templateContent != null">
        template_content = #{templateContent,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplate">
    update sys_notify_template
    set template_id = #{templateId,jdbcType=INTEGER},
      category_id = #{categoryId,jdbcType=INTEGER},
      display_order = #{displayOrder,jdbcType=INTEGER},
      is_enabled = #{isEnabled,jdbcType=TINYINT},
      is_deleted = #{isDeleted,jdbcType=TINYINT},
      template_content = #{templateContent,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.sys.notify.SysNotifyTemplate">
    update sys_notify_template
    set template_id = #{templateId,jdbcType=INTEGER},
      category_id = #{categoryId,jdbcType=INTEGER},
      display_order = #{displayOrder,jdbcType=INTEGER},
      is_enabled = #{isEnabled,jdbcType=TINYINT},
      is_deleted = #{isDeleted,jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>