From dba72443e05e7b0a52ee85bfd9f4641aebc42c60 Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Thu, 07 Dec 2017 08:58:09 +0800 Subject: [PATCH] app接口 --- src/main/java/com/moral/controller/ScreenController.java | 43 +++++++++++-------------------------------- 1 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java index 893bd61..0da945c 100644 --- a/src/main/java/com/moral/controller/ScreenController.java +++ b/src/main/java/com/moral/controller/ScreenController.java @@ -12,11 +12,10 @@ import java.util.LinkedHashMap; import java.util.Map; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.io.Resource; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -27,15 +26,14 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONReader; import com.alibaba.fastjson.TypeReference; -import com.moral.common.bean.ResultBean; import com.moral.common.exception.BusinessException; -import com.moral.entity.Account; +import com.moral.common.util.ValidateUtil; import com.moral.service.AccountService; import com.moral.service.DeviceService; import com.moral.service.HistoryService; /** - * The Class ScreenController. + * The Class ScreenController.������������ */ @RestController @RequestMapping(value = "screen") @@ -43,24 +41,24 @@ public class ScreenController { /** The screen service. */ - @Autowired + @Resource private HistoryService historyService; /** The account service. */ - @Autowired + @Resource private AccountService accountService; /** The device service. */ - @Autowired + @Resource private DeviceService deviceService; /** The resource. */ @Value(value = "classpath:system/alarmLevels.json") - private Resource resource; + private org.springframework.core.io.Resource resource; /** The redis template. */ - @javax.annotation.Resource - RedisTemplate<String, String> redisTemplate; + @Resource + private RedisTemplate<String, String> redisTemplate; /** The level key. */ private String levelKey = "alarm_level_config"; @@ -85,22 +83,6 @@ return resultMap; } - @GetMapping("login1") - public ResultBean<Account> screenLogin1(HttpServletRequest request) { - ResultBean<Account> resultBean = new ResultBean<Account>(ResultBean.FAIL); - try { - Map<String, Object> parameters = getParametersStartingWith(request, null); - if (!(parameters.containsKey("account") && parameters.containsKey("password"))) { - resultBean.setMsg("������������������������������������"); - } else { - resultBean = accountService.screenLogin1(parameters); - } - } catch (Exception e) { - e.printStackTrace(); - resultBean = new ResultBean<Account>(e); - } - return resultBean; - } /** * Gets the equipment states. ��������������������������������������� @@ -157,11 +139,8 @@ @GetMapping("sensor-standard") public Map<String, Object> getStandardBySensor(@RequestParam("macKey") String macKey) { Map<String, Object> result = new HashMap<String, Object>(); - if (isEmpty(macKey)) { - throw new BusinessException("���������������������"); - } else { - result.put("standard", getValue(macKey + "-standard")); - } + ValidateUtil.notEmpty(macKey, "���������������������"); + result.put("standard", getValue(macKey + "-standard")); return result; } -- Gitblit v1.8.0