improvement: device 更名为 env

This commit is contained in:
shizhendong
2024-09-04 14:19:02 +08:00
parent 41ba204ee6
commit c861efd75d
10 changed files with 70 additions and 70 deletions

View File

@@ -1,7 +1,7 @@
package net.geedge.api.config;
import cn.hutool.log.Log;
import net.geedge.api.entity.DeviceApiYml;
import net.geedge.api.entity.EnvApiYml;
import net.geedge.common.T;
import org.springframework.web.socket.BinaryMessage;
import org.springframework.web.socket.CloseStatus;
@@ -17,9 +17,9 @@ public class VncProxyHandler extends TextWebSocketHandler {
private static final Log log = Log.get();
private DeviceApiYml.Vnc vnc;
private EnvApiYml.Vnc vnc;
public VncProxyHandler(DeviceApiYml.Vnc vnc) {
public VncProxyHandler(EnvApiYml.Vnc vnc) {
this.vnc = vnc;
}

View File

@@ -1,6 +1,6 @@
package net.geedge.api.config;
import net.geedge.api.entity.DeviceApiYml;
import net.geedge.api.entity.EnvApiYml;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
@@ -12,10 +12,10 @@ import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry
public class WebSocketConfig implements WebSocketConfigurer {
@Autowired
private DeviceApiYml deviceApiYml;
private EnvApiYml envApiYml;
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new VncProxyHandler(deviceApiYml.getVnc()), "/api/v1/device/websocket").setAllowedOrigins("*");
registry.addHandler(new VncProxyHandler(envApiYml.getVnc()), "/api/v1/env/websocket").setAllowedOrigins("*");
}
}

View File

@@ -2,7 +2,7 @@ package net.geedge.api.controller;
import cn.hutool.core.codec.Base32Codec;
import jakarta.servlet.http.HttpServletResponse;
import net.geedge.api.entity.DeviceApiYml;
import net.geedge.api.entity.EnvApiYml;
import net.geedge.api.util.AdbUtil;
import net.geedge.common.*;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,14 +15,14 @@ import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/v1/device")
@RequestMapping("/api/v1/env")
public class APIController {
private final AdbUtil adbUtil;
@Autowired
public APIController(DeviceApiYml deviceApiYml) {
this.adbUtil = AdbUtil.getInstance(deviceApiYml.getAdb());
public APIController(EnvApiYml envApiYml) {
this.adbUtil = AdbUtil.getInstance(envApiYml.getAdb());
}
@GetMapping("/status")

View File

@@ -3,14 +3,14 @@ package net.geedge.api.entity;
import lombok.Data;
@Data
public class DeviceApiYml {
public class EnvApiYml {
private Device device;
private Env env;
private Adb adb;
private Vnc vnc;
@Data
public class Device {
public class Env {
String type;
String platform;
String root;

View File

@@ -3,7 +3,7 @@ package net.geedge.api.util;
import cn.hutool.core.codec.Base32Codec;
import cn.hutool.core.thread.NamedThreadFactory;
import cn.hutool.log.Log;
import net.geedge.api.entity.DeviceApiYml;
import net.geedge.api.entity.EnvApiYml;
import net.geedge.common.APIException;
import net.geedge.common.Constant;
import net.geedge.common.RCode;
@@ -38,7 +38,7 @@ public class AdbUtil {
public record CommandResult(Integer exitCode, String output) {
}
private AdbUtil(DeviceApiYml.Adb adb) {
private AdbUtil(EnvApiYml.Adb adb) {
this.serial = T.StrUtil.emptyToDefault(adb.getSerial(), "");
this.host = adb.getHost();
this.port = adb.getPort();
@@ -48,7 +48,7 @@ public class AdbUtil {
this.init();
}
public static AdbUtil getInstance(DeviceApiYml.Adb connInfo) {
public static AdbUtil getInstance(EnvApiYml.Adb connInfo) {
if (instance == null) {
synchronized (AdbUtil.class) {
if (instance == null) {