<?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.yunfeiyun.agmp.common.web.system.mapper.SysMenuConfigMapper">

	<resultMap type="SysMenuConfig" id="SysMenuConfigResult">
		<id     property="menucfgId"    column="menucfgId"        />
		<result property="menuId"       column="menuId"      />
		<result property="menucfgSys"   column="menucfgSys"      />
		<result property="menuName"       column="menuName"      />
	</resultMap>

	<sql id="selectMenuConfigVo">
		select r.*,n.menuName , n.menuSeq	from SysMenuconfig r
		left join SysMenu n
		on r.menuId = n.menuId
	</sql>

	<select id="selectMenuConfigList" parameterType="SysMenuConfig" resultMap="SysMenuConfigResult">
		<include refid="selectMenuConfigVo"/>
		<where>
			AND menuParentid = '0'
			<if test="menucfgSys != null and menucfgSys != ''">
				AND menucfgSys = #{menucfgSys}
			</if>
		</where>
		order by menuSeq
	</select>


	<select id="selectMenuConfigByCfgId" parameterType="String" resultMap="SysMenuConfigResult">
		<include refid="selectMenuConfigVo"/>
		where  menuParentid = '0' AND menucfgSys = #{menucfgSys} order by menuSeq
	</select>

	<select id="selectMenuConfigByMenuId" parameterType="String" resultMap="SysMenuConfigResult">
		select * from SysMenuconfig
		where   menuId = #{menuId} LIMIT 1
	</select>

	<update id="updateMenuConfig" parameterType="SysMenuConfig">
		update SysMenuconfig
		<trim prefix="SET" suffixOverrides=",">
			<if test="menuId != null">menuId = #{menuId},</if>
			<if test="menucfgSys != null">menucfgSys = #{menucfgSys},</if>
		</trim>
		where menucfgId = #{menucfgId}
	</update>


	<insert id="insertMenuConfig" parameterType="SysMenuConfig">
		insert into SysMenuconfig
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="menucfgId != null and menucfgId != ''">menucfgId,</if>
			<if test="menuId != null and menuId != ''">menuId,</if>
			<if test="menucfgSys != null and menucfgSys != ''">menucfgSys,</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="menucfgId != null and menucfgId != ''">#{menucfgId},</if>
			<if test="menuId != null and menuId != ''">#{menuId},</if>
			<if test="menucfgSys != null and menucfgSys != ''">#{menucfgSys},</if>
		</trim>
	</insert>

	<delete id="deleteMenuConfigById" parameterType="String">
		delete from SysMenuconfig where menucfgId = #{menucfgId} LIMIT 1
	</delete>


	<delete id="deleteMenuConfigByMenuId" parameterType="String">
		delete from SysMenuconfig where menuId = #{menuId} LIMIT 1
	</delete>

</mapper>