| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.dk.mdm.mapper.mst.MenuFrequencyMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- menu_uuid
- , cp_id, staff_id, app_code, qty, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.mst.MenuFrequencyResponse">
- <id column="menu_uuid" property="menuUuid" typeHandler="UuidTypeHandler"/>
- <result column="cp_id" property="cpId"/>
- <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
- <result column="app_code" property="appCode"/>
- <result column="qty" property="qty"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_app_code" property="opAppCode"/>
- <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
- <result column="op_db_user" property="opDbUser"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="cpId != null">
- AND cp_id = #{cpId}
- </if>
- <if test="staffId != null and staffId != ''">
- AND staff_id = #{staffId}
- </if>
- <if test="appCode != null and appCode != ''">
- AND app_code = #{appCode}
- </if>
- <if test="opAppCode != null and opAppCode != ''">
- AND op_app_code = #{opAppCode}
- </if>
- </where>
- </sql>
- <sql id="idsForeach">
- <!-- 根据主键menuUuid批量操作 -->
- WHERE menu_uuid in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </sql>
- <!-- 查询表t_mst_menu_frequency,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMap">
- SELECT
- sys.f_get_name_i18n ( tam.menu_name_i18n, #{i18n} ) menu_name,
- tmf.menu_uuid,
- tam.object_code,
- tam.object_path,
- CASE WHEN tam.object_icon IS NULL THEN NULL ELSE tam.object_icon || '.png' END AS object_icon
- FROM
- dkic_b.t_mst_menu_frequency tmf
- INNER JOIN sys.t_app_menu tam ON tmf.menu_uuid = tam.menu_uuid
- WHERE
- tmf.staff_id = #{staffId} ::uuid
- AND tmf.app_code = #{appCode}
- <!--排除在外的功能-->
- <if test="exceptMenu != null ">
- AND tmf.menu_uuid != ALL(#{exceptMenu,typeHandler=UuidListTypeHandler} )
- </if>
- <if test="gradeCode != null and gradeCode != ''">
- AND (tam.grade_codes is null or #{gradeCode} = any(tam.grade_codes))
- </if>
- ORDER BY
- tmf.qty DESC
- <if test="queryLimit != null and queryLimit != 0 ">
- limit #{queryLimit}
- </if>
- </select>
- <!--新建编辑用户功能频率-->
- <insert id="save">
- insert into dkic_b.t_mst_menu_frequency
- (
- <trim suffixOverrides=",">
- menu_uuid,
- cp_id,
- staff_id,
- app_code,
- qty,
- </trim>
- )
- values
- (
- <trim suffixOverrides=",">
- #{menuUuid} ::uuid,
- #{cpId},
- #{staffId} ::uuid,
- #{appCode},
- #{qty},
- </trim>
- )
- on conflict (menu_uuid,staff_id,app_code) do update set
- cp_id = excluded."cp_id",
- qty = excluded."qty" ;
- </insert>
- <!-- 根据主键查询表t_mst_menu_frequency的一行数据 -->
- <select id="selectMenuById" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_b.t_mst_menu_frequency
- WHERE menu_uuid = #{menuUuid}::uuid
- and cp_id = #{cpId}
- and app_code = #{appCode}
- and staff_id = #{staffId} ::uuid
- </select>
- <insert id="insertBatch">
- insert into t_mst_menu_frequency
- (
- <trim suffixOverrides=",">
- cp_id,
- staff_id,
- app_code,
- qty,
- op_app_code,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.cpId},
- #{item.staffId}::uuid,
- #{item.appCode},
- #{item.qty},
- #{item.opAppCode},
- </trim>
- )
- </foreach>
- </insert>
- </mapper>
|