package com.basic.security.manager; import com.basic.security.model.ModelAdapter; import com.basic.security.model.Time; import java.util.List; /** * 时间规则的管理类 */ public class TimeManager extends BaseManager { // 获取所有的时间规则 public static List getAllTimeRule() { return findList("select * from time where del_flag='0'"); } // 获取所有启用的时间规则 public static List getAllUseTimeRule() { return findList("select * from time where is_use='1' and del_flag ='0'"); } // 删除某个时间规则 public static void deleteOneTimeRule(ModelAdapter timeRule) { try { deletePhysically(findById("time", timeRule.getId())); } catch (Exception e) { e.printStackTrace(); } } // 获取时间规则的名称中是否已有此规则名称 public static boolean isContain(String timeRuleName) { List allTimeRule = getAllTimeRule(); for (ModelAdapter timeRule : allTimeRule) { if (timeRuleName.equals(timeRule.getString("time_rule_name"))) { return true; } } return false; } public static void saveTime(ModelAdapter timeDocument) { BaseManager.save(timeDocument); } public static ModelAdapter findByTimeRuleName(String timeRuleName) { return findOne("select * from time where " + Time.time_rule_name + "='" + timeRuleName + "'"); } }