123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?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,img
- </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 desc
- </select>
- <!-- 查询列表 -->
- <select id="getPage" resultType="com.tld.model.Menu">
- select
- a.id,
- a.name,
- a.url,
- a.p_id,
- a.order_by,
- a.type,
- a.img,
- a.modify_time as modifyTime,
- b.user_name as modifyUser
- from tld_menu a
- left join tld_user b on a.modify_user = b.id
- <trim prefix="WHERE" prefixOverrides="and |or">
- <if test="pId != null and pId != ''">
- and a.p_id = #{pId}
- </if>
- <if test="name != null and name != ''">
- and a.name like CONCAT(CONCAT('%', #{name}), '%')
- </if>
- <if test="type != null and type != ''">
- and a.type = #{type}
- </if>
- <if test="id != null and id != ''">
- and a.id = #{id}
- </if>
- </trim>
- order by a.order_by
- </select>
- <!-- 新增菜单 -->
- <insert id="addMenu">
- insert into tld_menu(name,url,p_id,order_by,type,img,modify_user,modify_time) values(#{name},#{url},#{pId},#{orderBy},#{type},#{img},#{modifyUser},NOW())
- </insert>
- <!-- 修改菜单 -->
- <update id="updateMenu">
- update tld_menu
- <set>
- <trim suffixOverrides=",">
- <if test="name != null">
- name = #{name},
- </if>
- <if test="url != null">
- url = #{url},
- </if>
- <if test="pId != null">
- p_id = #{pId},
- </if>
- <if test="orderBy != null">
- order_by = #{orderBy},
- </if>
- <if test="type != null">
- type = #{type},
- </if>
- <if test="img != null">
- img = #{img},
- </if>
- modify_user = #{modifyUser},modify_time=now(),
- </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.img,
- 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>
- <!-- 根据角色查询菜单内容PDA -->
- <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>
|