package com.yihu.hos.system.dao;

import com.yihu.hos.system.model.SystemRoleAction;
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("systemRoleActionDao")
public class SystemRoleActionDao extends SQLGeneralDAO {

    public static final String BEAN_ID = "systemRoleActionDao";

   
    public List<SystemRoleAction> getSystemRoleActionListByRoleId(String roleId) throws Exception {

        return (List<SystemRoleAction>) super.hibernateTemplate.find("from SystemRoleAction s where s.roleId=?", roleId);
    }

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

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