package cn.com.ty.lift.system.appmenu.mapper;


import cn.com.ty.lift.system.appmenu.mapper.entity.Appmenu;
import cn.com.ty.lift.system.appmenu.mapper.entity.AppuserMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * app角色权限-Repository
 * 
 * @author Xson
 * @date 2020-06-04
 */
public interface AppuserMenuMapper extends BaseMapper<AppuserMenu> {

	@Select("SELECT b.* FROM appuser_menu a LEFT JOIN appmenu b ON a.appmenu_id=b.id  WHERE a.user_level_id=#{id} and b.parent_id!=1")
	List<Appmenu> findMenuByUserLevelId(@Param("id") Integer levelId);

	@Delete("DELETE FROM appuser_menu WHERE user_level_id=#{id}")
	void deleteByLevelId(@Param("id") Integer id);
}
