SmsbVersionPackageMapper.xml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.inspur.source.mapper.SmsbVersionPackageMapper">
  6. <select id="selectVoPageWithTreeName" resultType="com.inspur.source.domain.vo.SmsbVersionPackageVo" parameterType="com.inspur.source.domain.bo.SmsbVersionPackageBo">
  7. WITH RECURSIVE category_path AS (
  8. SELECT
  9. id,
  10. NAME,
  11. parent_id,
  12. id AS leaf_id,
  13. 1 AS LEVEL
  14. FROM smsb_version_tree
  15. UNION ALL
  16. -- 向上递归
  17. SELECT
  18. t.id,
  19. t.NAME,
  20. t.parent_id,
  21. cp.leaf_id,
  22. cp.LEVEL + 1
  23. FROM smsb_version_tree t
  24. INNER JOIN category_path cp ON t.id = cp.parent_id
  25. )
  26. SELECT
  27. p.id AS id,
  28. p.version_name,
  29. p.version_code,
  30. p.file_size ,
  31. p.file_name,
  32. p.file_url,
  33. p.md5,
  34. p.tree_id,
  35. p.tree_ids,
  36. p.remark,
  37. p.create_time,
  38. p.create_by,
  39. p.update_time,
  40. GROUP_CONCAT(cp.name ORDER BY cp.level DESC SEPARATOR '/') AS tree_name
  41. FROM smsb_version_package p
  42. JOIN category_path cp
  43. ON p.tree_id = cp.leaf_id
  44. WHERE 1 = 1
  45. <if test="bo.versionName != null">
  46. AND p.version_name LIKE CONCAT('%', #{bo.versionName}, '%')
  47. </if>
  48. <if test="bo.versionCode != null">
  49. AND p.version_code LIKE CONCAT('%', #{bo.versionCode}, '%')
  50. </if>
  51. GROUP BY
  52. p.id
  53. order by p.id desc
  54. </select>
  55. </mapper>