<?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="cn.timer.api.dao.zzgl.ZzglMenuMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.zzgl.ZzglMenu" >
                <result column="menu_id" property="menuId" />
                <result column="menu_name" property="menuName" />
                <result column="parent_id" property="parentId" />
                <result column="order_num" property="orderNum" />
                <result column="path" property="path" />
                <result column="component" property="component" />
                <result column="is_frame" property="isFrame" />
                <result column="menu_type" property="menuType" />
                <result column="visible" property="visible" />
                <result column="perms" property="perms" />
                <result column="icon" property="icon" />
                <result column="create_by" property="createBy" />
                <result column="create_time" property="createTime" />
                <result column="update_by" property="updateBy" />
                <result column="update_time" property="updateTime" />
                <result column="remark" property="remark" />
    </resultMap>

    <sql id="Base_Column_List">
                menu_id,
                menu_name,
                parent_id,
                order_num,
                path,
                component,
                is_frame,
                menu_type,
                visible,
                perms,
                icon,
                create_by,
                create_time,
                update_by,
                update_time,
                remark
    </sql>
    
    <sql id="Base_Column_List_A">
                a.menu_id,
                a.menu_name,
                a.parent_id,
                a.order_num,
                a.path,
                a.component,
                a.is_frame,
                a.menu_type,
                a.visible,
                a.perms,
                a.icon,
                a.create_by,
                a.create_time,
                a.update_by,
                a.update_time,
                a.remark
    </sql>
    
    <sql id="Base_Column_List_Alias">
                menu_id ZzglMenu_menu_id,
                menu_name ZzglMenu_menu_name,
                parent_id ZzglMenu_parent_id,
                order_num ZzglMenu_order_num,
                path ZzglMenu_path,
                component ZzglMenu_component,
                is_frame ZzglMenu_is_frame,
                menu_type ZzglMenu_menu_type,
                visible ZzglMenu_visible,
                perms ZzglMenu_perms,
                icon ZzglMenu_icon,
                create_by ZzglMenu_create_by,
                create_time ZzglMenu_create_time,
                update_by ZzglMenu_update_by,
                update_time ZzglMenu_update_time,
                remark ZzglMenu_remark
    </sql>
    
    <select id="selectMenuByPostId" resultMap="BaseResultMap">
        SELECT a.menu_id
        FROM zzgl_menu a
        LEFT JOIN zzgl_post_menu b ON a.menu_id = b.menu_id
        WHERE b.bmgw_id = #{id}
    </select>
    
    <select id="queryList" resultMap="BaseResultMap" parameterType="cn.timer.api.dto.zzgl.ZzglMenuQueryDto">
        SELECT <include refid="Base_Column_List" />
        FROM zzgl_menu
        <where>
        	<if test ="null != obj.menuName and '' != obj.menuName">
            	and menu_name like CONCAT('%',#{obj.menuName},'%')
            </if>
            <if test ="null != obj.visible  and '' != obj.visible">
            	and visible = #{obj.visible},
            </if>
        </where>
    </select>

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.zzgl.ZzglMenu">
        INSERT INTO zzgl_menu
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != menuId'>
                        menu_id,
                        </if>
                        <if test ='null != menuName'>
                        menu_name,
                        </if>
                        <if test ='null != parentId'>
                        parent_id,
                        </if>
                        <if test ='null != orderNum'>
                        order_num,
                        </if>
                        <if test ='null != path'>
                        path,
                        </if>
                        <if test ='null != component'>
                        component,
                        </if>
                        <if test ='null != isFrame'>
                        is_frame,
                        </if>
                        <if test ='null != menuType'>
                        menu_type,
                        </if>
                        <if test ='null != visible'>
                        visible,
                        </if>
                        <if test ='null != perms'>
                        perms,
                        </if>
                        <if test ='null != icon'>
                        icon,
                        </if>
                        <if test ='null != createBy'>
                        create_by,
                        </if>
                        <if test ='null != createTime'>
                        create_time,
                        </if>
                        <if test ='null != updateBy'>
                        update_by,
                        </if>
                        <if test ='null != updateTime'>
                        update_time,
                        </if>
                        <if test ='null != remark'>
                        remark
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != menuId'>
                        #{menuId},
                        </if>
                        <if test ='null != menuName'>
                        #{menuName},
                        </if>
                        <if test ='null != parentId'>
                        #{parentId},
                        </if>
                        <if test ='null != orderNum'>
                        #{orderNum},
                        </if>
                        <if test ='null != path'>
                        #{path},
                        </if>
                        <if test ='null != component'>
                        #{component},
                        </if>
                        <if test ='null != isFrame'>
                        #{isFrame},
                        </if>
                        <if test ='null != menuType'>
                        #{menuType},
                        </if>
                        <if test ='null != visible'>
                        #{visible},
                        </if>
                        <if test ='null != perms'>
                        #{perms},
                        </if>
                        <if test ='null != icon'>
                        #{icon},
                        </if>
                        <if test ='null != createBy'>
                        #{createBy},
                        </if>
                        <if test ='null != createTime'>
                        #{createTime},
                        </if>
                        <if test ='null != updateBy'>
                        #{updateBy},
                        </if>
                        <if test ='null != updateTime'>
                        #{updateTime},
                        </if>
                        <if test ='null != remark'>
                        #{remark}
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM zzgl_menu
        WHERE id = #{id}
    </delete>

    <update id="update" parameterType="cn.timer.api.bean.zzgl.ZzglMenu">
        UPDATE zzgl_menu
        <set>
                    <if test ='null != menuId'>menu_id = #{menuId},</if>
                    <if test ='null != menuName'>menu_name = #{menuName},</if>
                    <if test ='null != parentId'>parent_id = #{parentId},</if>
                    <if test ='null != orderNum'>order_num = #{orderNum},</if>
                    <if test ='null != path'>path = #{path},</if>
                    <if test ='null != component'>component = #{component},</if>
                    <if test ='null != isFrame'>is_frame = #{isFrame},</if>
                    <if test ='null != menuType'>menu_type = #{menuType},</if>
                    <if test ='null != visible'>visible = #{visible},</if>
                    <if test ='null != perms'>perms = #{perms},</if>
                    <if test ='null != icon'>icon = #{icon},</if>
                    <if test ='null != createBy'>create_by = #{createBy},</if>
                    <if test ='null != createTime'>create_time = #{createTime},</if>
                    <if test ='null != updateBy'>update_by = #{updateBy},</if>
                    <if test ='null != updateTime'>update_time = #{updateTime},</if>
                    <if test ='null != remark'>remark = #{remark}</if>
        </set>
        WHERE id = #{id}
    </update>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM zzgl_menu
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM zzgl_menu
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM zzgl_menu
    </select>

	 -->

</mapper>