From 87edfeea2b218924a9a4b37912fcdaf180cc9150 Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Tue, 08 May 2018 13:25:09 +0800
Subject: [PATCH] test
---
src/main/java/com/moral/controller/MobileController.java | 86 ++++++++++++++++++++++++++++--------------
1 files changed, 57 insertions(+), 29 deletions(-)
diff --git a/src/main/java/com/moral/controller/MobileController.java b/src/main/java/com/moral/controller/MobileController.java
index 848d02e..dec5579 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;
@@ -9,20 +10,15 @@
import javax.servlet.http.HttpServletRequest;
import com.moral.common.util.Crypto;
+import com.moral.entity.*;
+import com.moral.service.*;
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;
-import com.moral.entity.Device;
-import com.moral.entity.MonitorPoint;
-import com.moral.entity.OperateUser;
-import com.moral.entity.Organization;
-import com.moral.service.DeviceService;
-import com.moral.service.MonitorPointService;
-import com.moral.service.OperateUserService;
-import com.moral.service.OrganizationService;
/**
* The Class MobileController.
@@ -48,6 +44,9 @@
@Resource
private MonitorPointService monitorPointService;
+ @Resource
+ private ProfessionService professionService;
+
/**
* Mobile login.������
*
@@ -55,7 +54,7 @@
* @param password the password
* @return the result bean
*/
- @PostMapping("accountlogin")
+ @RequestMapping("accountlogin")
public AppData<OperateUser> mobileLogin(String username, String password) {
OperateUser operateUser = operateUserService.mobileLogin(username,password);
return new AppData<OperateUser>(operateUser);
@@ -75,14 +74,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 +132,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,11 +146,8 @@
* @param request the area name
* @return the monitor points by area name
*/
- @PostMapping("getMpointsByAreaName")
+ @GetMapping("getMpointsByAreaName")
public AppData<List<MonitorPoint>> getMonitorPointsByAreaName(HttpServletRequest request) {
- System.out.println("++++++++++++++++++++++++++++++++11111");
- System.out.println(request.getParameter("areaName"));
-
Map<String, Object> parameters = getParametersStartingWith(request, null);
List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByAreaName(parameters);
return new AppData<List<MonitorPoint>>(monitorPoints);
@@ -136,11 +159,8 @@
* @param request the area name
* @return the organizations by area name
*/
- @PostMapping("getOrgsByAreaName")
+ @GetMapping("getOrgsByAreaName")
public AppData<List<Organization>> getOrganizationsByAreaName(HttpServletRequest request) {
- System.out.println("++++++++++++++++++++++++++++++++22222");
- System.out.println(request.getParameter("areaName"));
-
Map<String, Object> parameters = getParametersStartingWith(request, null);
List<Organization> organizations = organizationService.getOrganizationsByAreaName(parameters);
return new AppData<List<Organization>>(organizations);
@@ -196,9 +216,10 @@
}
/**
- * Send SMS
*
- * @param mobile
+ * @param username
+ * @param password
+ * @param code
* @return
*/
@PostMapping("password")
@@ -235,4 +256,11 @@
return apiData;
}
}
+
+ @GetMapping("profession")
+ public AppData<List<Profession>> profession(){
+
+ List<Profession> professions = professionService.getProfessiontList();
+ return new AppData<List<Profession>>(professions);
+ }
}
--
Gitblit v1.8.0