ept_menuMapper.xml 4.3 KB
<?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.eport.rest.dao.EptMenuDao">
    
	<sql id="EptMenuEntityColumns">
		a1.MENU_ID AS "menuId"
		,a1.MENU_NAME AS "menuName"
		,a1.PARENT_ID AS "parentId"
		,a1.MENU_URL AS "menuUrl"
		,a1.SORT_ID AS "sortId"
		,a1.IS_TOP AS "isTop"
		,a1.IS_ADMIN AS "isAdmin"
	</sql>
	
	<sql id="EptMenuEntityListColumns">
		a1.MENU_ID AS "menuId"
	</sql>
	
	
	
		<!--查询表中所有资料(所有字段) -->
		<select id="listAll"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.EptMenuEntity"
		>
		select  
			<include refid="EptMenuEntityColumns"/>
			,(select MENU_NAME from ept_menu  c1 where c1.MENU_ID = a1.PARENT_ID) as parentMenuName
		FROM ept_menu  a1
		WHERE 1=1
		and a1.IS_DELETE = 0
		order by 
		SORT_ID asc
		</select>
		
	
		<!--分页查询资料(所有字段) -->
		<select id="pageAll"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.EptMenuEntity"
		>
		select  
			<include refid="EptMenuEntityColumns"/>
			,(select MENU_NAME from ept_menu  c1 where c1.MENU_ID = a1.PARENT_ID) as parentMenuName
		FROM ept_menu  a1
		WHERE 1=1
		and a1.IS_DELETE = 0
		order by 
		SORT_ID asc
		</select>
		
	
		<!--查询表中所有资料(仅列表显示字段) -->
		<select id="list"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.EptMenuEntity"
		>
		select  
			<include refid="EptMenuEntityListColumns"/>
		FROM ept_menu  a1
		WHERE 1=1
		and a1.IS_DELETE = 0
		order by 
		SORT_ID asc
		</select>
		
	
		<!--分页查询资料(仅列表显示字段) -->
		<select id="page"  
		parameterType="HashMap" 
		resultType="com.eport.rest.entity.EptMenuEntity"
		>
		select  
			<include refid="EptMenuEntityListColumns"/>
		FROM ept_menu  a1
		WHERE 1=1
		and a1.IS_DELETE = 0
		order by 
		SORT_ID asc
		</select>
		
	
		<!--根据主键查询数据 -->
		<select id="findByPK"  
		parameterType="Integer" 
		resultType="com.eport.rest.entity.EptMenuEntity"
		>
		select  
		<include refid="EptMenuEntityColumns"/>
			,(select MENU_NAME from ept_menu  c1 where c1.MENU_ID = a1.PARENT_ID) as parentMenuName
		FROM ept_menu  a1
		and a1.IS_DELETE = 0
		WHERE a1.MENU_ID=#{par}
		</select>
		
	
		<!--新增数据 -->
		<insert id="insert"  
		parameterType="com.eport.rest.entity.EptMenuEntity" 
		>
		<selectKey resultType="Integer" order="AFTER" keyProperty="menuId">
		<if test="menuId != null ">
		select #{menuId} from dual
		</if>
		<if test="menuId == null ">
		SELECT LAST_INSERT_ID() AS menuId
		</if>
		 </selectKey>
		insert  
		  INTO ept_menu (
		MENU_NAME
		,PARENT_ID
		,MENU_URL
		,SORT_ID
		,IS_TOP
		,IS_ADMIN
		,IS_DELETE
		<if test="menuId != null ">
		,MENU_ID
		</if>
		  ) VALUES (
		#{menuName,jdbcType=VARCHAR}
		,#{parentId,jdbcType=INTEGER}
		,#{menuUrl,jdbcType=VARCHAR}
		,#{sortId,jdbcType=INTEGER}
		,#{isTop,jdbcType=INTEGER}
		,#{isAdmin,jdbcType=INTEGER}
		,#{isDelete,jdbcType=INTEGER}
		<if test="menuId != null ">
		,#{menuId,jdbcType=INTEGER}
		</if>
		  )
		</insert>
		
	
		<!--更新数据 -->
		<update id="update"  
		parameterType="com.eport.rest.entity.EptMenuEntity" 
		>
		update  
		ept_menu
		<set>
		<if test="menuName != null ">
		MENU_NAME = #{menuName},
		</if>
		<if test="parentId != null ">
		PARENT_ID = #{parentId},
		</if>
		<if test="menuUrl != null ">
		MENU_URL = #{menuUrl},
		</if>
		<if test="sortId != null ">
		SORT_ID = #{sortId},
		</if>
		<if test="isTop != null ">
		IS_TOP = #{isTop},
		</if>
		<if test="isAdmin != null ">
		IS_ADMIN = #{isAdmin},
		</if>
		<if test="isDelete != null ">
		IS_DELETE = #{isDelete},
		</if>
		</set>
		WHERE MENU_ID = #{menuId}
		</update>
		
	
		<!--根据主键删除数据 -->
		<delete id="delete"  
		parameterType="HashMap" 
		>
		delete  
		from ept_menu 
		 WHERE MENU_ID in (${par})
		</delete>
		
	
		<!--获取底部显示菜单 -->
		<select id="getTopMenu"  
		parameterType="HashMap" 
		resultType="HashMap"
		>
		select a1.MENU_ID AS "menuId"
		,a1.MENU_NAME AS "menuName"
		,a1.PARENT_ID AS "parentId"
		,a1.MENU_URL AS "menuUrl"
		,a1.SORT_ID AS "sortId"
		,a1.IS_TOP AS "isTop"
		,(select MENU_NAME from ept_menu  c1 where c1.MENU_ID = a1.PARENT_ID) as parentMenuName
		FROM ept_menu  a1
		where a1.IS_TOP=1 
		and a1.IS_DELETE = 0
		order by SORT_ID asc
		</select>
		
	
</mapper>