From 1c6fb0320ba354ec40faaad9dcc52e758f5c838f Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei@blit.7drlb.com>
Date: Tue, 24 Oct 2017 10:48:14 +0800
Subject: [PATCH] 大屏登录接口
---
src/main/java/com/moral/monitor/controller/ScreenApiController.java | 80 +++++++++++++++++++++++++++++++--------
1 files changed, 63 insertions(+), 17 deletions(-)
diff --git a/src/main/java/com/moral/monitor/controller/ScreenApiController.java b/src/main/java/com/moral/monitor/controller/ScreenApiController.java
index 37b8ebc..9aba7e9 100644
--- a/src/main/java/com/moral/monitor/controller/ScreenApiController.java
+++ b/src/main/java/com/moral/monitor/controller/ScreenApiController.java
@@ -1,27 +1,41 @@
package com.moral.monitor.controller;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
import com.alibaba.fastjson.JSON;
+import com.moral.monitor.entity.AccountEntity;
import com.moral.monitor.entity.Equipment;
import com.moral.monitor.entity.State;
import com.moral.monitor.service.ScreenApiService;
+import com.moral.monitor.service.ScreenService;
+import com.moral.monitor.util.Crypto;
import com.moral.monitor.util.ScreenApiData;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import javax.annotation.Resource;
-import java.util.LinkedHashMap;
-import java.util.List;
/**
* Created by a on 2017/7/12.
*/
-@Controller
+@RestController
@RequestMapping(value = "screen")
public class ScreenApiController {
- @Resource
+ @Autowired
ScreenApiService screenApiService;
+ @Autowired
+ private ScreenService screenService;
/**
* ������������/������������ ���������������������������������������������������������������������
* @param area ������������������������ ������������������������������
@@ -132,13 +146,45 @@
}
-
-
-
-
-
-
-
-
-
+
+ /**
+ * Screen login.
+ *
+ * @param request the request
+ * @return the map
+ */
+ @RequestMapping(value = "/login", method = RequestMethod.POST)
+ 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;
+ }
+
}
--
Gitblit v1.8.0