ZbGalleryMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.ZbGalleryMapper">
  6. <resultMap type="com.ruoyi.system.domain.grallery.ZbGallery" id="ZbGalleryResult">
  7. <result property="id" column="id"/>
  8. <result property="name" column="name"/>
  9. <result property="cnName" column="cn_name"/>
  10. <result property="ptName" column="pt_name"/>
  11. <result property="latinName" column="latin_name"/>
  12. <result property="distribution" column="distribution"/>
  13. <result property="host" column="host"/>
  14. <result property="form" column="form"/>
  15. <result property="symptom" column="symptom"/>
  16. <result property="category" column="category"/>
  17. <result property="categoryId" column="category_id"/>
  18. <result property="createBy" column="create_by"/>
  19. <result property="createTime" column="create_time"/>
  20. <result property="updateBy" column="update_by"/>
  21. <result property="updateTime" column="update_time"/>
  22. <result property="remark" column="remark"/>
  23. </resultMap>
  24. <sql id="selectZbGalleryVo">
  25. select id, name, cn_name, pt_name, latin_name, distribution, years, celebrity, host, form, symptom, category, category_id, create_by, create_time, update_by, update_time, remark from zb_gallery
  26. </sql>
  27. <select id="selectZbGalleryList" resultType="com.ruoyi.system.dto.GalleryDto">
  28. SELECT
  29. zg.*,
  30. zgc.`name` categoryName
  31. FROM
  32. zb_gallery zg
  33. JOIN zb_gallery_category zgc on zgc.id = zg.category_id
  34. <where>
  35. <if test="obj != null">
  36. <if test="obj.name != null and obj.name != ''">
  37. and zg.name like concat('%', #{obj.name}, '%')
  38. </if>
  39. <if test="obj.cnName != null and obj.cnName != ''">
  40. and zg.cn_name like concat('%', #{obj.cnName}, '%')
  41. </if>
  42. <if test="obj.ptName != null and obj.ptName != ''">
  43. and zg.pt_name like concat('%', #{obj.ptName}, '%')
  44. </if>
  45. <if test="obj.latinName != null and obj.latinName != ''">
  46. and zg.latin_name like concat('%', #{obj.latinName}, '%')
  47. </if>
  48. <if test="obj.distribution != null and obj.distribution != ''">
  49. and zg.distribution = #{obj.distribution}
  50. </if>
  51. <if test="obj.host != null and obj.host != ''">
  52. and zg.host = #{obj.host}
  53. </if>
  54. <if test="obj.form != null and obj.form != ''">
  55. and zg.form = #{obj.form}
  56. </if>
  57. <if test="obj.symptom != null and obj.symptom != ''">
  58. and zg.symptom = #{obj.symptom}
  59. </if>
  60. <if test="obj.category != null and obj.category != ''">
  61. and zg.category = #{obj.category}
  62. </if>
  63. <if test="obj.categoryId != null ">
  64. and zg.category_id = #{obj.categoryId}
  65. </if>
  66. </if>
  67. </where>
  68. order by zg.create_time DESC
  69. </select>
  70. <resultMap id="GalleryDtoMap" type="com.ruoyi.system.dto.GalleryDto">
  71. <result property="id" column="id"/>
  72. <result property="name" column="name"/>
  73. <result property="cnName" column="cn_name"/>
  74. <result property="ptName" column="pt_name"/>
  75. <result property="latinName" column="latin_name"/>
  76. <result property="distribution" column="distribution"/>
  77. <result property="host" column="host"/>
  78. <result property="years" column="years"/>
  79. <result property="celebrity" column="celebrity"/>
  80. <result property="form" column="form"/>
  81. <result property="symptom" column="symptom"/>
  82. <result property="category" column="category"/>
  83. <result property="categoryId" column="category_id"/>
  84. <result property="remark" column="remark"/>
  85. <result property="categoryName" column="categoryName"/>
  86. <collection property="imgInfos" ofType="com.ruoyi.system.dto.GalleryDto$ImgInfosDTO">
  87. <result property="author" column="author"/>
  88. <result property="location" column="location"/>
  89. <result property="watermarkType" column="watermark_type"/>
  90. <result property="watermarkColor" column="watermark_color"/>
  91. <result property="url" column="url"/>
  92. </collection>
  93. </resultMap>
  94. <select id="selectGalleryDto" resultMap="GalleryDtoMap">
  95. SELECT
  96. zg.*,
  97. zf.url,
  98. zgi.watermark_type,
  99. zgi.location,
  100. zgi.author,
  101. zgc.name categoryName
  102. FROM
  103. zb_gallery zg
  104. LEFT JOIN zb_gallery_img zgi ON zg.id = zgi.gallert_id
  105. LEFT JOIN zb_file zf ON zf.id = zgi.thumb_id
  106. left join zb_gallery_category zgc on zgc.id = zg.category_id
  107. <if test="categoryIds != null and categoryIds.size() > 0">
  108. WHERE zg.category_id in
  109. <foreach collection="categoryIds" open="(" close=")" item="item" separator=",">
  110. #{item}
  111. </foreach>
  112. </if>
  113. </select>
  114. <select id="selectGalleryDtoThumbnail" resultMap="GalleryDtoMap">
  115. SELECT
  116. zg.*,
  117. ifnull(zf.thumbnail_url,zf.url) as url,
  118. zgi.watermark_type,
  119. zgi.location,
  120. zgi.author,
  121. zgc.name categoryName
  122. FROM
  123. zb_gallery zg
  124. LEFT JOIN zb_gallery_img zgi ON zg.id = zgi.gallert_id
  125. LEFT JOIN zb_file zf ON zf.id = zgi.thumb_id
  126. left join zb_gallery_category zgc on zgc.id = zg.category_id
  127. <if test="categoryIds != null and categoryIds.size() > 0">
  128. WHERE zg.category_id in
  129. <foreach collection="categoryIds" open="(" close=")" item="item" separator=",">
  130. #{item}
  131. </foreach>
  132. </if>
  133. ORDER BY zg.name
  134. </select>
  135. <select id="checkCategoryHasValue" resultType="java.lang.Integer">
  136. SELECT
  137. 1
  138. FROM
  139. zb_gallery where category_id = #{categoryId} limit 1
  140. </select>
  141. </mapper>