FileList.xml 3.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="cn.fw.rp.dao.FileListDao">

    <!-- 查询数量 -->
    <select id="selectCount" parameterType="QueryCriterion" resultType="java.lang.Integer">
        select count(1) from file_list
        <include refid="core.where_condition"/>
    </select>

    <!-- 查询,根据主键 -->
    <select id="selectById" parameterType="Long" resultMap="fileListMap">
        select *
        from file_list
        where id = #{id}
    </select>

    <select id="selectByFileId" parameterType="String" resultMap="fileListMap">
        select *
        from file_list
        where file_id = #{fileId}
    </select>

    <!-- 查询列表,根据条件 -->
    <select id="selectList" parameterType="QueryCriterion" resultMap="fileListMap">
        select * from file_list
        <include refid="core.where_condition"/>
        <include refid="core.page_condition"/>
    </select>

    <!-- 更新,根据主键 -->
    <update id="updateById" parameterType="FileList">
        update file_list
        <include refid="update_columns"/>
        where id = #{t.id}
    </update>

    <!-- 更新列表,根据条件 -->
    <update id="updateList">
        update marketing_comment
        <include refid="update_columns"/>
        <include refid="core.where_condition_pre_con"/>
    </update>

    <!-- 新增 -->
    <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="FileList">
        insert into file_list
        (file_id,
         file_name,
         content_type,
         upload_time,
         upload_user,
         file_path,
         flag,
         file_length)
        values (#{fileId},
                #{fileName},
                #{contentType},
                now(),
                #{uploadUser},
                #{filePath},
                #{flag},
                #{fileLength})
    </insert>

    <!-- 删除,根据主键 -->
    <delete id="deleteById" parameterType="Long">
        delete
        from file_list
        where id = #{id}
    </delete>

    <!-- 删除列表,根据条件 -->
    <delete id="deleteList" parameterType="QueryCriterion">
        delete from file_list
        <include refid="core.where_condition"/>
    </delete>

    <!-- 查询结果集 -->
    <resultMap id="fileListMap" type="FileList">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="file_id" jdbcType="INTEGER" property="fileId"/>
        <result column="file_name" jdbcType="VARCHAR" property="fileName"/>
        <result column="content_type" jdbcType="VARCHAR" property="contentType"/>
        <result column="upload_time" jdbcType="VARCHAR" property="uploadTime"/>
        <result column="upload_user" jdbcType="VARCHAR" property="uploadUser"/>
        <result column="file_path" jdbcType="VARCHAR" property="filePath"/>
        <result column="flag" jdbcType="INTEGER" property="flag"/>
        <result column="file_length" jdbcType="INTEGER" property="fileLength"/>
    </resultMap>

    <!-- 更新字段列表 -->
    <sql id="update_columns">
        <set>
            <if test="t.problemId != null"><![CDATA[problem_id =  #{t.problemId},]]></if>
            <if test="t.fileId != null"><![CDATA[file_id =  #{t.fileId},]]></if>
        </set>
    </sql>
</mapper>