GateMapper.xml 5.35 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.yohobuy.platform.dal.cms.GateDao" >
  <resultMap id="BaseResultMap" type="com.yohobuy.platform.dal.cms.model.Gate" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="meta_key" property="metaKey" jdbcType="VARCHAR" />
    <result column="platform" property="platform" jdbcType="VARCHAR" />
    <result column="title" property="title" jdbcType="VARCHAR" />
    <result column="url" property="url" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="BIT" />
    <result column="create_time" property="createTime" jdbcType="INTEGER" />
    <result column="update_time" property="updateTime" jdbcType="INTEGER" />
    <result column="price" property="price" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, meta_key, platform, title, url, status, create_time, update_time, price
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from gate
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from gate
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yohobuy.platform.dal.cms.model.Gate" >
    insert into gate (id, meta_key, platform, 
      title, url, status, create_time, 
      update_time, price)
    values (#{id,jdbcType=INTEGER}, #{metaKey,jdbcType=VARCHAR}, #{platform,jdbcType=VARCHAR}, 
      #{title,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{status,jdbcType=BIT}, #{createTime,jdbcType=INTEGER}, 
      #{updateTime,jdbcType=INTEGER}, #{price,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.yohobuy.platform.dal.cms.model.Gate" >
    insert into gate
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="metaKey != null" >
        meta_key,
      </if>
      <if test="platform != null" >
        platform,
      </if>
      <if test="title != null" >
        title,
      </if>
      <if test="url != null" >
        url,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
      <if test="price != null" >
        price,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="metaKey != null" >
        #{metaKey,jdbcType=VARCHAR},
      </if>
      <if test="platform != null" >
        #{platform,jdbcType=VARCHAR},
      </if>
      <if test="title != null" >
        #{title,jdbcType=VARCHAR},
      </if>
      <if test="url != null" >
        #{url,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        #{status,jdbcType=BIT},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="price != null" >
        #{price,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yohobuy.platform.dal.cms.model.Gate" >
    update gate
    <set >
      <if test="metaKey != null" >
        meta_key = #{metaKey,jdbcType=VARCHAR},
      </if>
      <if test="platform != null" >
        platform = #{platform,jdbcType=VARCHAR},
      </if>
      <if test="title != null" >
        title = #{title,jdbcType=VARCHAR},
      </if>
      <if test="url != null" >
        url = #{url,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=BIT},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="price != null" >
        price = #{price,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yohobuy.platform.dal.cms.model.Gate" >
    update gate
    set meta_key = #{metaKey,jdbcType=VARCHAR},
      platform = #{platform,jdbcType=VARCHAR},
      title = #{title,jdbcType=VARCHAR},
      url = #{url,jdbcType=VARCHAR},
      status = #{status,jdbcType=BIT},
      update_time = #{updateTime,jdbcType=INTEGER},
      price = #{price,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectCount" resultType="java.lang.Integer">
    SELECT count(*) FROM gate g
    <include refid="WHERE_CONDITION"/>
  </select>

  <select id="selectPage" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" /> FROM gate g
    <include refid="WHERE_CONDITION"/>
    ORDER BY update_time DESC
    limit #{offset}, #{rows}
  </select>

  <sql id="WHERE_CONDITION">
    <if test="condition != null">
      <trim prefix="where" prefixOverrides="and | or">
        1 = 1
        <if test="condition.status != null">
          AND status = #{condition.status}
        </if>
      </trim>
    </if>
  </sql>

</mapper>