123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?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.tld.mapper.MenuMapper">
- <sql id="field">
- id,name,url,p_id,order_by,type
- </sql>
- <!-- 查询菜单 -->
- <select id="getMenu" resultType="com.tld.model.Menu">
- select
- <include refid="field"/>
- from tld_menu
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="pId != null and pId != ''">
- and p_id = #{pId}
- </if>
- and type = "PC"
- </trim>
- order by order_by
- </select>
- <!-- 查询列表 -->
- <select id="getPage" resultType="com.tld.model.Menu">
- select
- <include refid="field"/>
- from tld_menu
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="pId != null and pId != ''">
- and p_id = #{pId}
- </if>
- <if test="name != null and name != ''">
- and name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- <if test="type != null and type != ''">
- and type = #{type}
- </if>
- <if test="id != null and id != ''">
- and id = #{id}
- </if>
- </trim>
- order by order_by
- </select>
- <!-- 新增菜单 -->
- <insert id="addMenu">
- insert into tld_menu(name,url,p_id,order_by,type) values(#{name},#{url},#{pId},#{orderBy},#{type})
- </insert>
- <!-- 修改菜单 -->
- <update id="updateMenu">
- update tld_menu
- <set>
- <trim suffixOverrides=",">
- <if test="name != null and name != ''">
- name = #{name},
- </if>
- <if test="url != null and url != ''">
- url = #{url},
- </if>
- <if test="pId != null and pId != ''">
- p_id = #{pId},
- </if>
- <if test="orderBy != null and orderBy != ''">
- order_by = #{orderBy},
- </if>
- <if test="type != null and type != ''">
- type = #{type},
- </if>
- </trim>
- </set>
- where id = #{id}
- </update>
- <!-- 删除菜单 -->
- <delete id="delMenu">
- delete from tld_menu where id = #{id}
- </delete>
- <!-- 根据角色查询菜单内容 -->
- <select id="getUserMenu" resultType="com.tld.model.Menu">
- SELECT a.id,
- a.name,
- a.url,
- a.p_id,
- c.menu
- FROM tld_menu a
- JOIN tld_user b ON b.id = #{userId}
- JOIN tld_role c ON b.role = c.id
- WHERE c.menu LIKE CONCAT('%', CONCAT(a.id, ','), '%')
- ORDER BY a.order_by
- </select>
- <!-- 根据角色查询菜单内容 -->
- <select id="getUserMenuPDA" resultType="com.tld.model.Menu">
- SELECT a.id,
- a.name,
- a.url,
- a.p_id,
- c.menu_pda
- FROM tld_menu a
- JOIN tld_user b ON b.id = #{userId}
- JOIN tld_role c ON b.role = c.id
- WHERE c.menu_pda LIKE CONCAT('%', CONCAT(a.id, ','), '%')
- ORDER BY a.order_by
- </select>
- </mapper>
|