whycrzg
2021-02-23 351b9a53cb9ecebdf8f79db0117f540d9c42c2a4
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package com.fgkj.services;
 
import com.fgkj.dto.*;
import com.fgkj.mapper.UinfDaoFactory;
import com.fgkj.mapper.impl.User_battgroup_baojigroup_usrMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
import javax.annotation.Resource;
@Service
public class User_battgroup_baojigroup_usrService {
 
    @Resource
    private User_battgroup_baojigroup_usrMapper mapper;
 
    @Resource
    private User_logService uservice;
 
    /*// 5.3添加(包机组中添加用户)
    public ServiceModel add(Object obj) {
        Boolean bl = mapper.add(obj);
        if (bl) {
            model.setCode(1);
            model.setMsg("添加用户到包机组成功!");
        } else {
            model.setMsg("添加用户到包机组失败!");
        }
        return model;
    }*/
    // 5.3添加(包机组中添加用户)
    @Transactional
    public ServiceModel add(List<User_battgroup_baojigroup_usr> list) {
        ServiceModel model = new ServiceModel();
        Boolean bl = true;
        if (list != null && list.size() > 0) {
            if (list != null && list.size() > 0) {
                try {
                    for (int i = 0; i < list.size(); i++) {
                        User_battgroup_baojigroup_usr uusr = list.get(i);
                        bl = mapper.addPro(uusr);
                        String msg = "添加" + uusr.getuName() + "用户至" + uusr.getBaoji_group_name() + "包机组中";
                        User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
                        uservice.add(ulog);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    model.setMsg("添加用户到包机组失败!");
                    return model;
                }
            }
 
        }
 
        if (bl) {
            model.setCode(1);
            model.setMsg("添加用户到包机组成功!");
        } else {
            model.setMsg("添加用户到包机组失败!");
        }
        return model;
    }
    public ServiceModel update(User_battgroup_baojigroup_usr obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl = null;
        try {
            bl = mapper.update(obj);
        } catch (Exception e) {
            e.printStackTrace();
            model.setMsg("修改失败!");
            return model;
        }
        if (bl) {
            model.setCode(1);
            model.setMsg("修改成功!");
        } else {
            model.setMsg("修改失败!");
        }
        return model;
    }
    
 
    // 5.3删除(删除包机组中的用户)
    public ServiceModel delete(User_battgroup_baojigroup_usr obj) {
        ServiceModel model = new ServiceModel();
        Boolean bl = null;
        try {
            bl = mapper.del(obj)>0;
        } catch (Exception e) {
            e.printStackTrace();
            model.setMsg("从包机组移除用户失败!");
            return model;
        }
        if (bl) {
            model.setCode(1);
            model.setMsg("从包机组移除用户成功!");
        } else {
            model.setMsg("从包机组移除用户失败!");
        }
        return model;
    }
    //穿梭框包机组删除多个用户
    @Transactional
    public ServiceModel delPro(List<User_battgroup_baojigroup_usr> list) {
        ServiceModel model = new ServiceModel();
        Boolean bl = true;
        if (list != null && list.size() > 0) {
            if (list != null && list.size() > 0) {
                for (int i = 0; i < list.size(); i++) {
                    try {
                        User_battgroup_baojigroup_usr uusr = list.get(i);
                        bl = mapper.delPro(uusr) > 0;
                        {
                            String msg = "将" + uusr.getuName() + "用户从" + uusr.getBaoji_group_name() + "包机组中删除";
                            User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
                            uservice.add(ulog);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        model.setCode(0);
                        model.setMsg("删除失败!");
                        return model;
                    }
                }
            }
 
        }
        if (bl) {
            model.setCode(1);
            model.setMsg("删除成功!");
        } else {
            model.setMsg("删除失败!");
        }
        return model;
    }
    public ServiceModel serchByCondition(User_battgroup_baojigroup_usr obj) {
        ServiceModel model = new ServiceModel();
        List<User_battgroup_baojigroup_usr> list = mapper.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() {
        ServiceModel model = new ServiceModel();
        List list = mapper.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(User_battgroup_baojigroup_usr obj){
        ServiceModel model = new ServiceModel();
        User_battgroup_baojigroup_usr uusr=(User_battgroup_baojigroup_usr) obj;
        List<User_inf> list=mapper.serchByInfo(uusr);
        if(list!=null&&list.size()>0){
            model.setCode(1);
            model.setData(list);
        }else{
            model.setCode(0);
            model.setMsg("查询失败!");
        }
        return model;
    }
}