ServiceController.java
1.91 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
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.data.id.IdUtil;
import org.springframework.web.bind.annotation.*;
import vion.model.monitor.ServiceInfo;
import vion.service.monitor.IServiceInfoService;
/**
* 服务
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/service")
public class ServiceController {
private final IServiceInfoService serviceInfoService;
@GetMapping
@SaCheckPermission(value = "service:list", orRole = "admin")
public Page<ServiceInfo> list(ServiceInfo dto) {
return serviceInfoService.lambdaQuery(dto)
.orderByAsc(ServiceInfo::getCreateTime)
.orderByDesc(ServiceInfo::getUpdateTime)
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
}
@GetMapping("/{id}")
@SaCheckPermission(value = "service:query", orRole = "admin")
public ServiceInfo get(@PathVariable Long id) {
return serviceInfoService.getById(id);
}
@PostMapping
@SaCheckPermission(value = "service:save", orRole = "admin")
public String save(@RequestBody ServiceInfo serviceInfo) {
serviceInfo.setUid(IdUtil.nanoId(16));
serviceInfoService.save(serviceInfo);
return "服务添加成功";
}
@PostMapping("/{id}")
@SaCheckPermission(value = "service:edit", orRole = "admin")
public String update(@PathVariable Long id, @RequestBody ServiceInfo serviceInfo) {
serviceInfo.setId(id);
serviceInfoService.updateById(serviceInfo);
return "服务更新成功";
}
@DeleteMapping("/{id}")
@SaCheckPermission(value = "service:remove", orRole = "admin")
public String remove(@PathVariable Long id) {
serviceInfoService.removeById(id);
return "服务删除成功";
}
}