<?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.NoticeMessageTemplateMapper">
    <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabNoticeMessageTemplate">
        <id column="notice_message_template_id" jdbcType="INTEGER" property="noticeMessageTemplateId"/>
        <result column="enterprise_id" jdbcType="VARCHAR" property="enterpriseId"/>
        <result column="template_code" jdbcType="VARCHAR" property="templateCode"/>
        <result column="content" jdbcType="VARCHAR" property="content"/>
        <result column="notice_content" jdbcType="VARCHAR" property="noticeContent"/>
        <result column="delete_flag" jdbcType="INTEGER" property="deleteFlag"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        notice_message_template_id, enterprise_id, template_code, content,notice_content, delete_flag, create_time,
        update_time
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_notice_message_template
        where notice_message_template_id = #{noticeMessageTemplateId,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from tab_haoban_notice_message_template
        where notice_message_template_id = #{noticeMessageTemplateId,jdbcType=INTEGER}
    </delete>
    <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabNoticeMessageTemplate">
    insert into tab_haoban_notice_message_template (notice_message_template_id, enterprise_id, 
      template_code, content, delete_flag, 
      create_time, update_time)
    values (#{noticeMessageTemplateId,jdbcType=INTEGER}, #{enterpriseId,jdbcType=VARCHAR}, 
      #{templateCode,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{deleteFlag,jdbcType=INTEGER}, 
      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
  </insert>
    <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabNoticeMessageTemplate">
        insert into tab_haoban_notice_message_template
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="noticeMessageTemplateId != null">
                notice_message_template_id,
            </if>
            <if test="enterpriseId != null">
                enterprise_id,
            </if>
            <if test="templateCode != null">
                template_code,
            </if>
            <if test="content != null">
                content,
            </if>
            <if test="deleteFlag != null">
                delete_flag,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="noticeMessageTemplateId != null">
                #{noticeMessageTemplateId,jdbcType=INTEGER},
            </if>
            <if test="enterpriseId != null">
                #{enterpriseId,jdbcType=VARCHAR},
            </if>
            <if test="templateCode != null">
                #{templateCode,jdbcType=VARCHAR},
            </if>
            <if test="content != null">
                #{content,jdbcType=VARCHAR},
            </if>
            <if test="deleteFlag != null">
                #{deleteFlag,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.TabNoticeMessageTemplate">
        update tab_haoban_notice_message_template
        <set>
            <if test="enterpriseId != null">
                enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
            </if>
            <if test="templateCode != null">
                template_code = #{templateCode,jdbcType=VARCHAR},
            </if>
            <if test="content != null">
                content = #{content,jdbcType=VARCHAR},
            </if>
            <if test="deleteFlag != null">
                delete_flag = #{deleteFlag,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 notice_message_template_id = #{noticeMessageTemplateId,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabNoticeMessageTemplate">
    update tab_haoban_notice_message_template
    set enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
      template_code = #{templateCode,jdbcType=VARCHAR},
      content = #{content,jdbcType=VARCHAR},
      delete_flag = #{deleteFlag,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where notice_message_template_id = #{noticeMessageTemplateId,jdbcType=INTEGER}
  </update>

    <select id="getByCode" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_notice_message_template
        where template_code = #{templateCode,jdbcType=VARCHAR} and enterprise_id=#{enterpriseId} and delete_flag=0
    </select>
</mapper>