AddressMapperAuto.xml 5.33 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.config.address.mapper.AddressMapperAuto">
  <select id="selectListEntityByLike" resultType="com.huaheng.pc.config.address.domain.Address">
   SELECT id, warehouseCode, param, url  
   FROM address
  <where>
    <if test="id != null "> 
        AND id = #{id}
    </if>
    <if test="warehouseCode != null and warehouseCode != '' "> 
        AND warehouseCode = #{warehouseCode}
    </if>
    <if test="param != null and param != ''"> 
        <bind name="paramPattern" value="'%' + param + '%'" />
        AND param like #{paramPattern}
    </if>
    <if test="url != null and url != ''"> 
        <bind name="urlPattern" value="'%' + url + '%'" />
        AND url like #{urlPattern}
    </if>
  </where>
  </select>

  <select id="selectListEntityByEqual" resultType="com.huaheng.pc.config.address.domain.Address">
   SELECT id, warehouseCode, param, url  
   FROM address
  <where>
    <if test="id != null"> 
        AND id = #{id}
    </if>
    <if test="warehouseCode != null"> 
        AND warehouseCode = #{warehouseCode}
    </if>
    <if test="param != null"> 
        AND param = #{param}
    </if>
    <if test="url != null"> 
        AND url = #{url}
    </if>
  </where>
  </select>

  <select id="selectListMapByEqual" resultType="java.util.HashMap">
      SELECT ${columns} FROM address
  <where>
    <if test="condition.id != null"> 
        AND id = #{condition.id}
    </if>
    <if test="condition.warehouseCode != null"> 
        AND warehouseCode = #{condition.warehouseCode}
    </if>
    <if test="condition.param != null"> 
        AND param = #{condition.param}
    </if>
    <if test="condition.url != null"> 
        AND url = #{condition.url}
    </if>
  </where>
  </select>

  <select id="selectEntityById" resultType="com.huaheng.pc.config.address.domain.Address">
      SELECT id, warehouseCode, param, url  FROM address WHERE id = #{id}
  </select>

  <select id="selectFirstEntity" resultType="com.huaheng.pc.config.address.domain.Address">
  SELECT id, warehouseCode, param, url  
  FROM address
  <where>
    <if test="id != null"> 
        AND id = #{id}
    </if>
    <if test="warehouseCode != null"> 
        AND warehouseCode = #{warehouseCode}
    </if>
    <if test="param != null"> 
        AND param = #{param}
    </if>
    <if test="url != null"> 
        AND url = #{url}
    </if>
  </where>
   LIMIT 1 
  </select>

  <select id="selectFirstMap" resultType="java.util.HashMap">
      SELECT ${columns} FROM address
  <where>
    <if test="condition.id != null"> 
        AND id = #{condition.id}
    </if>
    <if test="condition.warehouseCode != null"> 
        AND warehouseCode = #{condition.warehouseCode}
    </if>
    <if test="condition.param != null"> 
        AND param = #{condition.param}
    </if>
    <if test="condition.url != null"> 
        AND url = #{condition.url}
    </if>
  </where>
   LIMIT 1 
  </select>

  <insert id="insert" parameterType="com.huaheng.pc.config.address.domain.Address" keyProperty="id" useGeneratedKeys="true" >
  INSERT INTO address 
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="warehouseCode != null"> 
        warehouseCode, 
    </if>
    <if test="param != null"> 
        param, 
    </if>
    <if test="url != null"> 
        url, 
    </if>
  </trim>
  <trim prefix=" values (" suffix=")" suffixOverrides=",">
    <if test="warehouseCode != null"> 
        #{warehouseCode, jdbcType=VARCHAR}, 
    </if>
    <if test="param != null"> 
        #{param, jdbcType=VARCHAR}, 
    </if>
    <if test="url != null"> 
        #{url, jdbcType=VARCHAR}, 
    </if>
  </trim>
  </insert>

  <update id="updateByModel">
  UPDATE address 
  <set>
    <if test="warehouseCode != null"> 
        warehouseCode = #{warehouseCode, jdbcType=VARCHAR}, 
    </if>
    <if test="param != null"> 
        param = #{param, jdbcType=VARCHAR}, 
    </if>
    <if test="url != null"> 
        url = #{url, jdbcType=VARCHAR}, 
    </if>
  </set>
   WHERE id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateByCondition">
  UPDATE address 
  <set>
    <if test="record.warehouseCode != null"> 
        warehouseCode = #{record.warehouseCode, jdbcType=VARCHAR}, 
    </if>
    <if test="record.param != null"> 
        param = #{record.param, jdbcType=VARCHAR}, 
    </if>
    <if test="record.url != null"> 
        url = #{record.url, jdbcType=VARCHAR}, 
    </if>
  </set>
  <where>
    <if test="condition.id != null"> 
        AND id = #{condition.id}
    </if>
    <if test="condition.warehouseCode != null"> 
        AND warehouseCode = #{condition.warehouseCode}
    </if>
    <if test="condition.param != null"> 
        AND param = #{condition.param}
    </if>
    <if test="condition.url != null"> 
        AND url = #{condition.url}
    </if>
  </where>
  </update>

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

  <delete id="deleteByCondition"> 
  DELETE FROM address 
  <where>
    <if test="id != null"> 
        AND id = #{id}
    </if>
    <if test="warehouseCode != null"> 
        AND warehouseCode = #{warehouseCode}
    </if>
    <if test="param != null"> 
        AND param = #{param}
    </if>
    <if test="url != null"> 
        AND url = #{url}
    </if>
  </where>
  </delete>

  </mapper>