Skip to content

Commit

Permalink
feat: add hub contorl
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Dec 11, 2022
1 parent b17a47e commit 8a4782a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;

Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<Devices>> listByAgentId(@RequestParam(name = "agentId") int agentId) {
return new RespModel<>(RespEnum.SEARCH_OK,
devicesService.listByAgentId(agentId));
}

@WebAspect
@ApiOperation(value = "修改设备安装密码", notes = "修改对应设备id的安装密码")
@PutMapping("/saveDetail")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8a4782a

Please sign in to comment.