a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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<ModelAdapter> getAllTimeRule() {
        return findList("select * from time where del_flag='0'");
    }
 
    // 获取所有启用的时间规则
    public static List<ModelAdapter> 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<ModelAdapter> 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 + "'");
    }
}