<?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.gic.haoban.manage.service.dao.mapper.TabHaobanApplicationTemplateMapper" >
  <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanApplicationTemplate" >
    <id column="application_template_id" property="applicationTemplateId" jdbcType="VARCHAR" />
    <result column="application_template_name" property="applicationTemplateName" jdbcType="VARCHAR" />
    <result column="status_flag" property="statusFlag" jdbcType="INTEGER" />
    <result column="default_flag" property="defaultFlag" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    application_template_id, application_template_name, status_flag, default_flag, create_time, 
    update_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from tab_haoban_application_template
    where application_template_id = #{applicationTemplateId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from tab_haoban_application_template
    where application_template_id = #{applicationTemplateId,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanApplicationTemplate" >
    insert into tab_haoban_application_template (application_template_id, application_template_name, 
      status_flag, default_flag, create_time, 
      update_time)
    values (#{applicationTemplateId,jdbcType=VARCHAR}, #{applicationTemplateName,jdbcType=VARCHAR}, 
      #{statusFlag,jdbcType=INTEGER}, #{defaultFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanApplicationTemplate" >
    insert into tab_haoban_application_template
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="applicationTemplateId != null" >
        application_template_id,
      </if>
      <if test="applicationTemplateName != null" >
        application_template_name,
      </if>
      <if test="statusFlag != null" >
        status_flag,
      </if>
      <if test="defaultFlag != null" >
        default_flag,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="applicationTemplateId != null" >
        #{applicationTemplateId,jdbcType=VARCHAR},
      </if>
      <if test="applicationTemplateName != null" >
        #{applicationTemplateName,jdbcType=VARCHAR},
      </if>
      <if test="statusFlag != null" >
        #{statusFlag,jdbcType=INTEGER},
      </if>
      <if test="defaultFlag != null" >
        #{defaultFlag,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanApplicationTemplate" >
    update tab_haoban_application_template
    <set >
      <if test="applicationTemplateName != null" >
        application_template_name = #{applicationTemplateName,jdbcType=VARCHAR},
      </if>
      <if test="statusFlag != null" >
        status_flag = #{statusFlag,jdbcType=INTEGER},
      </if>
      <if test="defaultFlag != null" >
        default_flag = #{defaultFlag,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where application_template_id = #{applicationTemplateId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanApplicationTemplate" >
    update tab_haoban_application_template
    set application_template_name = #{applicationTemplateName,jdbcType=VARCHAR},
      status_flag = #{statusFlag,jdbcType=INTEGER},
      default_flag = #{defaultFlag,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where application_template_id = #{applicationTemplateId,jdbcType=VARCHAR}
  </update>
  
  <select id="selectByTemplateName" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from tab_haoban_application_template
    where application_template_name = #{templateName,jdbcType=VARCHAR}
    and status_flag = 1
  </select>
  
  <select id="listByTemplateName" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from tab_haoban_application_template
    where 1
    <if test="templateName != null and templateName != ''"> 
    and application_template_name like CONCAT('%',#{templateName},'%')
    </if>
    and status_flag = 1
  </select>
  
  <select id="selectDefaultTemplate" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from tab_haoban_application_template
    where default_flag = 1
    and status_flag = 1
  </select>
</mapper>