123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?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
- </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>
- </trim>
- </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 = #{name}
- </if>
- </trim>
- </select>
- <!-- 新增菜单 -->
- <insert id="addMenu">
- insert into tld_menu(name,url,p_id) values(#{name},#{url},#{pId})
- </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>
- </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,
- a.id_code
- 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, ','),'%')
- </select>
- </mapper>
|