工业级运维app手机api
沈斌
2018-02-28 10452b5c9fee46e4c0a6bea0da89371d60ec10bb
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
package com.moral.monitor.controller;
 
import com.moral.monitor.entity.MonitorPoint;
import com.moral.monitor.entity.QueryHelper;
import com.moral.monitor.service.MonitorpointService;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
 
/**
 * Created by a on 2017/7/18.
 */
@Controller
public class MonitorPointController {
 
    private static final Log log = LogFactory.getLog(MonitorPointController.class);
 
    @Autowired
    MonitorpointService monitorPointService;
 
    @RequestMapping("/findAllMonitorpoint")
    @ResponseBody
    public Map findAllMonitorpoint(@RequestBody QueryHelper queryHelper){
 
        String trim = queryHelper.getSearch().trim();
        if(trim.equals("")){
            queryHelper.setSearch("");
        }
 
        LinkedHashMap<String, Object> s = new LinkedHashMap<String, Object>();
        List<MonitorPoint> equs = monitorPointService.allMonitorpoint(queryHelper);
        s.put("rows",equs);
 
        int total = monitorPointService.monitorCount(queryHelper);
        s.put("total",total);
 
        return s;
 
    }
 
 
 
    @RequestMapping("/deleteMonitor")
    @ResponseBody
    public String deleteUser(@RequestParam("ids[]") String[] ids){
        try{
            for (String id:ids){
                if (!(id.equals(""))) {
                    monitorPointService.deleteMonitor(id);
                }
            }
        }
        catch (Exception e){
            log.debug(e.getMessage());
            return "false";
        }
        return "true";
    }
 
 
 
    @RequestMapping("/addMonitorpoint")
    @ResponseBody
    public String addMonitorpoint(@RequestBody MonitorPoint monitorPoint){
 
        try {
            String name = monitorPoint.getName();
            String address = monitorPoint.getAddress();
 
            if (name.trim().equals("")||address.trim().equals("")){
                return "false";
            }
            monitorPointService.addMonitorpoint(monitorPoint);
        }catch (Exception e){
            log.debug(e.getMessage());
            return "false";
        }
        return "true";
    }
 
 
 
    @RequestMapping("/editMonitorPoint")
    @ResponseBody
    public String editMonitorPoint(@RequestBody MonitorPoint monitorPoint){
        try {
            monitorPointService.updateMonitorpoint(monitorPoint);
        }catch (Exception e){
            log.debug(e.getMessage());
            return "false";
        }
        return "true";
    }
 
 
 
}