<?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="lingtao.net.dao.MyFileMapper">
  <resultMap id="BaseResultMap" type="lingtao.net.bean.MyFile">
    <id column="fileId" jdbcType="INTEGER" property="fileId" />
    <result column="fileName" jdbcType="VARCHAR" property="fileName" />
    <result column="filePath" jdbcType="VARCHAR" property="filePath" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="createBy" jdbcType="VARCHAR" property="createBy" />
    <result column="createDate" jdbcType="TIMESTAMP" property="createDate" />
    <result column="updateBy" jdbcType="VARCHAR" property="updateBy" />
    <result column="updateDate" jdbcType="TIMESTAMP" property="updateDate" />
  </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">
    fileId, fileName, filePath, remark, createBy, createDate, updateBy, updateDate
  </sql>
  <select id="selectByExample" parameterType="lingtao.net.bean.MyFileExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from tbl_file
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tbl_file
    where fileId = #{fileId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tbl_file
    where fileId = #{fileId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="lingtao.net.bean.MyFileExample">
    delete from tbl_file
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="lingtao.net.bean.MyFile">
    insert into tbl_file (fileId, fileName, filePath, 
      remark, createBy, createDate, 
      updateBy, updateDate)
    values (#{fileId,jdbcType=INTEGER}, #{fileName,jdbcType=VARCHAR}, #{filePath,jdbcType=VARCHAR}, 
      #{remark,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, 
      #{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="lingtao.net.bean.MyFile">
    insert into tbl_file
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="fileId != null">
        fileId,
      </if>
      <if test="fileName != null">
        fileName,
      </if>
      <if test="filePath != null">
        filePath,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createBy != null">
        createBy,
      </if>
      <if test="createDate != null">
        createDate,
      </if>
      <if test="updateBy != null">
        updateBy,
      </if>
      <if test="updateDate != null">
        updateDate,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="fileId != null">
        #{fileId,jdbcType=INTEGER},
      </if>
      <if test="fileName != null">
        #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="filePath != null">
        #{filePath,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null">
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="lingtao.net.bean.MyFileExample" resultType="java.lang.Long">
    select count(*) from tbl_file
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update tbl_file
    <set>
      <if test="record.fileId != null">
        fileId = #{record.fileId,jdbcType=INTEGER},
      </if>
      <if test="record.fileName != null">
        fileName = #{record.fileName,jdbcType=VARCHAR},
      </if>
      <if test="record.filePath != null">
        filePath = #{record.filePath,jdbcType=VARCHAR},
      </if>
      <if test="record.remark != null">
        remark = #{record.remark,jdbcType=VARCHAR},
      </if>
      <if test="record.createBy != null">
        createBy = #{record.createBy,jdbcType=VARCHAR},
      </if>
      <if test="record.createDate != null">
        createDate = #{record.createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateBy != null">
        updateBy = #{record.updateBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updateDate != null">
        updateDate = #{record.updateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update tbl_file
    set fileId = #{record.fileId,jdbcType=INTEGER},
      fileName = #{record.fileName,jdbcType=VARCHAR},
      filePath = #{record.filePath,jdbcType=VARCHAR},
      remark = #{record.remark,jdbcType=VARCHAR},
      createBy = #{record.createBy,jdbcType=VARCHAR},
      createDate = #{record.createDate,jdbcType=TIMESTAMP},
      updateBy = #{record.updateBy,jdbcType=VARCHAR},
      updateDate = #{record.updateDate,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="lingtao.net.bean.MyFile">
    update tbl_file
    <set>
      <if test="fileName != null">
        fileName = #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="filePath != null">
        filePath = #{filePath,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        createBy = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        createDate = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        updateBy = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null">
        updateDate = #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where fileId = #{fileId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="lingtao.net.bean.MyFile">
    update tbl_file
    set fileName = #{fileName,jdbcType=VARCHAR},
      filePath = #{filePath,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      createBy = #{createBy,jdbcType=VARCHAR},
      createDate = #{createDate,jdbcType=TIMESTAMP},
      updateBy = #{updateBy,jdbcType=VARCHAR},
      updateDate = #{updateDate,jdbcType=TIMESTAMP}
    where fileId = #{fileId,jdbcType=INTEGER}
  </update>
  
  <!-- 获取所有的文件信息 -->
  <select id="getFileList" parameterType="MyFile" resultMap="BaseResultMap">
		SELECT 
		  a.fileId,
		  a.fileName,
		  a.filePath 
		FROM
		  tbl_file a
  		<where>
  			<if test="fileName != null and fileName !='' ">
  				and fileName like '%${fileName}%'
  			</if>
  		</where>
  </select>
</mapper>