package com.chenyang.nse.bussiness.dao.table.console;

import com.chenyang.nse.bussiness.dao.BaseDao;
import com.chenyang.nse.bussiness.entity.orm.table.console.TConsolePrivilege;
import java.util.List;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class TConsolePrivilegeDao extends BaseDao<TConsolePrivilege, String> {
   public void save(String roleid, List<String> privileges) {
      this.remove(new Criterion[]{Restrictions.eq("roleid", roleid)});
      this.getSession().flush();
      if (privileges != null) {
         for(String privilege : privileges) {
            TConsolePrivilege record = new TConsolePrivilege(roleid, privilege);
            this.save(record);
         }
      }

   }
}
