ProductChainMapper.xml 3.29 KB
<?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.yoho.product.dal.ProductChainMapper" >
  <resultMap id="BaseResultMap" type="com.yoho.product.model.ProductChain" >
    <id column="tag_id" property="tagId" jdbcType="VARCHAR" />
    <result column="chain_id" property="chainId" jdbcType="BIGINT" />
    <result column="transaction_id" property="transactionId" jdbcType="VARCHAR" />
    <result column="transaction_time" property="transactionTime" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    tag_id, chain_id, transaction_id, transaction_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from product_chain
    where tag_id = #{tagId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from product_chain
    where tag_id = #{tagId,jdbcType=VARCHAR}
  </delete>
  <insert id="updateProductChain" parameterType="com.yoho.product.model.ProductChain" >
    insert into product_chain (tag_id, chain_id, transaction_id, transaction_time)
    values (#{tagId,jdbcType=VARCHAR}, #{chainId,jdbcType=BIGINT}, #{transactionId,jdbcType=VARCHAR}, #{transactionTime,jdbcType=INTEGER})
    ON DUPLICATE KEY UPDATE transaction_time=#{transactionTime, jdbcType=INTEGER}, transaction_id = #{transactionId,jdbcType=VARCHAR}
  </insert>
  <insert id="insertSelective" parameterType="com.yoho.product.model.ProductChain" >
    insert into product_chain
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="tagId != null" >
        tag_id,
      </if>
      <if test="chainId != null" >
        chain_id,
      </if>
      <if test="transactionId != null" >
        transaction_id,
      </if>
      <if test="transactionTime != null" >
        transaction_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="tagId != null" >
        #{tagId,jdbcType=VARCHAR},
      </if>
      <if test="chainId != null" >
        #{chainId,jdbcType=BIGINT},
      </if>
      <if test="transactionId != null" >
        #{transactionId,jdbcType=VARCHAR},
      </if>
      <if test="transactionTime != null" >
        #{transactionTime,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.product.model.ProductChain" >
    update product_chain
    <set >
      <if test="chainId != null" >
        chain_id = #{chainId,jdbcType=BIGINT},
      </if>
      <if test="transactionId != null" >
        transaction_id = #{transactionId,jdbcType=VARCHAR},
      </if>
      <if test="transactionTime != null" >
        transaction_time = #{transactionTime,jdbcType=INTEGER},
      </if>
    </set>
    where tag_id = #{tagId,jdbcType=VARCHAR}
  </update>
  <update id="updateTransactionId" >
    update product_chain
    set transaction_id = #{transactionId,jdbcType=VARCHAR},
    where tag_id = #{tagId,jdbcType=VARCHAR}
  </update>
    
  <select id="selectProductChain" resultMap="BaseResultMap">
      select
      <include refid="Base_Column_List" />
      from product_chain
      where transaction_id IS NULL limit 200
  </select>
</mapper>