<?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.ruoyi.system.mapper.SysMenuClickMapper">
    
    <resultMap type="SysMenuClick" id="SysMenuClickResult">
        <result property="id"    column="id"    />
        <result property="pageRoute"    column="page_route"    />
        <result property="pageName"    column="page_name"    />
        <result property="clickCount"    column="click_count"    />
        <result property="lastClickTime"    column="last_click_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectSysMenuClickVo">
        select id, page_route, page_name, click_count, last_click_time, create_by, create_time, update_by, update_time, remark from sys_menu_click
    </sql>

    <select id="selectSysMenuClickList" parameterType="SysMenuClick" resultMap="SysMenuClickResult">
        <include refid="selectSysMenuClickVo"/>
        <where>  
            <if test="pageRoute != null  and pageRoute != ''"> and page_route = #{pageRoute}</if>
            <if test="pageName != null  and pageName != ''"> and page_name like concat('%', #{pageName}, '%')</if>
            <if test="clickCount != null "> and click_count = #{clickCount}</if>
            <if test="lastClickTime != null "> and last_click_time = #{lastClickTime}</if>
        </where>
        order by click_count desc
    </select>
    
    <select id="selectSysMenuClickById" parameterType="Long" resultMap="SysMenuClickResult">
        <include refid="selectSysMenuClickVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysMenuClick" parameterType="SysMenuClick" useGeneratedKeys="true" keyProperty="id">
        insert into sys_menu_click
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pageRoute != null and pageRoute != ''">page_route,</if>
            <if test="pageName != null">page_name,</if>
            <if test="clickCount != null">click_count,</if>
            <if test="lastClickTime != null">last_click_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pageRoute != null and pageRoute != ''">#{pageRoute},</if>
            <if test="pageName != null">#{pageName},</if>
            <if test="clickCount != null">#{clickCount},</if>
            <if test="lastClickTime != null">#{lastClickTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateSysMenuClick" parameterType="SysMenuClick">
        update sys_menu_click
        <trim prefix="SET" suffixOverrides=",">
            <if test="pageRoute != null and pageRoute != ''">page_route = #{pageRoute},</if>
            <if test="pageName != null">page_name = #{pageName},</if>
            <if test="clickCount != null">click_count = #{clickCount},</if>
            <if test="lastClickTime != null">last_click_time = #{lastClickTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysMenuClickById" parameterType="Long">
        delete from sys_menu_click where id = #{id}
    </delete>

    <delete id="deleteSysMenuClickByIds" parameterType="String">
        delete from sys_menu_click where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>