MenuFrequencyMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.dk.mdm.mapper.mst.MenuFrequencyMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. menu_uuid
  8. , cp_id, staff_id, app_code, qty, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  9. </sql>
  10. <!-- 通用查询映射结果 -->
  11. <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.mst.MenuFrequencyResponse">
  12. <id column="menu_uuid" property="menuUuid" typeHandler="UuidTypeHandler"/>
  13. <result column="cp_id" property="cpId"/>
  14. <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
  15. <result column="app_code" property="appCode"/>
  16. <result column="qty" property="qty"/>
  17. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  18. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  19. <result column="op_app_code" property="opAppCode"/>
  20. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  21. <result column="op_db_user" property="opDbUser"/>
  22. </resultMap>
  23. <!-- 通用条件列 -->
  24. <sql id="Condition">
  25. <where>
  26. <if test="cpId != null">
  27. AND cp_id = #{cpId}
  28. </if>
  29. <if test="staffId != null and staffId != ''">
  30. AND staff_id = #{staffId}
  31. </if>
  32. <if test="appCode != null and appCode != ''">
  33. AND app_code = #{appCode}
  34. </if>
  35. <if test="opAppCode != null and opAppCode != ''">
  36. AND op_app_code = #{opAppCode}
  37. </if>
  38. </where>
  39. </sql>
  40. <sql id="idsForeach">
  41. <!-- 根据主键menuUuid批量操作 -->
  42. WHERE menu_uuid in
  43. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  44. #{item}
  45. </foreach>
  46. </sql>
  47. <!-- 查询表t_mst_menu_frequency,(条件查询+分页)列表 -->
  48. <select id="selectByCond" resultMap="BaseResultMap">
  49. SELECT
  50. sys.f_get_name_i18n ( tam.menu_name_i18n, #{i18n} ) menu_name,
  51. tmf.menu_uuid,
  52. tam.object_code,
  53. tam.object_path,
  54. CASE WHEN tam.object_icon IS NULL THEN NULL ELSE tam.object_icon || '.png' END AS object_icon
  55. FROM
  56. dkic_b.t_mst_menu_frequency tmf
  57. INNER JOIN sys.t_app_menu tam ON tmf.menu_uuid = tam.menu_uuid
  58. WHERE
  59. tmf.staff_id = #{staffId} ::uuid
  60. AND tmf.app_code = #{appCode}
  61. <!--排除在外的功能-->
  62. <if test="exceptMenu != null ">
  63. AND tmf.menu_uuid != ALL(#{exceptMenu,typeHandler=UuidListTypeHandler} )
  64. </if>
  65. <if test="gradeCode != null and gradeCode != ''">
  66. AND (tam.grade_codes is null or #{gradeCode} = any(tam.grade_codes))
  67. </if>
  68. ORDER BY
  69. tmf.qty DESC
  70. <if test="queryLimit != null and queryLimit != 0 ">
  71. limit #{queryLimit}
  72. </if>
  73. </select>
  74. <!--新建编辑用户功能频率-->
  75. <insert id="save">
  76. insert into dkic_b.t_mst_menu_frequency
  77. (
  78. <trim suffixOverrides=",">
  79. menu_uuid,
  80. cp_id,
  81. staff_id,
  82. app_code,
  83. qty,
  84. </trim>
  85. )
  86. values
  87. (
  88. <trim suffixOverrides=",">
  89. #{menuUuid} ::uuid,
  90. #{cpId},
  91. #{staffId} ::uuid,
  92. #{appCode},
  93. #{qty},
  94. </trim>
  95. )
  96. on conflict (menu_uuid,staff_id,app_code) do update set
  97. cp_id = excluded."cp_id",
  98. qty = excluded."qty" ;
  99. </insert>
  100. <!-- 根据主键查询表t_mst_menu_frequency的一行数据 -->
  101. <select id="selectMenuById" resultMap="BaseResultMap">
  102. SELECT
  103. <include refid="Base_Column_List"/>
  104. FROM dkic_b.t_mst_menu_frequency
  105. WHERE menu_uuid = #{menuUuid}::uuid
  106. and cp_id = #{cpId}
  107. and app_code = #{appCode}
  108. and staff_id = #{staffId} ::uuid
  109. </select>
  110. <insert id="insertBatch">
  111. insert into t_mst_menu_frequency
  112. (
  113. <trim suffixOverrides=",">
  114. cp_id,
  115. staff_id,
  116. app_code,
  117. qty,
  118. op_app_code,
  119. </trim>
  120. )
  121. values
  122. <foreach collection="list" index="index" item="item" separator=",">
  123. (
  124. <trim suffixOverrides=",">
  125. #{item.cpId},
  126. #{item.staffId}::uuid,
  127. #{item.appCode},
  128. #{item.qty},
  129. #{item.opAppCode},
  130. </trim>
  131. )
  132. </foreach>
  133. </insert>
  134. </mapper>