KnowledgeFileMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.xzl.web.mapper.KnowledgeFileMapper">
  6. <resultMap type="KnowledgeFile" id="SysFileResult">
  7. <result property="fileId" column="file_id" />
  8. <result property="folderId" column="folder_id" />
  9. <result property="fileName" column="file_name" />
  10. <result property="fileType" column="file_type" />
  11. <result property="fileSize" column="file_size" />
  12. <result property="filePath" column="file_path" />
  13. <result property="downloadCount" column="download_count" />
  14. <result property="status" column="status" />
  15. <result property="delFlag" column="del_flag" />
  16. <result property="createBy" column="create_by" />
  17. <result property="createTime" column="create_time" />
  18. <result property="updateBy" column="update_by" />
  19. <result property="updateTime" column="update_time" />
  20. <!-- 添加文件夹名称映射 -->
  21. <result property="folderName" column="folder_name" />
  22. </resultMap>
  23. <sql id="selectSysFileVo">
  24. 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
  25. </sql>
  26. <select id="selectSysFileList" parameterType="KnowledgeFile" resultMap="SysFileResult">
  27. SELECT
  28. a.*,b.folder_name
  29. FROM
  30. sys_file a
  31. LEFT JOIN sys_file_folder b on a.folder_id=b.folder_id
  32. <where>
  33. <if test="folderId != null "> and a.folder_id = #{folderId}</if>
  34. <if test="fileName != null and fileName != ''"> and a.file_name like concat('%', #{fileName}, '%')</if>
  35. <if test="fileType != null and fileType != ''"> and a.file_type = #{fileType}</if>
  36. <if test="fileSize != null "> and a.file_size = #{fileSize}</if>
  37. <if test="filePath != null and filePath != ''"> and a.file_path = #{filePath}</if>
  38. <if test="downloadCount != null "> and a.download_count = #{downloadCount}</if>
  39. <if test="status != null and status != ''"> and a.status = #{status}</if>
  40. </where>
  41. </select>
  42. <select id="selectSysFileByFileId" parameterType="Long" resultMap="SysFileResult">
  43. <include refid="selectSysFileVo"/>
  44. where file_id = #{fileId}
  45. </select>
  46. <insert id="insertSysFile" parameterType="KnowledgeFile" useGeneratedKeys="true" keyProperty="fileId">
  47. insert into sys_file
  48. <trim prefix="(" suffix=")" suffixOverrides=",">
  49. <if test="folderId != null">folder_id,</if>
  50. <if test="fileName != null and fileName != ''">file_name,</if>
  51. <if test="fileType != null">file_type,</if>
  52. <if test="fileSize != null">file_size,</if>
  53. <if test="filePath != null">file_path,</if>
  54. <if test="downloadCount != null">download_count,</if>
  55. <if test="status != null">status,</if>
  56. <if test="delFlag != null">del_flag,</if>
  57. <if test="createBy != null">create_by,</if>
  58. <if test="createTime != null">create_time,</if>
  59. <if test="updateBy != null">update_by,</if>
  60. <if test="updateTime != null">update_time,</if>
  61. </trim>
  62. <trim prefix="values (" suffix=")" suffixOverrides=",">
  63. <if test="folderId != null">#{folderId},</if>
  64. <if test="fileName != null and fileName != ''">#{fileName},</if>
  65. <if test="fileType != null">#{fileType},</if>
  66. <if test="fileSize != null">#{fileSize},</if>
  67. <if test="filePath != null">#{filePath},</if>
  68. <if test="downloadCount != null">#{downloadCount},</if>
  69. <if test="status != null">#{status},</if>
  70. <if test="delFlag != null">#{delFlag},</if>
  71. <if test="createBy != null">#{createBy},</if>
  72. <if test="createTime != null">#{createTime},</if>
  73. <if test="updateBy != null">#{updateBy},</if>
  74. <if test="updateTime != null">#{updateTime},</if>
  75. </trim>
  76. </insert>
  77. <update id="updateSysFile" parameterType="KnowledgeFile">
  78. update sys_file
  79. <trim prefix="SET" suffixOverrides=",">
  80. <if test="folderId != null">folder_id = #{folderId},</if>
  81. <if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
  82. <if test="fileType != null">file_type = #{fileType},</if>
  83. <if test="fileSize != null">file_size = #{fileSize},</if>
  84. <if test="filePath != null">file_path = #{filePath},</if>
  85. <if test="downloadCount != null">download_count = #{downloadCount},</if>
  86. <if test="status != null">status = #{status},</if>
  87. <if test="delFlag != null">del_flag = #{delFlag},</if>
  88. <if test="createBy != null">create_by = #{createBy},</if>
  89. <if test="createTime != null">create_time = #{createTime},</if>
  90. <if test="updateBy != null">update_by = #{updateBy},</if>
  91. <if test="updateTime != null">update_time = #{updateTime},</if>
  92. </trim>
  93. where file_id = #{fileId}
  94. </update>
  95. <delete id="deleteSysFileByFileId" parameterType="Long">
  96. delete from sys_file where file_id = #{fileId}
  97. </delete>
  98. <delete id="deleteSysFileByFileIds" parameterType="String">
  99. delete from sys_file where file_id in
  100. <foreach item="fileId" collection="array" open="(" separator="," close=")">
  101. #{fileId}
  102. </foreach>
  103. </delete>
  104. <update id="updateSysFileStatus">
  105. UPDATE sys_file
  106. SET status = #{status}, update_time = now()
  107. WHERE file_id = #{fileId}
  108. </update>
  109. </mapper>