|  |  |  | 
|---|
|  |  |  | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
|---|
|  |  |  | <mapper namespace="com.moral.api.mapper.ManageMenuMapper"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- 通用查询映射结果 --> | 
|---|
|  |  |  | <resultMap id="BaseResultMap" type="com.moral.api.entity.ManageMenu"> | 
|---|
|  |  |  | <id column="id" property="id" /> | 
|---|
|  |  |  | <result column="name" property="name" /> | 
|---|
|  |  |  | <result column="url" property="url" /> | 
|---|
|  |  |  | <result column="icon" property="icon" /> | 
|---|
|  |  |  | <result column="parent_id" property="parentId" /> | 
|---|
|  |  |  | <result column="order" property="order" /> | 
|---|
|  |  |  | <result column="create_time" property="createTime" /> | 
|---|
|  |  |  | <result column="update_time" property="updateTime" /> | 
|---|
|  |  |  | <result column="is_delete" property="isDelete" /> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  | <!-- 通用查询映射结果 --> | 
|---|
|  |  |  | <resultMap id="BaseResultMap" type="com.moral.api.entity.ManageMenu"> | 
|---|
|  |  |  | <id column="id" property="id"/> | 
|---|
|  |  |  | <result column="name" property="name"/> | 
|---|
|  |  |  | <result column="url" property="url"/> | 
|---|
|  |  |  | <result column="icon" property="icon"/> | 
|---|
|  |  |  | <result column="parent_id" property="parentId"/> | 
|---|
|  |  |  | <result column="order" property="order"/> | 
|---|
|  |  |  | <result column="create_time" property="createTime"/> | 
|---|
|  |  |  | <result column="update_time" property="updateTime"/> | 
|---|
|  |  |  | <result column="is_delete" property="isDelete"/> | 
|---|
|  |  |  | <result column="desc" property="desc"/> | 
|---|
|  |  |  | </resultMap> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <sql id="Base_Column_List"> | 
|---|
|  |  |  | mm.id,mm.name,mm.url,mm.icon,mm.parent_id,mm.order,mm.create_time,mm.update_time,mm.is_delete,mm.desc | 
|---|
|  |  |  | </sql> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--根据角色查询父子结构的菜单--> | 
|---|
|  |  |  | <select id="getAllMenusByRoles" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | DISTINCT | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | from | 
|---|
|  |  |  | manage_menu mm | 
|---|
|  |  |  | join | 
|---|
|  |  |  | manage_role_menu mrm | 
|---|
|  |  |  | on | 
|---|
|  |  |  | mm.`id` = mrm.`menu_id` and mrm.`is_delete`= '0' | 
|---|
|  |  |  | join | 
|---|
|  |  |  | manage_role mr | 
|---|
|  |  |  | on | 
|---|
|  |  |  | mr.`id` = mrm.`role_id` and mr.`id` IN | 
|---|
|  |  |  | <foreach collection="list" separator="," open="(" close=")" item="role"> | 
|---|
|  |  |  | #{role.id} | 
|---|
|  |  |  | </foreach> | 
|---|
|  |  |  | where | 
|---|
|  |  |  | mm.`is_delete`= '0' | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getManageMenuByName" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select * from manage_menu | 
|---|
|  |  |  | where name = #{name} | 
|---|
|  |  |  | and is_delete = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getManageMenuById" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select * from manage_menu | 
|---|
|  |  |  | where id = #{id} | 
|---|
|  |  |  | and is_delete = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <insert id="insertOne" parameterType="java.util.Map"> | 
|---|
|  |  |  | INSERT INTO manage_menu | 
|---|
|  |  |  | <trim prefix="(" suffix=")" suffixOverrides=","> | 
|---|
|  |  |  | <if test="name != null"> | 
|---|
|  |  |  | name, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="url != null"> | 
|---|
|  |  |  | url, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="icon != null"> | 
|---|
|  |  |  | icon, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="parentId != null"> | 
|---|
|  |  |  | parent_id, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="order != null"> | 
|---|
|  |  |  | `order`, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="desc != null"> | 
|---|
|  |  |  | `desc`, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | <trim prefix="values (" suffix=")" suffixOverrides=","> | 
|---|
|  |  |  | <if test="name != null"> | 
|---|
|  |  |  | #{name}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="url != null"> | 
|---|
|  |  |  | #{url}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="icon != null"> | 
|---|
|  |  |  | #{icon}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="parentId != null"> | 
|---|
|  |  |  | #{parentId}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="order != null"> | 
|---|
|  |  |  | #{order}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="desc != null"> | 
|---|
|  |  |  | #{desc}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </insert> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <update id="updateManageMenuById" parameterType="java.util.Map"> | 
|---|
|  |  |  | update manage_menu | 
|---|
|  |  |  | <set> | 
|---|
|  |  |  | <if test="name != null"> | 
|---|
|  |  |  | name = #{name}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="url != null"> | 
|---|
|  |  |  | url = #{url}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="icon != null"> | 
|---|
|  |  |  | icon = #{icon}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="parent_id != null"> | 
|---|
|  |  |  | parent_id = #{parent_id}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="order != null"> | 
|---|
|  |  |  | `order` = #{order}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="is_delete != null"> | 
|---|
|  |  |  | is_delete = #{is_delete}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="desc != null"> | 
|---|
|  |  |  | `desc` = #{desc}, | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </set> | 
|---|
|  |  |  | where id = #{id} | 
|---|
|  |  |  | </update> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getDataWithPage" parameterType="java.util.Map" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | from manage_menu mm | 
|---|
|  |  |  | where mm.is_delete = 0 | 
|---|
|  |  |  | ORDER BY parent_id ASC,`order` ASC | 
|---|
|  |  |  | limit #{start},#{number} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getAll" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | from manage_menu mm | 
|---|
|  |  |  | where mm.is_delete = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getManageRoleByNameFuzzy" parameterType="java.util.Map" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | from manage_menu mm | 
|---|
|  |  |  | where mm.name like concat('%',#{name},'%') | 
|---|
|  |  |  | and mm.is_delete = 0 | 
|---|
|  |  |  | limit #{start},#{number} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getManageMenuByRoleId" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | FROM manage_menu mm | 
|---|
|  |  |  | JOIN manage_role_menu mrm | 
|---|
|  |  |  | ON mm.id = mrm.menu_id AND mrm.is_delete = 0 | 
|---|
|  |  |  | JOIN manage_role mr | 
|---|
|  |  |  | ON mr.id = mrm.role_id and mr.id = #{roleId} | 
|---|
|  |  |  | WHERE mm.is_delete = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getManageMenuByCondition" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | from manage_menu mm | 
|---|
|  |  |  | where mm.is_delete = 0 | 
|---|
|  |  |  | <if test="name != null"> | 
|---|
|  |  |  | and mm.name = #{name} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="url != null"> | 
|---|
|  |  |  | and mm.url = #{url} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="icon != null"> | 
|---|
|  |  |  | and mm.icon = #{icon} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="parent_id != null"> | 
|---|
|  |  |  | and mm.parent_id = #{parent_id} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="order != null"> | 
|---|
|  |  |  | and mm.order = #{order} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="desc != null"> | 
|---|
|  |  |  | and mm.desc = #{order} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | limit #{start},#{number} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getManageMenuByNameFuzzy" parameterType="java.util.Map" resultMap="BaseResultMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | <include refid="Base_Column_List"></include> | 
|---|
|  |  |  | from manage_menu mm | 
|---|
|  |  |  | where mm.is_delete = 0 | 
|---|
|  |  |  | <if test="name != null"> | 
|---|
|  |  |  | and mm.name like concat('%',#{name},'%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="url != null"> | 
|---|
|  |  |  | and mm.url = #{url} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="icon != null"> | 
|---|
|  |  |  | and mm.icon = #{icon} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="parent_id != null"> | 
|---|
|  |  |  | and mm.parent_id = #{parent_id} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="order != null"> | 
|---|
|  |  |  | and mm.order = #{order} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="desc != null"> | 
|---|
|  |  |  | and mm.desc = #{order} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | limit #{start},#{number} | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </mapper> | 
|---|