EventController.java
3.2 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
81
82
83
84
85
86
87
package vion.controller.monitor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.data.id.IdUtil;
import org.springframework.web.bind.annotation.*;
import vion.dto.monitor.EventDTO;
import vion.model.monitor.Event;
import vion.model.monitor.RAgentEvent;
import vion.service.monitor.IEventService;
import vion.service.monitor.IRAgentEventService;
import vion.vo.monitor.EventVO;
import java.util.List;
/**
* 事件管理
*/
@RestController
@RequestMapping("/api/event")
@RequiredArgsConstructor
public class EventController {
private final IEventService eventService;
private final IRAgentEventService agentEventService;
@GetMapping
@SaCheckPermission(value = "event:list", orRole = "admin")
public Page<Event> list(Event event) {
return eventService.lambdaQuery(event)
.in(CollUtil.isNotEmpty(event.getTypeList()), Event::getType, event.getTypeList())
.orderByDesc(Event::getCreateTime)
.page(Page.of(event.getPageNum(), event.getPageSize()));
}
@GetMapping("/{id}")
@SaCheckPermission(value = "event:query", orRole = "admin")
public Event get(@PathVariable Long id) {
return eventService.getById(id);
}
@PostMapping
@SaCheckPermission(value = "event:save", orRole = "admin")
public String save(@RequestBody Event event) {
event.setUid(IdUtil.nanoId(20));
return eventService.save(event) ? "事件添加成功" : "事件添加失败";
}
@PostMapping("/{id}")
@SaCheckPermission(value = "event:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody Event event) {
event.setId(id);
return eventService.updateById(event) ? "事件更新成功" : "事件更新失败";
}
@DeleteMapping("/{id}")
@SaCheckPermission(value = "event:remove", orRole = "admin")
public String remove(@PathVariable Long id) {
return eventService.removeById(id) ? "事件删除成功" : "事件删除失败";
}
@GetMapping("/bind")
@SaCheckPermission(value = "event:bind:list", orRole = "admin")
public Page<EventVO> listAgentEvent(EventDTO dto) {
return eventService.list(dto);
}
@PostMapping("/bind/{agentUid}/{mallUid}")
@SaCheckPermission(value = "event:bind", orRole = "admin")
public String bind(@PathVariable String agentUid, @PathVariable String mallUid, @RequestBody List<RAgentEvent> dtoList) {
return agentEventService.bind(agentUid, mallUid, dtoList);
}
@PostMapping("/unbind/{agentUid}/{mallUid}")
@SaCheckPermission(value = "event:unbind", orRole = "admin")
public String unbind(@PathVariable String agentUid, @PathVariable String mallUid, List<Long> idList) {
return agentEventService.unbind(agentUid, mallUid, idList);
}
@PostMapping("/bind/batch/{agentUid}")
@SaCheckPermission(value = "event:bind:batch", orRole = "admin")
public String bindBatch(@PathVariable String agentUid, @RequestBody RAgentEvent dto) {
return agentEventService.bindBatch(agentUid, dto);
}
}