SysOrderFileMapper.xml 4.85 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.glsx.ordercenter.mapper.SysOrderFileMapper">
  <resultMap id="BaseResultMap" type="com.glsx.ordercenter.pojo.SysOrderFile">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="order_id" jdbcType="INTEGER" property="orderId" />
    <result column="file_path" jdbcType="VARCHAR" property="filePath" />
    <result column="file_type" jdbcType="TINYINT" property="fileType" />
    <result column="sort" jdbcType="TINYINT" property="sort" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, order_id, file_path, file_type, sort, create_by, create_time
  </sql>
 
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from sys_order_file
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from sys_order_file
    where id = #{id,jdbcType=INTEGER}
  </delete>

  <insert id="insert" parameterType="com.glsx.ordercenter.pojo.SysOrderFile">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_order_file (order_id, file_path, file_type, 
      sort, create_by, create_time
      )
    values (#{orderId,jdbcType=INTEGER}, #{filePath,jdbcType=VARCHAR}, #{fileType,jdbcType=TINYINT}, 
      #{sort,jdbcType=TINYINT}, #{createBy,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.glsx.ordercenter.pojo.SysOrderFile">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_order_file
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderId != null">
        order_id,
      </if>
      <if test="filePath != null">
        file_path,
      </if>
      <if test="fileType != null">
        file_type,
      </if>
      <if test="sort != null">
        sort,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderId != null">
        #{orderId,jdbcType=INTEGER},
      </if>
      <if test="filePath != null">
        #{filePath,jdbcType=VARCHAR},
      </if>
      <if test="fileType != null">
        #{fileType,jdbcType=TINYINT},
      </if>
      <if test="sort != null">
        #{sort,jdbcType=TINYINT},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.glsx.ordercenter.pojo.SysOrderFile">
    update sys_order_file
    <set>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=INTEGER},
      </if>
      <if test="filePath != null">
        file_path = #{filePath,jdbcType=VARCHAR},
      </if>
      <if test="fileType != null">
        file_type = #{fileType,jdbcType=TINYINT},
      </if>
      <if test="sort != null">
        sort = #{sort,jdbcType=TINYINT},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.glsx.ordercenter.pojo.SysOrderFile">
    update sys_order_file
    set order_id = #{orderId,jdbcType=INTEGER},
      file_path = #{filePath,jdbcType=VARCHAR},
      file_type = #{fileType,jdbcType=TINYINT},
      sort = #{sort,jdbcType=TINYINT},
      create_by = #{createBy,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <insert id="addOrderFileList" keyProperty="id" useGeneratedKeys="true">
  	 insert into sys_order_file (order_id, file_path, file_type, 
      sort, create_by, create_time
      )
    values 
    <foreach item="item" collection="fileList" separator=",">
     (#{item.orderId,jdbcType=INTEGER}, #{item.filePath,jdbcType=VARCHAR}, #{item.fileType,jdbcType=TINYINT}, 
      #{item.sort,jdbcType=TINYINT}, #{item.createBy,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}
      )
     </foreach>
  </insert>
</mapper>