|
@@ -1,6 +1,11 @@
|
|
package net.mooctest.www.android_auto_test.controller;
|
|
package net.mooctest.www.android_auto_test.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import net.mooctest.www.android_auto_test.common.constant.enums.DeviceStatus;
|
|
import net.mooctest.www.android_auto_test.common.exceptions.LackParamsException;
|
|
import net.mooctest.www.android_auto_test.common.exceptions.LackParamsException;
|
|
|
|
+import net.mooctest.www.android_auto_test.models.Device;
|
|
|
|
+import net.mooctest.www.android_auto_test.services.DeviceService;
|
|
import net.mooctest.www.android_auto_test.utils.SnowFlake;
|
|
import net.mooctest.www.android_auto_test.utils.SnowFlake;
|
|
import net.mooctest.www.android_auto_test.vo.TraceMetaInfo;
|
|
import net.mooctest.www.android_auto_test.vo.TraceMetaInfo;
|
|
import net.mooctest.www.android_auto_test.vo.TraceStatusResult;
|
|
import net.mooctest.www.android_auto_test.vo.TraceStatusResult;
|
|
@@ -8,6 +13,8 @@ import net.mooctest.www.android_auto_test.services.AutoTestService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author henrylee
|
|
* @author henrylee
|
|
@@ -18,6 +25,9 @@ public class AutoTestController {
|
|
@Autowired
|
|
@Autowired
|
|
AutoTestService autoTestService;
|
|
AutoTestService autoTestService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ DeviceService deviceService;
|
|
|
|
+
|
|
@RequestMapping(value = "/api/v1/runTest", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/api/v1/runTest", method = RequestMethod.POST)
|
|
public TraceStatusResult runTest(@RequestBody TraceMetaInfo traceInfo) throws LackParamsException {
|
|
public TraceStatusResult runTest(@RequestBody TraceMetaInfo traceInfo) throws LackParamsException {
|
|
if (traceInfo.getTraceId() == null){
|
|
if (traceInfo.getTraceId() == null){
|
|
@@ -44,4 +54,20 @@ public class AutoTestController {
|
|
public boolean stopDevice(@RequestParam(name = "udid") String udid){
|
|
public boolean stopDevice(@RequestParam(name = "udid") String udid){
|
|
return autoTestService.stopDevice(udid);
|
|
return autoTestService.stopDevice(udid);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value = "/api/v1/devices", method = RequestMethod.GET)
|
|
|
|
+ public JSONArray getDevices(){
|
|
|
|
+ List<Device> devices = deviceService.getOnlineDeviceList();
|
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
|
+ for (Device d: devices){
|
|
|
|
+ String udid = d.getUdid();
|
|
|
|
+ DeviceStatus ds = deviceService.getDeviceStatus(udid);
|
|
|
|
+ JSONObject jo = new JSONObject();
|
|
|
|
+ jo.put("udid", udid);
|
|
|
|
+ jo.put("status", ds.getCode());
|
|
|
|
+ jo.put("statusDes", ds.getDescription());
|
|
|
|
+ jsonArray.add(jo);
|
|
|
|
+ }
|
|
|
|
+ return jsonArray;
|
|
|
|
+ }
|
|
}
|
|
}
|