NavigationDao.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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="com.backendsys.modules.cms.navigation.dao.NavigationDao">
  4. <sql id="includeNavigation">
  5. n.id id,
  6. n.id navigation_id,
  7. n.parent_id parent_id,
  8. nt.navigation_name navigation_name,
  9. COALESCE(nt.link, '') link,
  10. n.sort sort,
  11. n.is_blank is_blank
  12. </sql>
  13. <sql id="includeNavigationDetail">
  14. n.id id,
  15. n.id navigation_id,
  16. n.parent_id parent_id,
  17. n.sort sort,
  18. n.is_blank is_blank
  19. </sql>
  20. <sql id="includeNavigationTranslation">
  21. id, navigation_id, language, navigation_name, link
  22. </sql>
  23. <resultMap id="resultMapNavigation" type="java.util.LinkedHashMap">
  24. <id property="id" column="id" jdbcType="BIGINT" />
  25. <result property="navigation_id" column="navigation_id" javaType="java.lang.Long" />
  26. <result property="parent_id" column="parent_id" javaType="java.lang.Long" />
  27. <result property="navigation_name" column="navigation_name" />
  28. <result property="link" column="link" />
  29. <result property="sort" column="sort" javaType="java.lang.Integer" />
  30. <result property="is_blank" column="is_blank" javaType="java.lang.Integer" />
  31. </resultMap>
  32. <resultMap id="resultMapNavigationDetail" type="java.util.LinkedHashMap">
  33. <id property="id" column="id" jdbcType="BIGINT" />
  34. <result property="navigation_id" column="navigation_id" javaType="java.lang.Long" />
  35. <result property="parent_id" column="parent_id" javaType="java.lang.Long" />
  36. <result property="navigation_name" column="navigation_name" />
  37. <result property="link" column="link" />
  38. <result property="sort" column="sort" javaType="java.lang.Integer" />
  39. <result property="is_blank" column="is_blank" javaType="java.lang.Integer" />
  40. <collection property="translations" javaType="java.util.List"
  41. select="queryTranslationsById" column="id">
  42. <id property="id" column="id" />
  43. <result property="navigation_name" column="navigation_name" />
  44. <result property="link" column="link" />
  45. </collection>
  46. </resultMap>
  47. <sql id="leftJoinTranslations">
  48. LEFT JOIN cms_navigation_i18n nt ON n.id = nt.navigation_id
  49. </sql>
  50. <!-- 查 列表 -->
  51. <select id="selectNavigationList" resultMap="resultMapNavigation">
  52. SELECT
  53. <include refid="includeNavigation" />
  54. FROM cms_navigation n
  55. <include refid="leftJoinTranslations" />
  56. <where>
  57. nt.language = #{lang}
  58. <if test="navigation_name != null and navigation_name != ''">
  59. AND nt.navigation_name LIKE CONCAT('%', #{navigation_name}, '%')
  60. </if>
  61. </where>
  62. ORDER BY n.sort DESC
  63. </select>
  64. <!-- 查 详情 (带翻译 Array) (二次查询) -->
  65. <select id="selectNavigationDetail" resultMap="resultMapNavigationDetail">
  66. SELECT <include refid="includeNavigationDetail" />
  67. FROM cms_navigation n
  68. <where>
  69. <if test="navigation_id != null and navigation_id != ''">
  70. AND n.id = #{navigation_id}
  71. </if>
  72. </where>
  73. </select>
  74. <!-- 查 翻译集合 (子查询) -->
  75. <select id="queryTranslationsById" resultType="java.util.LinkedHashMap">
  76. SELECT <include refid="includeNavigationTranslation" />
  77. FROM cms_navigation_i18n
  78. WHERE navigation_id = #{id}
  79. </select>
  80. <!-- 查 详情 (公共) (带翻译 Object) (关联查询) -->
  81. <!-- <select id="queryNavigationDetailPublic" resultMap="resultMapNavigation">-->
  82. <!-- SELECT <include refid="includeNavigation" />-->
  83. <!-- FROM cms_navigation n-->
  84. <!-- <include refid="leftJoinTranslations" />-->
  85. <!-- WHERE nt.language = #{lang}-->
  86. <!-- </select>-->
  87. <!-- 创建 -->
  88. <!-- <insert id="insertNavigation" parameterType="com.backendsys.modules.cms.navigation.entity."-->
  89. <!-- useGeneratedKeys="true" keyProperty="navigation_id">-->
  90. <!-- INSERT INTO cms_navigation (-->
  91. <!-- <if test="parent_id != null and parent_id != ''">, parent_id</if>-->
  92. <!-- <if test="sort != null and sort != ''">, sort</if>-->
  93. <!-- <if test="is_blank != null and is_blank != ''">, is_blank</if>-->
  94. <!-- )-->
  95. <!-- VALUES (-->
  96. <!-- <if test="parent_id != null and parent_id != ''">, #{parent_id}</if>-->
  97. <!-- <if test="sort != null and sort != ''">, #{sort}</if>-->
  98. <!-- <if test="is_blank != null and is_blank != ''">, #{is_blank}</if>-->
  99. <!-- );-->
  100. <!-- </insert>-->
  101. <!-- 创建翻译 -->
  102. <!-- <insert id="insertNavigationTranslations" parameterType="com.backendcms.entity.Cms.CmsNavigationI18nDTO.TranslationsDTO">-->
  103. <!-- INSERT INTO cms_navigation_i18n (navigation_id, language, navigation_name, link)-->
  104. <!-- VALUES-->
  105. <!-- <foreach collection="translations" item="translation" separator=",">-->
  106. <!-- (#{translation.navigation_id}, #{translation.language}, #{translation.navigation_name}, #{translation.link})-->
  107. <!-- </foreach>-->
  108. <!-- </insert>-->
  109. <!-- 编辑 -->
  110. <!-- <update id="updateNavigationTranslations" parameterType="com.backendcms.entity.Cms.CmsNavigationI18nDTO.CmsNavigationI18nDTO"-->
  111. <!-- useGeneratedKeys="true" keyProperty="navigation_id">-->
  112. <!-- UPDATE cms_navigation-->
  113. <!-- SET-->
  114. <!-- <trim suffixOverrides="," suffix=" ">-->
  115. <!-- <if test="parent_id != null and parent_id != ''">parent_id = #{parent_id},</if>-->
  116. <!-- <if test="sort != null and sort != ''">sort = #{sort},</if>-->
  117. <!-- <if test="is_blank != null and is_blank != ''">is_blank = #{is_blank},</if>-->
  118. <!-- </trim>-->
  119. <!-- WHERE id = #{navigation_id};-->
  120. <!-- <foreach collection="translations" item="translation" separator=";">-->
  121. <!-- UPDATE cms_navigation_i18n-->
  122. <!-- SET-->
  123. <!-- <trim suffixOverrides="," suffix=" ">-->
  124. <!-- navigation_name = #{translation.navigation_name},-->
  125. <!-- <if test="translation.link != null and translation.link != ''">-->
  126. <!-- link = #{translation.link},-->
  127. <!-- </if>-->
  128. <!-- </trim>-->
  129. <!-- WHERE navigation_id = ${navigation_id} AND language = #{translation.language}-->
  130. <!-- </foreach>-->
  131. <!-- </update>-->
  132. <!-- 删除 -->
  133. <delete id="deleteNavigation" parameterType="java.lang.Long">
  134. DELETE FROM cms_navigation WHERE id = #{navigation_id};
  135. DELETE FROM cms_navigation_i18n WHERE navigation_id = #{navigation_id};
  136. </delete>
  137. <!-- 删除 (批量) -->
  138. <delete id="deleteNavigationBatch" parameterType="java.lang.Long">
  139. DELETE FROM cms_navigation WHERE id IN
  140. <foreach collection="ids" item="id" open="(" separator="," close=")">
  141. #{id}
  142. </foreach>;
  143. DELETE FROM cms_navigation_i18n WHERE navigation_id IN
  144. <foreach collection="ids" item="id" open="(" separator="," close=")">
  145. #{id}
  146. </foreach>;
  147. </delete>
  148. </mapper>