123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?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.xzl.web.mapper.KnowledgeFileMapper">
- <resultMap type="KnowledgeFile" id="SysFileResult">
- <result property="fileId" column="file_id" />
- <result property="folderId" column="folder_id" />
- <result property="fileName" column="file_name" />
- <result property="fileType" column="file_type" />
- <result property="fileSize" column="file_size" />
- <result property="filePath" column="file_path" />
- <result property="downloadCount" column="download_count" />
- <result property="status" column="status" />
- <result property="delFlag" column="del_flag" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <!-- 添加文件夹名称映射 -->
- <result property="folderName" column="folder_name" />
- </resultMap>
- <sql id="selectSysFileVo">
- select file_id, folder_id, file_name, file_type, file_size, file_path, download_count, status, del_flag, create_by, create_time, update_by, update_time from sys_file
- </sql>
- <select id="selectSysFileList" parameterType="KnowledgeFile" resultMap="SysFileResult">
- SELECT
- a.*,b.folder_name
- FROM
- sys_file a
- LEFT JOIN sys_file_folder b on a.folder_id=b.folder_id
- <where>
- <if test="folderId != null "> and a.folder_id = #{folderId}</if>
- <if test="fileName != null and fileName != ''"> and a.file_name like concat('%', #{fileName}, '%')</if>
- <if test="fileType != null and fileType != ''"> and a.file_type = #{fileType}</if>
- <if test="fileSize != null "> and a.file_size = #{fileSize}</if>
- <if test="filePath != null and filePath != ''"> and a.file_path = #{filePath}</if>
- <if test="downloadCount != null "> and a.download_count = #{downloadCount}</if>
- <if test="status != null and status != ''"> and a.status = #{status}</if>
- </where>
- </select>
- <select id="selectSysFileByFileId" parameterType="Long" resultMap="SysFileResult">
- <include refid="selectSysFileVo"/>
- where file_id = #{fileId}
- </select>
- <insert id="insertSysFile" parameterType="KnowledgeFile" useGeneratedKeys="true" keyProperty="fileId">
- insert into sys_file
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="folderId != null">folder_id,</if>
- <if test="fileName != null and fileName != ''">file_name,</if>
- <if test="fileType != null">file_type,</if>
- <if test="fileSize != null">file_size,</if>
- <if test="filePath != null">file_path,</if>
- <if test="downloadCount != null">download_count,</if>
- <if test="status != null">status,</if>
- <if test="delFlag != null">del_flag,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="folderId != null">#{folderId},</if>
- <if test="fileName != null and fileName != ''">#{fileName},</if>
- <if test="fileType != null">#{fileType},</if>
- <if test="fileSize != null">#{fileSize},</if>
- <if test="filePath != null">#{filePath},</if>
- <if test="downloadCount != null">#{downloadCount},</if>
- <if test="status != null">#{status},</if>
- <if test="delFlag != null">#{delFlag},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- </trim>
- </insert>
- <update id="updateSysFile" parameterType="KnowledgeFile">
- update sys_file
- <trim prefix="SET" suffixOverrides=",">
- <if test="folderId != null">folder_id = #{folderId},</if>
- <if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
- <if test="fileType != null">file_type = #{fileType},</if>
- <if test="fileSize != null">file_size = #{fileSize},</if>
- <if test="filePath != null">file_path = #{filePath},</if>
- <if test="downloadCount != null">download_count = #{downloadCount},</if>
- <if test="status != null">status = #{status},</if>
- <if test="delFlag != null">del_flag = #{delFlag},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </trim>
- where file_id = #{fileId}
- </update>
- <delete id="deleteSysFileByFileId" parameterType="Long">
- delete from sys_file where file_id = #{fileId}
- </delete>
- <delete id="deleteSysFileByFileIds" parameterType="String">
- delete from sys_file where file_id in
- <foreach item="fileId" collection="array" open="(" separator="," close=")">
- #{fileId}
- </foreach>
- </delete>
- <update id="updateSysFileStatus">
- UPDATE sys_file
- SET status = #{status}, update_time = now()
- WHERE file_id = #{fileId}
- </update>
- </mapper>
|