From 606c896c1b7c9d986cfb13d8464f3482160a1389 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Tue, 08 May 2018 09:47:40 +0800 Subject: [PATCH] 手机 设备 保存 api --- src/main/java/com/moral/controller/MobileController.java | 58 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/moral/controller/MobileController.java b/src/main/java/com/moral/controller/MobileController.java index 67cf364..9bc8e52 100644 --- a/src/main/java/com/moral/controller/MobileController.java +++ b/src/main/java/com/moral/controller/MobileController.java @@ -2,6 +2,7 @@ import static com.moral.common.util.WebUtils.getParametersStartingWith; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -12,6 +13,7 @@ import com.moral.util.MessageUtils; import com.taobao.api.ApiException; import org.apache.commons.lang3.StringUtils; +import org.springframework.cglib.beans.BeanMap; import org.springframework.web.bind.annotation.*; import com.moral.common.bean.AppData; @@ -75,14 +77,38 @@ return new AppData<OperateUser>(operateUser); } - /** - * Install device.������������ - * - * @param device the device - * @return the result bean - */ + /** + * + * @param request + * @param uid + * @param deviceName + * @param address + * @param longitude + * @param latitude + * @param mac + * @param monitorpoint + * @return + */ @PostMapping("reportDevice") - public AppData<String> installDevice(Device device) { + public AppData<String> installDevice( + HttpServletRequest request , + @RequestParam(value ="uid") Integer uid, + @RequestParam(value ="device_name") String deviceName, + @RequestParam(value ="address") String address, + @RequestParam(value ="longitude") double longitude, + @RequestParam(value ="latitude") double latitude, + @RequestParam(value ="mac") String mac, + @RequestParam(value ="monitorpoint") Integer monitorpoint + ) { + // device ������ + Device device = new Device(); + device.setOperateUserId(uid); + device.setName(deviceName); + device.setAddress(address); + device.setLongitude(longitude); + device.setLatitude(latitude); + device.setMac(mac); + device.setMonitorPointId(monitorpoint); deviceService.saveOrUpdateDevice(device); return new AppData<String>(""); } @@ -109,9 +135,12 @@ * @return the device by mac */ @GetMapping("getEquInfoByMac") - public AppData<Device> getDeviceByMac(@RequestParam(value="mac", required=true)String mac) { - Device device = deviceService.getDeviceByMac(mac); - return new AppData<Device>(device); + public AppData<Map> getDeviceByMac(@RequestParam(value="mac", required=true)String mac) { + Device device = deviceService.getDeviceByMac(mac,false);//��������������� + Map<String,Object> deviceMap = new HashMap<>(BeanMap.create(device)); + deviceMap.put("monitorpointDetail",deviceMap.get("monitorPoint")); + deviceMap.remove("monitorPoint"); + return new AppData<Map>(deviceMap); } /** @@ -120,7 +149,7 @@ * @param request the area name * @return the monitor points by area name */ - @PostMapping("getMpointsByAreaName") + @GetMapping("getMpointsByAreaName") public AppData<List<MonitorPoint>> getMonitorPointsByAreaName(HttpServletRequest request) { Map<String, Object> parameters = getParametersStartingWith(request, null); List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByAreaName(parameters); @@ -133,7 +162,7 @@ * @param request the area name * @return the organizations by area name */ - @PostMapping("getOrgsByAreaName") + @GetMapping("getOrgsByAreaName") public AppData<List<Organization>> getOrganizationsByAreaName(HttpServletRequest request) { Map<String, Object> parameters = getParametersStartingWith(request, null); List<Organization> organizations = organizationService.getOrganizationsByAreaName(parameters); @@ -190,9 +219,10 @@ } /** - * Send SMS * - * @param mobile + * @param username + * @param password + * @param code * @return */ @PostMapping("password") -- Gitblit v1.8.0