工业级运维app手机api
xufenglei
2017-10-26 62a2c2cff2978dfcfe2fc4ef3e4c1e2a89835dbf
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
package com.moral.monitor.controller;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.WebUtils;
 
import com.moral.monitor.entity.AccountEntity;
import com.moral.monitor.service.ScreenService;
import com.moral.monitor.util.Crypto;
 
@RestController
@RequestMapping(value = "screen")
@CrossOrigin(origins = "*", maxAge = 3600)
public class ScreenController {
 
    @Autowired
    private ScreenService screenService;
    /**
     * Screen login.
     *
     * @param request the request
     * @return the map
     */
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public Map<String, Object> screenLogin(HttpServletRequest request) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        String msg = "";
        Integer accountId = -1;
        String account = request.getParameter("account");
        String password = request.getParameter("password");
        if (StringUtils.isBlank(account) || StringUtils.isBlank(password)) {
            msg = "用户名及密码不允许为空!";
        } else {
            try {
                password = Crypto.md5(password);
                List<AccountEntity> accountLists = screenService.getAccountLists(account, password);
                if (CollectionUtils.isEmpty(accountLists) || accountLists.size() != 1) {
                    msg = "用户名及密码输入错误!";
                } else {
                    AccountEntity accountEntity = accountLists.get(0);
                    if ("1".equals(accountEntity.getEnable())) {
                        msg = "登录成功!";
                        accountId = accountEntity.getId();
                    } else {
                        msg = "您的账号已禁用,请联系管理员!";
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
                msg = "系统正忙,请稍后再试!";
            }
        }
        resultMap.put("msg", msg);
        resultMap.put("accountId", accountId);
        return resultMap;
    }
    
    @RequestMapping(value = "/month-average", method = RequestMethod.GET)
    public Map<String, Object> getDataByEquipmentMac(HttpServletRequest request) {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request,null);
        Map<String, Object> resu =  screenService.getDataByEquipmentMac(parameters);
        return resu;
    }
 
    @RequestMapping(value = "/all-average", method = RequestMethod.GET)
    public Map<String, Object> getAverageByAll(HttpServletRequest request) {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request,null);
        Map<String, Object> resu =  screenService.getAverageByAll(parameters);
        return resu;
    }
}