<?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.wechat.dao.MdeSubscribedPrepareTypeMapper" >
  <resultMap id="BaseResultMap" type="com.wechat.model.dbEntity.MdeSubscribedPrepareType">
    <id column="USER_CODE" jdbcType="BIGINT" property="userCode" />
    <result column="PREPARE_FLAG" jdbcType="CHAR" property="prepareFlag" />
    <result column="VERSION_NO" jdbcType="INTEGER" property="versionNo" />
    <result column="REMARKS" jdbcType="VARCHAR" property="remarks" />
    <result column="DEL_FLAG" jdbcType="INTEGER" property="delFlag" />
    <result column="CREATE_BY" jdbcType="VARCHAR" property="createBy" />
    <result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
    <result column="UPDATE_BY" jdbcType="VARCHAR" property="updateBy" />
    <result column="UPDATE_DATE" jdbcType="TIMESTAMP" property="updateDate" />
  </resultMap>
  <sql id="Base_Column_List">
    USER_CODE, PREPARE_FLAG, VERSION_NO, REMARKS, DEL_FLAG, CREATE_BY, CREATE_DATE, UPDATE_BY, 
    UPDATE_DATE
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from mde_subscribed_prepare_type
    where USER_CODE = #{userCode,jdbcType=BIGINT}
  </select>
  <delete id="deleteByUserCode" parameterType="String">
    delete from mde_subscribed_prepare_type
    where USER_CODE = #{userCode}
  </delete>
  
  
  <select id="getSubscribedPrepareType" resultType="String" >
    SELECT
		PREPARE_FLAG AS prepareFlag
	FROM
		mde_subscribed_prepare_type 
	WHERE
		USER_CODE = #{userCode}
		AND DEL_FLAG = '0'
  </select>
  
  <insert id="insert" parameterType="com.wechat.model.dbEntity.MdeSubscribedPrepareType">
    insert into mde_subscribed_prepare_type (USER_CODE, PREPARE_FLAG,
    CREATE_BY,  CREATE_DATE, UPDATE_BY, UPDATE_DATE
      )
    values (#{userCode}, #{prepareFlag,jdbcType=CHAR},
    #{createBy,jdbcType=VARCHAR}, 
      #{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.wechat.model.dbEntity.MdeSubscribedPrepareType">
    insert into mde_subscribed_prepare_type
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="userCode != null">
        USER_CODE,
      </if>
      <if test="prepareFlag != null">
        PREPARE_FLAG,
      </if>
      <if test="versionNo != null">
        VERSION_NO,
      </if>
      <if test="remarks != null">
        REMARKS,
      </if>
      <if test="delFlag != null">
        DEL_FLAG,
      </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>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="userCode != null">
        #{userCode,jdbcType=BIGINT},
      </if>
      <if test="prepareFlag != null">
        #{prepareFlag,jdbcType=CHAR},
      </if>
      <if test="versionNo != null">
        #{versionNo,jdbcType=INTEGER},
      </if>
      <if test="remarks != null">
        #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=INTEGER},
      </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>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.wechat.model.dbEntity.MdeSubscribedPrepareType">
    update mde_subscribed_prepare_type
    <set>
      <if test="prepareFlag != null">
        PREPARE_FLAG = #{prepareFlag,jdbcType=CHAR},
      </if>
      <if test="versionNo != null">
        VERSION_NO = #{versionNo,jdbcType=INTEGER},
      </if>
      <if test="remarks != null">
        REMARKS = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        DEL_FLAG = #{delFlag,jdbcType=INTEGER},
      </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>
    </set>
    where USER_CODE = #{userCode,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.wechat.model.dbEntity.MdeSubscribedPrepareType">
    update mde_subscribed_prepare_type
    set PREPARE_FLAG = #{prepareFlag,jdbcType=CHAR},
      VERSION_NO = #{versionNo,jdbcType=INTEGER},
      REMARKS = #{remarks,jdbcType=VARCHAR},
      DEL_FLAG = #{delFlag,jdbcType=INTEGER},
      CREATE_BY = #{createBy,jdbcType=VARCHAR},
      CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
      UPDATE_BY = #{updateBy,jdbcType=VARCHAR},
      UPDATE_DATE = #{updateDate,jdbcType=TIMESTAMP}
    where USER_CODE = #{userCode,jdbcType=BIGINT}
  </update>
</mapper>