AgentController.java
2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package vion.controller.monitor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.AgentDTO;
import vion.model.monitor.RAgentService;
import vion.model.monitor.ServiceInfo;
import vion.service.monitor.IAgentService;
import vion.vo.AgentVO;
import java.util.List;
/**
* Agent
*/
@RestController
@RequestMapping("/api/agent")
@RequiredArgsConstructor
public class AgentController {
private final IAgentService agentService;
@GetMapping
@SaCheckPermission(value = "agent:list", orRole = "admin")
public Page<AgentVO> list(AgentDTO dto) {
return agentService.list(dto);
}
@GetMapping("/{id}")
@SaCheckPermission(value = "agent:query", orRole = "admin")
private AgentVO get(@PathVariable Long id) {
return agentService.getVOById(id);
}
@PostMapping("/{id}")
@SaCheckPermission(value = "agent:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody AgentDTO dto) {
dto.setId(id);
return agentService.update(dto);
}
@PostMapping("/upgrade/{id}")
@SaCheckPermission(value = "agent:upgrade", orRole = "admin")
public String upgradeCommand(@RequestBody AgentDTO dto) {
//todo
return "";
}
@GetMapping("/service/{uid}")
@SaCheckPermission(value = "agent:service:query", orRole = "admin")
public List<ServiceInfo> getServicesByUid(@PathVariable String uid) {
return agentService.getServicesByUid(uid);
}
@PostMapping("/service/{uid}")
@SaCheckPermission(value = "agent:service:save", orRole = "admin")
public String saveServicesByUid(@PathVariable String uid, @RequestBody List<ServiceInfo> serviceInfoList) {
return agentService.saveServicesByUid(uid, serviceInfoList);
}
@PostMapping("/service/{id}")
@SaCheckPermission(value = "agent:service:edit", orRole = "admin")
public String updateAgent2ServiceById(@PathVariable Long id, @RequestBody RAgentService rAgentService) {
return agentService.updateAgent2ServiceById(id, rAgentService);
}
@DeleteMapping("/service/{id}")
@SaCheckPermission(value = "agent:service:remove", orRole = "admin")
public String removeAgent2ServiceById(@PathVariable Long id) {
return agentService.removeAgent2ServiceById(id);
}
@PostMapping("/service/assign/{uid}")
@SaCheckPermission(value = "agent:service:assign", orRole = "admin")
public String assign(@PathVariable String uid, @RequestBody List<ServiceInfo> serviceInfoList) {
return agentService.assign(uid, serviceInfoList);
}
}