lxw
2020-07-11 9db52f2f2dd3665fe9da1ae5657e0167c3a34d40
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
111
112
113
114
115
116
package com.fgkj.services;
 
import java.util.List;
 
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.BaseDAOFactory;
import com.fgkj.dao.impl.User_battgroup_baojigroup_usrImpl;
import com.fgkj.dto.ServiceModel;
import com.fgkj.dto.User_battgroup_baojigroup_battgroup;
import com.fgkj.dto.User_battgroup_baojigroup_usr;
import com.fgkj.dto.User_inf;
 
public class User_battgroup_baojigroup_usrService {
    private ServiceModel model;
    private BaseDAO dao;
 
    public User_battgroup_baojigroup_usrService() {
        model = new ServiceModel();
        dao = BaseDAOFactory.getBaseDAO(BaseDAO.USER_BATTGROUP_BAOJIGROUP_USR);
    }
 
    /*// 5.3添加(包机组中添加用户)
    public ServiceModel add(Object obj) {
        Boolean bl = dao.add(obj);
        if (bl) {
            model.setCode(1);
            model.setMsg("添加用户到包机组成功!");
        } else {
            model.setMsg("添加用户到包机组失败!");
        }
        return model;
    }*/
    // 5.3添加(包机组中添加用户)
    public ServiceModel add(Object obj) {
        Boolean bl = ((User_battgroup_baojigroup_usrImpl)dao).addPro(obj);
        if (bl) {
            model.setCode(1);
            model.setMsg("添加用户到包机组成功!");
        } else {
            model.setMsg("添加用户到包机组失败!");
        }
        return model;
    }
    public ServiceModel update(Object obj) {
        Boolean bl = dao.update(obj);
        if (bl) {
            model.setCode(1);
            model.setMsg("修改成功!");
        } else {
            model.setMsg("修改失败!");
        }
        return model;
    }
    
 
    // 5.3删除(删除包机组中的用户)
    public ServiceModel delete(Object obj) {
        Boolean bl = dao.del(obj);
        if (bl) {
            model.setCode(1);
            model.setMsg("从包机组移除用户成功!");
        } else {
            model.setMsg("从包机组移除用户失败!");
        }
        return model;
    }
 
    public ServiceModel serchByCondition(Object obj) {
        List list = dao.serchByCondition(obj);
//        for (Object object : list) {
//            System.out.println(object);
//        }
        // System.out.println(list);
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
 
    public ServiceModel searchAll() {
        List<User_battgroup_baojigroup_usr> list = dao.searchAll();
//        for (User_battgroup_baojigroup_usr u : list) {
//            System.out.println(u);
//        }
 
        if (list != null && list.size() > 0) {
            model.setCode(1);
            model.setData(list);
        }
        return model;
    }
    
    //5.3查询不在某包机组下的用户
    public ServiceModel serchByInfo(Object obj){
        User_battgroup_baojigroup_usr uusr=(User_battgroup_baojigroup_usr) obj;
        List<User_inf> list=dao.serchByInfo(uusr);
        if(list!=null&&list.size()>0){
            model.setCode(1);
            model.setData(list);
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
 
 
    public static void main(String[] args) {
        User_battgroup_baojigroup_usrService us = new User_battgroup_baojigroup_usrService();
        User_battgroup_baojigroup_usr u = new User_battgroup_baojigroup_usr();
        u.setNum(6);
        us.serchByCondition(u);
        // us.searchAll();
    }
}