IMSupplierRefundAddressMapper.xml 9.3 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.sibu.orderHelper.integral.web.dao.IMSupplierRefundAddressDao">
  <resultMap id="BaseResultMap" type="com.sibu.orderHelper.integral.model.IMSupplierRefundAddress">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="supplier_id" jdbcType="VARCHAR" property="supplierId" />
    <result column="contact" jdbcType="VARCHAR" property="contact" />
    <result column="contact_phone" jdbcType="VARCHAR" property="contactPhone" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="refund_standard_remark" jdbcType="VARCHAR" property="refundStandardRemark" />
    <result column="create_dt" jdbcType="TIMESTAMP" property="createDt"/>
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, supplier_id, contact, contact_phone, address, refund_standard_remark
  </sql>

  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from im_supplier_refund_address
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from im_supplier_refund_address
    where id = #{id,jdbcType=VARCHAR}
  </delete>

  <insert id="insert" parameterType="com.sibu.orderHelper.integral.model.IMSupplierRefundAddress">
    insert into im_supplier_refund_address (id, supplier_id, contact, 
      contact_phone, address, refund_standard_remark,create_dt
      )
    values (#{id,jdbcType=VARCHAR}, #{supplierId,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, 
      #{contactPhone,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{refundStandardRemark,jdbcType=VARCHAR},
      NOW()
      )
  </insert>
  <insert id="insertSelective" parameterType="com.sibu.orderHelper.integral.model.IMSupplierRefundAddress">
    insert into im_supplier_refund_address
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="supplierId != null">
        supplier_id,
      </if>
      <if test="contact != null">
        contact,
      </if>
      <if test="contactPhone != null">
        contact_phone,
      </if>
      <if test="address != null">
        address,
      </if>
      <if test="refundStandardRemark != null">
        refund_standard_remark,
      </if>
      create_dt
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="supplierId != null">
        #{supplierId,jdbcType=VARCHAR},
      </if>
      <if test="contact != null">
        #{contact,jdbcType=VARCHAR},
      </if>
      <if test="contactPhone != null">
        #{contactPhone,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="refundStandardRemark != null">
        #{refundStandardRemark,jdbcType=VARCHAR},
      </if>
      NOW()
    </trim>
  </insert>



  <update id="updateByPrimaryKeySelective" parameterType="com.sibu.orderHelper.integral.model.IMSupplierRefundAddress">
    update im_supplier_refund_address
    <set>
      <if test="supplierId != null">
        supplier_id = #{supplierId,jdbcType=VARCHAR},
      </if>
      <if test="contact != null">
        contact = #{contact,jdbcType=VARCHAR},
      </if>
      <if test="contactPhone != null">
        contact_phone = #{contactPhone,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="refundStandardRemark != null">
        refund_standard_remark = #{refundStandardRemark,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sibu.orderHelper.integral.model.IMSupplierRefundAddressRecord">
    update im_supplier_refund_address
    set supplier_id = #{supplierId,jdbcType=VARCHAR},
      contact = #{contact,jdbcType=VARCHAR},
      contact_phone = #{contactPhone,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      refund_standard_remark = #{refundStandardRemark,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <resultMap id="SupplierRefundResultMap" type="com.sibu.orderHelper.integral.model.IMSupplierRefundAddress">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="supplier_id" jdbcType="VARCHAR" property="supplierId" />
    <result column="contact" jdbcType="VARCHAR" property="contact" />
    <result column="contact_phone" jdbcType="VARCHAR" property="contactPhone" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="refund_standard_remark" jdbcType="VARCHAR" property="refundStandardRemark" />
    <result column="supplierName" jdbcType="VARCHAR" property="supplierName" />
    <result column="supplierContact" jdbcType="VARCHAR" property="supplierContact" />
    <result column="supplierContactPhone" jdbcType="VARCHAR" property="supplierContactPhone" />
    <result column="create_dt" jdbcType="TIMESTAMP" property="createDt"/>
  </resultMap>

  <select id="listSupplierRefundAddress" parameterType="map" resultMap="SupplierRefundResultMap">
    SELECT
       sra.`id`,
       sra.`contact`,
       sra.`contact_phone`,
       sra.`address`,
       sra.`refund_standard_remark`,
       s.`name` AS supplierName,
       s.`contact` AS supplierContact,
       s.`contact_phone` AS supplierContactPhone
    FROM im_supplier_refund_address sra
    LEFT JOIN im_supplier s ON s.`id`=sra.`supplier_id`
    where 1=1
    <if test="supplierId != null and supplierId != ''">
      and s.`id`=#{supplierId}
    </if>
    <if test="supplierName != null and supplierName != ''">
       and s.`name` like concat('%',#{supplierName},'%')
    </if>
    <if test="contact != null and contact != ''">
       and sra.`contact` like concat('%',#{contact},'%')
    </if>
    <if test="contactPhone != null and contactPhone != ''">
       and sra.`contact_phone`=#{contactPhone}
    </if>
    <if test="address != null and address != ''">
       and sra.`address` LIKE  concat('%',#{address},'%')
    </if>
    order by sra.create_dt desc
    LIMIT ${pageNow},${pageSize}
  </select>

  <select id="totalSupplierRefundAddress" parameterType="map" resultType="java.lang.Integer">
    SELECT  count(*)  FROM im_supplier_refund_address sra
    LEFT JOIN im_supplier s ON s.`id`=sra.`supplier_id`
    where 1=1
    <if test="supplierId != null and supplierId != ''">
      and s.`id`=#{supplierId}
    </if>
    <if test="supplierName != null and supplierName != ''">
      and s.`name` like concat('%',#{supplierName},'%')
    </if>
    <if test="contact != null and contact != ''">
      and sra.`contact` like concat('%',#{contact},'%')
    </if>
    <if test="contactPhone != null and contactPhone != ''">
      and sra.`contact_phone`=#{contactPhone}
    </if>
    <if test="address != null and address != ''">
      and sra.`address` LIKE  concat('%',#{address},'%')
    </if>
  </select>
</mapper>