package com.yihu.hos.system.dao;

import com.yihu.hos.system.model.SystemRoleMenu;
import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by chenweida on 2016/2/19.
 */
@Repository("systemRoleMenuDao")
public class SystemRoleMenuDao extends SQLGeneralDAO {

    public static final String BEAN_ID = "systemRoleMenuDao";

  
    public List<SystemRoleMenu> getSystemRoleMenuListByRoleId(String roleId) throws Exception {
        return (List<SystemRoleMenu>) super.hibernateTemplate.find("from SystemRoleMenu s where s.roleId=?", roleId);

    }

  
    public SystemRoleMenu getRoleMenuByRoleIdAndMenuId(String roleId, String menuId) throws Exception {
        return (SystemRoleMenu) super.hibernateTemplate.find("from SystemRoleMenu s where s.roleId=? and s.menuId=?", roleId, menuId).get(0);
    }

  
    public void deleteAllByRoleId(String roleId) throws Exception {
        super.hibernateTemplate.bulkUpdate("delete SystemRoleMenu s where s.roleId=?",roleId);
    }
}
