工业级运维app手机api
xufenglei
2018-01-15 2e2861fd0bbba403a15a212c550bed9f8331f467
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
package com.moral.monitor.controller;
 
import com.moral.monitor.entity.*;
import com.moral.monitor.service.UserService;
import com.moral.monitor.util.JsonData;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
 
/**
 * Created by dgw on 2017/4/11.
 */
@Controller
@RequestMapping("user")
@CrossOrigin(origins = "*", maxAge = 3600)
public class UserController {
    private static final Log log = LogFactory.getLog(UserController.class);
    @Autowired
    UserService userService;
    @RequestMapping("main")
    public String showIndex(HttpServletRequest reqs){
        return "view/main";
    }
    /**
     * 从用户表中查询出所有记录
     * @author dgw at 2017.4.11
     * @return jd
     */
    @RequestMapping("/findAllUser")
    @ResponseBody
    public Map findAllUser(@RequestBody QueryHelper queryHelper){
 
        String search = queryHelper.getSearch();
 
        String trim = queryHelper.getSearch().trim();
        if(trim.equals("")){
            queryHelper.setSearch("");
        }
 
        LinkedHashMap<String, Object> s = new LinkedHashMap<String, Object>();
        List<User> users = userService.allUsers(queryHelper);
        s.put("rows",users);
 
        int total = userService.userscount(queryHelper);
        s.put("total",total);
 
        return s;
    }
 
 
 
    @RequestMapping("/deleteUser")
    @ResponseBody
    public String deleteUser(@RequestParam("ids[]") String[] ids){
        try{
            for (String id:ids){
                if (!(id.equals(""))) {
                    userService.deleteUser(id);
                }
            }
        }
        catch (Exception e){
            log.debug(e.getMessage());
            return "false";
        }
        return "true";
    }
 
 
 
    @RequestMapping("/group")
    @ResponseBody
    public List group(){
        List<Group> g = userService.group();
        return g;
    }
 
 
 
    @RequestMapping("/adduser")
    @ResponseBody
    public String adduser(@RequestBody User user){
        try {
            userService.adduser(user);
            String[] s = user.getSelected();
            if(s.length>0){
                User u = userService.finduserbymobile(user.getMobile());
                int id = u.getId();
                for (String g:s){
                    userService.intogroupuser(g,id);
                }
            }
        }catch (Exception e){
            log.debug(e.getMessage());
            return "false";
        }
        return "true";
    }
 
 
    /*修改时的用户组回显*/
    @RequestMapping("/groupuser")
    @ResponseBody
    public List groupuser(String mobile){
        User user = userService.finduserbymobile(mobile);
        int id = user.getId();
        List<GroupUser> g = userService.groupuser(id);
        return g;
    }
 
 
 
 
    @RequestMapping("/edituser")
    @ResponseBody
    public String edituser(@RequestBody User user){
        int id = user.getId();
        String[] s = user.getSelected();
        try {
             userService.updateuser(user);
             userService.deletegroupuser(id);
            for (String g:s){
                userService.intogroupuser(g,id);
            }
 
 
        }catch (Exception e){
            log.debug(e.getMessage());
            return "false";
        }
        return "true";
    }
 
 
 
 
 
 
 
 
    @RequestMapping("/findInstaller")
    @ResponseBody
    public List<Map<String,Object>> findInstaller(HttpServletRequest reqs){
      /*  List<Map<String,Object>> lisu = new ArrayList<Map<String, Object>>();
        lisu = service.findAllUser();
        return lisu;
 
    }
    @RequestMapping(value="/insertUser",method = RequestMethod.POST)
    @ResponseBody
    public void insertUser(@RequestBody UserEntity userEntity){
 
        service.insertUser(userEntity);
 
    }
    @RequestMapping("/updataUser")
    @ResponseBody
    public void updataUser(HttpServletRequest reqs,UserEntity userEntity){
        JsonData jd = new JsonData();
        service.updataUser(userEntity);
    }
    @RequestMapping("/deleUser")
    @ResponseBody
    public JsonData deleUser(HttpServletRequest reqs, int id){
        JsonData jd = new JsonData();
        service.deleUser(id);
        return jd;*/
 
      return null;
    }
 
    @RequestMapping("/selectUser")
    @ResponseBody
    public UserEntity selectUser(HttpServletRequest reqs, int id){/*
        UserEntity userEntity = service.selectUserByid(id);
        return userEntity;*/
        return null;
    }
    @RequestMapping(value="/selectCountUser",method = RequestMethod.POST)
    @ResponseBody
    public int selectCountUser(String name){
        /*return service.selectCountUser(name);*/
 
        return 0;
    }
 
 
 
 
 
}