DiskFileMapper.xml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.reghao.tnb.content.app.disk.db.mapper.DiskFileMapper">
  4. <insert id="save" useGeneratedKeys="true" keyProperty="id">
  5. insert into my_disk_file
  6. (`channel_code`,`file_id`,`pid`,`path`,`filename`,`file_type`,`sha256sum`,`size`,`owner`)
  7. values
  8. (#{channelCode},#{fileId},#{pid},#{path},#{filename},#{fileType},#{sha256sum},#{size},#{owner})
  9. </insert>
  10. <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
  11. insert into my_disk_file
  12. (`channel_code`,`file_id`,`pid`,`path`,`filename`,`file_type`,`sha256sum`,`size`,`owner`)
  13. values
  14. <foreach collection="list" item="item" index="index" separator=",">
  15. (#{item.channelCode},#{item.fileId},#{item.pid},#{item.path},#{item.filename},#{item.fileType},#{item.sha256sum},#{item.size},#{item.owner})
  16. </foreach>
  17. </insert>
  18. <delete id="deleteByAlbumIdAndPostId">
  19. delete from my_disk_file
  20. where album_id=#{albumId} and post_id=#{postId}
  21. </delete>
  22. <select id="countByDiskQuery" resultType="java.lang.Integer">
  23. select count(*)
  24. from my_disk_file
  25. <where>
  26. deleted=0
  27. <if test="fileType != null">
  28. and file_type=#{fileType}
  29. </if>
  30. <if test="owner != null">
  31. and owner=#{owner}
  32. </if>
  33. <if test="pid != null">
  34. and pid=#{pid}
  35. </if>
  36. <if test="fileId != null">
  37. and file_id=#{fileId}
  38. </if>
  39. <if test="path != null">
  40. and path=#{path}
  41. </if>
  42. <if test="sha256sum != null">
  43. and sha256sum=#{sha256sum}
  44. </if>
  45. </where>
  46. </select>
  47. <select id="findDiskQueryByPage" resultType="cn.reghao.tnb.content.app.disk.model.po.DiskFile">
  48. select *
  49. from my_disk_file
  50. <where>
  51. deleted=0
  52. <if test="diskQuery.fileType != null">
  53. and file_type=#{diskQuery.fileType}
  54. </if>
  55. <if test="diskQuery.owner != null">
  56. and owner=#{diskQuery.owner}
  57. </if>
  58. <if test="diskQuery.pid != null">
  59. and pid=#{diskQuery.pid}
  60. </if>
  61. <if test="diskQuery.fileId != null">
  62. and file_id=#{diskQuery.fileId}
  63. </if>
  64. <if test="diskQuery.path != null">
  65. and path=#{diskQuery.path}
  66. </if>
  67. <if test="diskQuery.sha256sum != null">
  68. and sha256sum=#{diskQuery.sha256sum}
  69. </if>
  70. </where>
  71. order by file_type,filename
  72. </select>
  73. <select id="findFileTypeCountByGroup" resultType="cn.reghao.tnb.content.app.disk.model.vo.DiskFileCount">
  74. select file,count(*) as total
  75. from my_disk_file
  76. group by file_type
  77. order by total desc
  78. </select>
  79. <select id="findByFileIds" resultType="cn.reghao.tnb.content.app.disk.model.po.DiskFile">
  80. select *
  81. from my_disk_file
  82. where file_id in
  83. <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
  84. #{id}
  85. </foreach>
  86. </select>
  87. </mapper>