<?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="MdeShowInfoMapper" >
  <resultMap id="BaseResultMap" type="com.wechat.model.dbEntity.MdeShowInfo" >
    <id column="SHOW_ID" property="showId" jdbcType="INTEGER" />
    <result column="USER_CODE" property="userCode" jdbcType="VARCHAR" />
    <result column="SHOW_TEMPLATE" property="showTemplate" jdbcType="VARCHAR" />
    <result column="SHOW_TITLE" property="showTitle" jdbcType="VARCHAR" />
    <result column="SHOW_INTRODUCTION" property="showIntroduction" jdbcType="VARCHAR" />
    <result column="WELFARES" property="welfares" jdbcType="VARCHAR" />
    <result column="JOB_IDS" property="jobIds" jdbcType="VARCHAR" />
    <result column="VERSION_NO" property="versionNo" jdbcType="INTEGER" />
    <result column="CREATE_BY" property="createBy" jdbcType="VARCHAR" />
    <result column="CREATE_DATE" property="createDate" jdbcType="TIMESTAMP" />
    <result column="UPDATE_BY" property="updateBy" jdbcType="VARCHAR" />
    <result column="UPDATE_DATE" property="updateDate" jdbcType="TIMESTAMP" />
    <result column="REMARKS" property="remarks" jdbcType="VARCHAR" />
    <result column="DEL_FLAG" property="delFlag" jdbcType="CHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    SHOW_ID, USER_CODE, SHOW_TEMPLATE, SHOW_TITLE, SHOW_INTRODUCTION, WELFARES, JOB_IDS, 
    VERSION_NO, CREATE_BY, CREATE_DATE, UPDATE_BY, UPDATE_DATE, REMARKS, DEL_FLAG
  </sql>
  
  <select id="getInfoById" resultMap="BaseResultMap" >
    select 
    <include refid="Base_Column_List" />
    from mde_show_info
    where SHOW_ID = #{showId}
     and DEL_FLAG = 0
  </select>
  
  <select id="getInfoForUpd" resultMap="BaseResultMap" >
    select 
    <include refid="Base_Column_List" />
    from mde_show_info
    where SHOW_ID = #{showId}
     and USER_CODE = #{userCode}
  </select>
  


  <insert id="insertSelective" useGeneratedKeys="true" keyProperty="showId" parameterType="com.wechat.model.dbEntity.MdeShowInfo" >
    insert into mde_show_info
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="userCode != null" >
        USER_CODE,
      </if>
      <if test="showTemplate != null" >
        SHOW_TEMPLATE,
      </if>
      <if test="showTitle != null" >
        SHOW_TITLE,
      </if>
      <if test="showIntroduction != null" >
        SHOW_INTRODUCTION,
      </if>
      <if test="welfares != null" >
        WELFARES,
      </if>
      <if test="jobIds != null" >
        JOB_IDS,
      </if>
      <if test="createBy != null" >
        CREATE_BY,
      </if>
      <if test="createDate != null" >
        CREATE_DATE,
      </if>
      <if test="updateBy != null" >
        UPDATE_BY,
      </if>
      <if test="updateDate != null" >
        UPDATE_DATE,
      </if>
      <if test="remarks != null" >
        REMARKS,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="userCode != null" >
        #{userCode},
      </if>
      <if test="showTemplate != null" >
        #{showTemplate,jdbcType=VARCHAR},
      </if>
      <if test="showTitle != null" >
        #{showTitle,jdbcType=VARCHAR},
      </if>
      <if test="showIntroduction != null" >
        #{showIntroduction,jdbcType=VARCHAR},
      </if>
      <if test="welfares != null" >
        #{welfares,jdbcType=VARCHAR},
      </if>
      <if test="jobIds != null" >
        #{jobIds,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null" >
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null" >
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="remarks != null" >
        #{remarks,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  
  <update id="updateByPrimaryKeySelective" parameterType="com.wechat.model.dbEntity.MdeShowInfo" >
    update mde_show_info
    <set >
      <if test="showTemplate != null" >
        SHOW_TEMPLATE = #{showTemplate,jdbcType=VARCHAR},
      </if>
      <if test="showTitle != null" >
        SHOW_TITLE = #{showTitle,jdbcType=VARCHAR},
      </if>
      <if test="showIntroduction != null" >
        SHOW_INTRODUCTION = #{showIntroduction,jdbcType=VARCHAR},
      </if>
      <if test="welfares != null" >
        WELFARES = #{welfares,jdbcType=VARCHAR},
      </if>
      <if test="jobIds != null" >
        JOB_IDS = #{jobIds,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null" >
        CREATE_BY = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null" >
        UPDATE_BY = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null" >
        UPDATE_DATE = #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="remarks != null" >
        REMARKS = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null" >
        DEL_FLAG = #{delFlag,jdbcType=CHAR},
      </if>
      version_no = version_no +1
    </set>
    where SHOW_ID = #{showId}
      and USER_CODE = #{userCode}
  </update>
  
  
  <update id="delShow" parameterType="java.util.Map" >
    update mde_show_info
    set DEL_FLAG = 1,
      version_no = version_no +1
        where SHOW_ID = #{showId}
      and USER_CODE = #{userCode}
  </update>
  
  <select id="getShowList" resultType="com.wechat.model.responseDto.MdeShowListResp" >
    select 
	    SHOW_ID        as showId, 
	    SHOW_TEMPLATE  as showTemplate, 
	    SHOW_TITLE     as showTitle, 
	    SHOW_INTRODUCTION   as showIntroduction, 
	    UPDATE_DATE    as updateDate
    from mde_show_info
    where USER_CODE = #{userCode}
     and DEL_FLAG = 0
  </select>
  
  
</mapper>