BuyerOrderMetaMapper.xml 3.87 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.yohoufo.dal.order.BuyerOrderMetaMapper">
  <resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.BuyerOrderMeta">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="order_code" jdbcType="BIGINT" property="orderCode" />
    <result column="uid" jdbcType="INTEGER" property="uid" />
    <result column="meta_key" jdbcType="VARCHAR" property="metaKey" />
    <result column="meta_value" jdbcType="VARCHAR" property="metaValue" />
  </resultMap>
  <sql id="Base_Column_List">
    id, order_code, uid, meta_key, meta_value
  </sql>

  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from buyer_order_meta
    where id = #{id,jdbcType=INTEGER}
  </select>

  <select id="selectByMetaKey" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from buyer_order_meta
    where
    <if test="uid != null">
      uid = #{uid,jdbcType=INTEGER}
    </if>
    and order_code = #{orderCode,jdbcType=BIGINT}
    and meta_key = #{metaKey,jdbcType=VARCHAR}
    limit 1
  </select>



  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrderMeta" useGeneratedKeys="true">
    insert into buyer_order_meta (order_code, uid, meta_key, 
      meta_value)
    values (#{orderCode,jdbcType=BIGINT}, #{uid,jdbcType=INTEGER}, #{metaKey,jdbcType=VARCHAR}, 
      #{metaValue,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrderMeta" useGeneratedKeys="true">
    insert into buyer_order_meta
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderCode != null">
        order_code,
      </if>
      <if test="uid != null">
        uid,
      </if>
      <if test="metaKey != null">
        meta_key,
      </if>
      <if test="metaValue != null">
        meta_value,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderCode != null">
        #{orderCode,jdbcType=BIGINT},
      </if>
      <if test="uid != null">
        #{uid,jdbcType=INTEGER},
      </if>
      <if test="metaKey != null">
        #{metaKey,jdbcType=VARCHAR},
      </if>
      <if test="metaValue != null">
        #{metaValue,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.BuyerOrderMeta">
    update buyer_order_meta
    <set>
      <if test="orderCode != null">
        order_code = #{orderCode,jdbcType=BIGINT},
      </if>
      <if test="uid != null">
        uid = #{uid,jdbcType=INTEGER},
      </if>
      <if test="metaKey != null">
        meta_key = #{metaKey,jdbcType=VARCHAR},
      </if>
      <if test="metaValue != null">
        meta_value = #{metaValue,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.BuyerOrderMeta">
    update buyer_order_meta
    set order_code = #{orderCode,jdbcType=BIGINT},
      uid = #{uid,jdbcType=INTEGER},
      meta_key = #{metaKey,jdbcType=VARCHAR},
      meta_value = #{metaValue,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateMetaValueByUidAndOrderCodeAndMetaKey" parameterType="com.yohoufo.dal.order.model.BuyerOrderMeta">
    update buyer_order_meta
    set  meta_value = #{metaValue,jdbcType=VARCHAR}
    where order_code = #{orderCode,jdbcType=BIGINT} and uid = #{uid,jdbcType=INTEGER} and meta_key = #{metaKey,jdbcType=VARCHAR}
  </update>
</mapper>