DataBlockMapper.xml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.oss.store.db.mapper.DataBlockMapper">
  4. <insert id="save" useGeneratedKeys="true" keyProperty="id">
  5. insert into data_block
  6. (`content_id`,`block_id`,`host`,`absolute_path`,`size`)
  7. values
  8. (#{contentId},#{blockId},#{host},#{absolutePath},#{size})
  9. </insert>
  10. <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
  11. insert into data_block
  12. (`content_id`,`block_id`,`host`,`absolute_path`,`size`)
  13. values
  14. <foreach collection="list" item="item" index="index" separator=",">
  15. (#{item.contentId},#{item.blockId},#{item.host},#{item.absolutePath},#{item.size})
  16. </foreach>
  17. </insert>
  18. <delete id="delete">
  19. delete from data_block
  20. where content_id=#{contentId}
  21. </delete>
  22. <select id="findDataBlocks" resultType="cn.reghao.oss.store.model.po.DataBlock">
  23. select *
  24. from data_block
  25. where id>#{nextId}
  26. limit #{pageSize}
  27. </select>
  28. <select id="findByContentId" resultType="cn.reghao.oss.store.model.po.DataBlock">
  29. select *
  30. from data_block
  31. where content_id=#{contentId}
  32. </select>
  33. <select id="findSubDirCount" resultType="cn.reghao.jutil.jdk.store.SubDirCount">
  34. select relative_dir,count(*) as total
  35. from data_block
  36. group by relative_dir
  37. order by total asc
  38. </select>
  39. <update id="updateParent">
  40. update data_block
  41. set relative_dir=#{relativeDir}
  42. where id=#{id}
  43. </update>
  44. <update id="updateBatch">
  45. update data_block
  46. <trim prefix="set" suffixOverrides=",">
  47. <trim prefix="relative_dir =case" suffix="end,">
  48. <foreach collection="list" item="item" index="index">
  49. when id=#{item.id} then #{item.relativeDir}
  50. </foreach>
  51. </trim>
  52. </trim>
  53. <where>
  54. id in
  55. <foreach collection="list" item="item" separator="," open="(" close=")">
  56. #{item.id}
  57. </foreach>
  58. </where>
  59. </update>
  60. </mapper>