1
81041
2019-06-20 ab3c4acf83f54f8449ca8664c4a2bb79bd30f297
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.fgkj.services;
 
 
import java.util.List;
 
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dto.Limit;
import com.fgkj.dto.ServiceModel;
 
 
public class LimitService {
    private BaseDAO dao;
    private ServiceModel model;
    
    public LimitService() {
        dao = BaseDAOFactory.getBaseDAO(BaseDAO.LIMIT);
        model = new ServiceModel();
    }
    public ServiceModel addLimit(Object obj){
        Limit l=(Limit) obj;
        List<Limit> list=dao.serchByCondition(l);
        Boolean bl=false;
        if(list.isEmpty()){
             bl=dao.add(l);
            if(bl==true){
                model.setCode(1);
                model.setMsg("添加成功");    
            }
            else{
                model.setMsg("添加失败");
            }    
            //System.out.println("Result:"+bl);
        }
        else{
        
        //System.out.println("Result:"+bl);
        }
        return model;
    }
 
    
    public ServiceModel delLimit(Object obj){
        Limit l=(Limit) obj;
        if(dao.del(l)){
            model.setCode(1);
            model.setMsg("删除成功");
        }else{
            model.setMsg("删除失败");
        }        
        return model;
    }
    
    public ServiceModel updateLimit(Object obj){
        Limit l=(Limit) obj;
        List<Limit> list=dao.serchByCondition(l);
        if(list.isEmpty()){
            if(dao.update(l)){
                model.setCode(1);
                model.setMsg("修改成功");
                
            }else{
                model.setMsg("修改失败");
            }
        }else{
            model.setMsg("修改失败");
        }
        return model;
    }
    
    public ServiceModel findLimit(Object obj){
        Limit l=(Limit) obj;
        List<Limit> list=dao.serchByCondition(l);
        if(list!=null && list.size()>0){
            model.setData(list);
            model.setCode(1);
        }else{
            model.setMsg("查询失败");
        }
        //for(Limit lm:list){
            //System.out.println(lm);
        //}
        return model;
    }
    
    public ServiceModel findLimitAll(){
        List<Limit> list=dao.searchAll();
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);
        }
            for(Limit lm:list){
            //System.out.println(lm);    
        }
        return model;
    }
    
    public ServiceModel findByInfo(Object obj){
        Limit l=(Limit) obj;
        List list=dao.serchByInfo(l);
        if(list==null || list.size()<1){
            model.setMsg("没有匹配的角色");
        }else{
            model.setData(list);
            model.setCode(1);
        }
        return model;
    }    
 
}