DataBlockMapper.xml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.dfs.store.db.mapper.DataBlockMapper">
  4. <insert id="save" useGeneratedKeys="true" keyProperty="id">
  5. insert into data_block
  6. (`id`,`deleted`,`create_time`,`update_time`,`content_id`,`index`,`block_id`,`absolute_path`,`start`,`end`)
  7. values
  8. (#{id},#{deleted},#{createTime},#{updateTime},#{contentId},#{index},#{blockId},#{absolutePath},#{start},#{end})
  9. </insert>
  10. <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
  11. insert into data_block
  12. (`id`,`deleted`,`create_time`,`update_time`,`content_id`,`index`,`block_id`,`absolute_path`,`start`,`end`)
  13. values
  14. <foreach collection="list" item="item" index="index" separator=",">
  15. (#{item.id},#{item.deleted},#{item.createTime},#{item.updateTime},#{item.contentId},#{item.index},#{item.blockId},#{item.absolutePath},#{item.start},#{item.end})
  16. </foreach>
  17. </insert>
  18. <update id="updateContentId">
  19. update data_block
  20. set content_id=#{contentId}
  21. where object_id=#{objectId}
  22. </update>
  23. <update id="updateBatch">
  24. update data_block
  25. <trim prefix="set" suffixOverrides=",">
  26. <trim prefix="content_id =case" suffix="end,">
  27. <foreach collection="list" item="item" index="index">
  28. when object_id=#{item.objectId} then #{item.contentId}
  29. </foreach>
  30. </trim>
  31. </trim>
  32. <where>
  33. object_id in
  34. <foreach collection="list" item="item" separator="," open="(" close=")">
  35. #{item.objectId}
  36. </foreach>
  37. </where>
  38. </update>
  39. <select id="findAll" resultType="cn.reghao.dfs.store.model.po.DataBlock">
  40. select * from data_block
  41. </select>
  42. <select id="findByObjectId" resultType="cn.reghao.dfs.store.model.po.DataBlock">
  43. select * from data_block
  44. where object_id=#{objectId}
  45. </select>
  46. <select id="findDataBlockByPage" resultType="cn.reghao.dfs.store.model.po.DataBlock">
  47. select data_block.*
  48. from data_block
  49. inner join file_meta
  50. on data_block.object_id=file_meta.object_id
  51. </select>
  52. </mapper>