ReceiptContainerDetailMapperAuto.xml 9.28 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.huaheng.pc.receipt.receiptContainerDetail.mapper.ReceiptContainerDetailMapperAuto">
  <select id="selectListEntityByLike" resultType="com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail">
      SELECT H.id, H.headerId, H.receiptDetailId, D.materialCode,D.batch,D.lot, H.qty, H.created, H.createdBy
      FROM receipt_container_detail H left join receipt_detail D ON H.receiptDetailId=D.Id
  <where>
    <if test="id != null "> 
        AND H.id = #{id}
    </if>
    <if test="headerId != null "> 
        AND H.headerId = #{headerId}
    </if>
    <if test="receiptDetailId != null "> 
        AND H.receiptDetailId = #{receiptDetailId}
    </if>
    <if test="materialCode != null and materialCode != ''"> 
        <bind name="materialCodePattern" value="'%' + materialCode + '%'" />
        AND D.materialCode like #{materialCodePattern}
    </if>
    <if test="qty != null "> 
        AND H.qty = #{qty}
    </if>
    <if test="params != null and params.createdBegin != null and params.createdBegin != ''"> 
        AND H.created &gt;= #{params.createdBegin}
    </if>
    <if test="params != null and params.createdEnd != null and params.createdEnd != ''"> 
        AND H.created &lt;= #{params.createdEnd}
    </if>
    <if test="createdBy != null and createdBy != ''"> 
        <bind name="createdByPattern" value="'%' + createdBy + '%'" />
        AND H.createdBy like #{createdByPattern}
    </if>
  </where>
  </select>

  <select id="selectListEntityByEqual" resultType="com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail">
   SELECT id, headerId, receiptDetailId, materialCode, qty, created, createdBy  
   FROM receipt_container_detail
  <where>
    <if test="id != null"> 
        AND id = #{id}
    </if>
    <if test="headerId != null"> 
        AND headerId = #{headerId}
    </if>
    <if test="receiptDetailId != null"> 
        AND receiptDetailId = #{receiptDetailId}
    </if>
    <if test="materialCode != null"> 
        AND materialCode = #{materialCode}
    </if>
    <if test="qty != null"> 
        AND qty = #{qty}
    </if>
    <if test="created != null"> 
        AND created = #{created}
    </if>
    <if test="createdBy != null"> 
        AND createdBy = #{createdBy}
    </if>
  </where>
  </select>

  <select id="selectListMapByEqual" resultType="java.util.HashMap">
      SELECT ${columns} FROM receipt_container_detail
  <where>
    <if test="condition.id != null"> 
        AND id = #{condition.id}
    </if>
    <if test="condition.headerId != null"> 
        AND headerId = #{condition.headerId}
    </if>
    <if test="condition.receiptDetailId != null"> 
        AND receiptDetailId = #{condition.receiptDetailId}
    </if>
    <if test="condition.materialCode != null"> 
        AND materialCode = #{condition.materialCode}
    </if>
    <if test="condition.qty != null"> 
        AND qty = #{condition.qty}
    </if>
    <if test="condition.created != null"> 
        AND created = #{condition.created}
    </if>
    <if test="condition.createdBy != null"> 
        AND createdBy = #{condition.createdBy}
    </if>
  </where>
  </select>

  <select id="selectEntityById" resultType="com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail">
      SELECT id, headerId, receiptDetailId, materialCode, qty, created, createdBy  FROM receipt_container_detail WHERE id = #{id}
  </select>

  <select id="selectFirstEntity" resultType="com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail">
  SELECT id, headerId, receiptDetailId, materialCode, qty, created, createdBy  
  FROM receipt_container_detail
  <where>
    <if test="id != null"> 
        AND id = #{id}
    </if>
    <if test="headerId != null"> 
        AND headerId = #{headerId}
    </if>
    <if test="receiptDetailId != null"> 
        AND receiptDetailId = #{receiptDetailId}
    </if>
    <if test="materialCode != null"> 
        AND materialCode = #{materialCode}
    </if>
    <if test="qty != null"> 
        AND qty = #{qty}
    </if>
    <if test="created != null"> 
        AND created = #{created}
    </if>
    <if test="createdBy != null"> 
        AND createdBy = #{createdBy}
    </if>
  </where>
   LIMIT 1 
  </select>

  <select id="selectFirstMap" resultType="java.util.HashMap">
      SELECT ${columns} FROM receipt_container_detail
  <where>
    <if test="condition.id != null"> 
        AND id = #{condition.id}
    </if>
    <if test="condition.headerId != null"> 
        AND headerId = #{condition.headerId}
    </if>
    <if test="condition.receiptDetailId != null"> 
        AND receiptDetailId = #{condition.receiptDetailId}
    </if>
    <if test="condition.materialCode != null"> 
        AND materialCode = #{condition.materialCode}
    </if>
    <if test="condition.qty != null"> 
        AND qty = #{condition.qty}
    </if>
    <if test="condition.created != null"> 
        AND created = #{condition.created}
    </if>
    <if test="condition.createdBy != null"> 
        AND createdBy = #{condition.createdBy}
    </if>
  </where>
   LIMIT 1 
  </select>

  <insert id="insert" parameterType="com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail" keyProperty="id" useGeneratedKeys="true" >
  INSERT INTO receipt_container_detail 
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="headerId != null"> 
        headerId, 
    </if>
    <if test="receiptDetailId != null"> 
        receiptDetailId, 
    </if>
    <if test="materialCode != null"> 
        materialCode, 
    </if>
    <if test="qty != null"> 
        qty, 
    </if>
    <if test="created != null"> 
        created, 
    </if>
    <if test="createdBy != null"> 
        createdBy, 
    </if>
  </trim>
  <trim prefix=" values (" suffix=")" suffixOverrides=",">
    <if test="headerId != null"> 
        #{headerId, jdbcType=INTEGER}, 
    </if>
    <if test="receiptDetailId != null"> 
        #{receiptDetailId, jdbcType=INTEGER}, 
    </if>
    <if test="materialCode != null"> 
        #{materialCode, jdbcType=VARCHAR}, 
    </if>
    <if test="qty != null"> 
        #{qty, jdbcType=DECIMAL}, 
    </if>
    <if test="created != null"> 
        #{created, jdbcType=TIMESTAMP}, 
    </if>
    <if test="createdBy != null"> 
        #{createdBy, jdbcType=VARCHAR}, 
    </if>
  </trim>
  </insert>

  <update id="updateByModel">
  UPDATE receipt_container_detail 
  <set>
    <if test="headerId != null"> 
        headerId = #{headerId, jdbcType=INTEGER}, 
    </if>
    <if test="receiptDetailId != null"> 
        receiptDetailId = #{receiptDetailId, jdbcType=INTEGER}, 
    </if>
    <if test="materialCode != null"> 
        materialCode = #{materialCode, jdbcType=VARCHAR}, 
    </if>
    <if test="qty != null"> 
        qty = #{qty, jdbcType=DECIMAL}, 
    </if>
    <if test="created != null"> 
        created = #{created, jdbcType=TIMESTAMP}, 
    </if>
    <if test="createdBy != null"> 
        createdBy = #{createdBy, jdbcType=VARCHAR}, 
    </if>
  </set>
   WHERE id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateByCondition">
  UPDATE receipt_container_detail 
  <set>
    <if test="record.headerId != null"> 
        headerId = #{record.headerId, jdbcType=INTEGER}, 
    </if>
    <if test="record.receiptDetailId != null"> 
        receiptDetailId = #{record.receiptDetailId, jdbcType=INTEGER}, 
    </if>
    <if test="record.materialCode != null"> 
        materialCode = #{record.materialCode, jdbcType=VARCHAR}, 
    </if>
    <if test="record.qty != null"> 
        qty = #{record.qty, jdbcType=DECIMAL}, 
    </if>
    <if test="record.created != null"> 
        created = #{record.created, jdbcType=TIMESTAMP}, 
    </if>
    <if test="record.createdBy != null"> 
        createdBy = #{record.createdBy, jdbcType=VARCHAR}, 
    </if>
  </set>
  <where>
    <if test="condition.id != null"> 
        AND id = #{condition.id}
    </if>
    <if test="condition.headerId != null"> 
        AND headerId = #{condition.headerId}
    </if>
    <if test="condition.receiptDetailId != null"> 
        AND receiptDetailId = #{condition.receiptDetailId}
    </if>
    <if test="condition.materialCode != null"> 
        AND materialCode = #{condition.materialCode}
    </if>
    <if test="condition.qty != null"> 
        AND qty = #{condition.qty}
    </if>
    <if test="condition.created != null"> 
        AND created = #{condition.created}
    </if>
    <if test="condition.createdBy != null"> 
        AND createdBy = #{condition.createdBy}
    </if>
  </where>
  </update>

  <delete id="deleteById"> 
  DELETE FROM receipt_container_detail WHERE id = #{id, jdbcType=INTEGER} 
  </delete>

  <delete id="deleteByCondition"> 
  DELETE FROM receipt_container_detail 
  <where>
    <if test="id != null"> 
        AND id = #{id}
    </if>
    <if test="headerId != null"> 
        AND headerId = #{headerId}
    </if>
    <if test="receiptDetailId != null"> 
        AND receiptDetailId = #{receiptDetailId}
    </if>
    <if test="materialCode != null"> 
        AND materialCode = #{materialCode}
    </if>
    <if test="qty != null"> 
        AND qty = #{qty}
    </if>
    <if test="created != null"> 
        AND created = #{created}
    </if>
    <if test="createdBy != null"> 
        AND createdBy = #{createdBy}
    </if>
  </where>
  </delete>

  </mapper>