whyclj
2020-07-22 a5729100cb1eaa3584b3a194e46e1b8b52b3ed1a
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
package com.fgkj.services;
 
import java.util.Iterator;
import java.util.List;
 
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dto.Limit;
import com.fgkj.dto.RoleLimit;
import com.fgkj.dto.Roles;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.UserRole;
 
public class UserRoleService {
    private BaseDAO dao;
    private ServiceModel model;
        
    public UserRoleService() {
        dao = BaseDAOFactory.getBaseDAO(5);
        model = new ServiceModel();
    }
     
    public ServiceModel findAllUserRole(){
        List list=dao.searchAll();
        if(list!=null && list.size()>0){
            model.setCode(1);
            model.setData(list);    
        }
        return model;
    } 
    
    public ServiceModel addUserRole(Object obj){
        UserRole ur=(UserRole) obj;
        List<UserRole> list=dao.serchByCondition(ur);
        Boolean bl=false;
        //System.out.println(ur);
        if(list.isEmpty()){
             bl=dao.add(ur);
            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 del(Object obj){
        boolean flag=dao.del(obj);
        if(flag){
            model.setCode(1);
            model.setMsg("删除成功");
        }else{
            model.setMsg("删除失败");
        }
        return model;
    }
    
}