diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/AgentsController.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/AgentsController.java index a8768329..60cc67f4 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/AgentsController.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/AgentsController.java @@ -18,6 +18,8 @@ package org.cloud.sonic.controller.controller; import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import org.cloud.sonic.common.config.WebAspect; import org.cloud.sonic.common.http.RespEnum; import org.cloud.sonic.common.http.RespModel; @@ -27,6 +29,7 @@ import org.cloud.sonic.controller.services.AgentsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.cloud.sonic.controller.transport.TransportWorker; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -46,6 +49,23 @@ public class AgentsController { @Autowired private AgentsService agentsService; + @WebAspect + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "id", value = "id", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "position", value = "position", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "type", value = "type", dataTypeClass = String.class) + }) + @GetMapping("/hubControl") + public RespModel hubControl(@RequestParam(name = "id") int id, @RequestParam(name = "position") int position, + @RequestParam(name = "type") String type) { + JSONObject result = new JSONObject(); + result.put("msg", "hub"); + result.put("position", position); + result.put("type", type); + TransportWorker.send(id, result); + return new RespModel<>(RespEnum.HANDLE_OK); + } + @WebAspect @ApiOperation(value = "查询所有Agent端", notes = "获取所有Agent端以及详细信息") @GetMapping("/list") diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/DevicesController.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/DevicesController.java index 82e8fb00..c10117dd 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/DevicesController.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/DevicesController.java @@ -45,6 +45,15 @@ public class DevicesController { @Autowired private DevicesService devicesService; + @WebAspect + @ApiOperation(value = "查询Agent所有设备", notes = "不分页的设备列表") + @ApiImplicitParam(name = "agentId", value = "平台", dataTypeClass = Integer.class) + @GetMapping("/listByAgentId") + public RespModel> listByAgentId(@RequestParam(name = "agentId") int agentId) { + return new RespModel<>(RespEnum.SEARCH_OK, + devicesService.listByAgentId(agentId)); + } + @WebAspect @ApiOperation(value = "修改设备安装密码", notes = "修改对应设备id的安装密码") @PutMapping("/saveDetail") diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/AgentsServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/AgentsServiceImpl.java index 2ce4a4a3..1271a936 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/AgentsServiceImpl.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/AgentsServiceImpl.java @@ -69,6 +69,7 @@ public void update(int id, String name, int highTemp, int highTempTime, int robo agents.setRobotToken(robotToken); agents.setRobotSecret(robotSecret); agents.setSecretKey(UUID.randomUUID().toString()); + agents.setHasHub(0); save(agents); } else { Agents ag = findById(id);