ZbGalleryCategoryMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.ruoyi.system.mapper.ZbGalleryCategoryMapper">
  6. <resultMap type="com.ruoyi.system.domain.grallery.ZbGalleryCategory" id="ZbGalleryCategoryResult">
  7. <result property="id" column="id"/>
  8. <result property="name" column="name"/>
  9. <result property="code" column="code"/>
  10. <result property="thumbnailId" column="thumbnail_id"/>
  11. <result property="top" column="top"/>
  12. <result property="parentId" column="parent_id"/>
  13. <result property="createBy" column="create_by"/>
  14. <result property="createTime" column="create_time"/>
  15. <result property="updateBy" column="update_by"/>
  16. <result property="updateTime" column="update_time"/>
  17. <result property="remark" column="remark"/>
  18. <result property="show" column="show"/>
  19. </resultMap>
  20. <sql id="selectZbGalleryCategoryVo">
  21. select id, name, code, thumbnail_id, top, parent_id, create_by, create_time, update_by, update_time, remark, show from zb_gallery_category
  22. </sql>
  23. <select id="selectZbGalleryCategoryList" parameterType="com.ruoyi.system.domain.grallery.ZbGalleryCategory"
  24. resultMap="ZbGalleryCategoryResult">
  25. <include refid="selectZbGalleryCategoryVo"/>
  26. <where>
  27. <if test="obj != null">
  28. <if test="obj.name != null and obj.name != ''">
  29. and name like concat('%', #{obj.name}, '%')
  30. </if>
  31. <if test="obj.thumbnailId != null ">
  32. and thumbnail_id = #{obj.thumbnailId}
  33. </if>
  34. <if test="obj.top != null ">
  35. and top = #{obj.top}
  36. </if>
  37. <if test="obj.parentId != null ">
  38. and parent_id = #{obj.parentId}
  39. </if>
  40. </if>
  41. </where>
  42. order by sort, name
  43. </select>
  44. <select id="selectGalleryCategory" resultType="com.ruoyi.system.dto.GalleryCategoryDto">
  45. SELECT
  46. zgc.*,
  47. zgcp.NAME AS parent,
  48. zf.url as thumbnail
  49. FROM
  50. zb_gallery_category zgc
  51. LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
  52. LEFT JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
  53. <where>
  54. <if test="obj != null">
  55. <if test="obj.name != null and obj.name != ''">
  56. and zgc.name like concat('%', #{obj.name}, '%')
  57. </if>
  58. <if test="obj.parentId != null ">
  59. and zgc.parent_id = #{obj.parentId}
  60. </if>
  61. </if>
  62. </where>
  63. order by zgc.sort , zgc.name
  64. </select>
  65. <select id="getDetailById" resultType="com.ruoyi.system.dto.GalleryCategoryDto">
  66. SELECT
  67. zgc.*,
  68. zgcp.name AS parent,
  69. zf.url as thumbnail
  70. FROM
  71. zb_gallery_category zgc
  72. LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
  73. LEFT JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
  74. where 1=1 and zgc.id = #{categoryId}
  75. </select>
  76. <select id="selectGalleryCategoryByParentCode" resultType="com.ruoyi.system.dto.GalleryCategoryDto">
  77. SELECT
  78. zgc.*,
  79. zgcp.name AS parent,
  80. zf.url as thumbnail
  81. FROM
  82. zb_gallery_category zgc
  83. JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
  84. LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
  85. where 1=1 and zgcp.code = #{categoryCode} and zgcp.top = 1
  86. order by zgc.sort, zgc.name
  87. </select>
  88. <select id="getByParentIds" resultType="com.ruoyi.system.dto.GalleryCategoryDto">
  89. SELECT
  90. zgc.*,
  91. zgcp.name AS parent,
  92. zf.url as thumbnail
  93. FROM
  94. zb_gallery_category zgc
  95. LEFT JOIN zb_file zf ON zgc.thumbnail_id = zf.id
  96. LEFT JOIN zb_gallery_category zgcp ON zgc.parent_id = zgcp.id
  97. where 1=1 and zgc.parent_id in
  98. <foreach collection="parentIds" item="item" open="(" close=")" separator=",">
  99. #{item}
  100. </foreach>
  101. order by zgc.sort, zgc.name
  102. </select>
  103. <select id="checkHasChildren" resultType="java.lang.Integer">
  104. select 1 from zb_gallery_category where parent_id = #{parentId} limit 1
  105. </select>
  106. <select id="getChildrens" resultType="java.lang.String">
  107. select getCategoryChildLst(#{parentId}) as childs
  108. </select>
  109. </mapper>