1 | package org.cardanofoundation.explorer.api.controller; | |
2 | ||
3 | import jakarta.validation.Valid; | |
4 | ||
5 | import lombok.RequiredArgsConstructor; | |
6 | ||
7 | import org.springframework.data.domain.Sort; | |
8 | import org.springframework.http.ResponseEntity; | |
9 | import org.springframework.validation.annotation.Validated; | |
10 | import org.springframework.web.bind.annotation.GetMapping; | |
11 | import org.springframework.web.bind.annotation.PathVariable; | |
12 | import org.springframework.web.bind.annotation.RequestMapping; | |
13 | import org.springframework.web.bind.annotation.RestController; | |
14 | ||
15 | import io.swagger.v3.oas.annotations.Operation; | |
16 | import io.swagger.v3.oas.annotations.Parameter; | |
17 | import io.swagger.v3.oas.annotations.tags.Tag; | |
18 | import org.springdoc.core.annotations.ParameterObject; | |
19 | ||
20 | import org.cardanofoundation.explorer.api.config.LogMessage; | |
21 | import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse; | |
22 | import org.cardanofoundation.explorer.api.model.response.BlockFilterResponse; | |
23 | import org.cardanofoundation.explorer.api.model.response.EpochResponse; | |
24 | import org.cardanofoundation.explorer.api.model.response.dashboard.EpochSummary; | |
25 | import org.cardanofoundation.explorer.api.service.BlockService; | |
26 | import org.cardanofoundation.explorer.api.service.EpochService; | |
27 | import org.cardanofoundation.explorer.common.validation.pagination.Pagination; | |
28 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault; | |
29 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid; | |
30 | ||
31 | @RestController | |
32 | @RequestMapping("/api/v1/epochs") | |
33 | @RequiredArgsConstructor | |
34 | @Validated | |
35 | @Tag(name = "epoch", description = "The epoch APIs") | |
36 | public class EpochController { | |
37 | ||
38 | private final EpochService epochService; | |
39 | ||
40 | private final BlockService blockService; | |
41 | ||
42 | @GetMapping("/{no}") | |
43 | @LogMessage | |
44 | @Operation( | |
45 | summary = "Get summary information of epoch by its number", | |
46 | tags = {"epoch"}) | |
47 | public ResponseEntity<EpochResponse> getEpochDetail( | |
48 | @PathVariable @Parameter(description = "The epoch number") String no) { | |
49 |
1
1. getEpochDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/EpochController::getEpochDetail → KILLED |
return ResponseEntity.ok(epochService.getEpochDetail(no)); |
50 | } | |
51 | ||
52 | @GetMapping("/{no}/blocks") | |
53 | @LogMessage | |
54 | @Operation( | |
55 | summary = "Get block list of epoch by its number", | |
56 | tags = {"epoch"}) | |
57 | public ResponseEntity<BaseFilterResponse<BlockFilterResponse>> getBlockList( | |
58 | @PathVariable @Parameter(description = "The epoch number") String no, | |
59 | @ParameterObject | |
60 | @PaginationValid | |
61 | @PaginationDefault( | |
62 | size = 20, | |
63 | sort = {"id"}, | |
64 | direction = Sort.Direction.DESC) | |
65 | @Valid | |
66 | Pagination pagination) { | |
67 |
1
1. getBlockList : replaced return value with null for org/cardanofoundation/explorer/api/controller/EpochController::getBlockList → KILLED |
return ResponseEntity.ok(blockService.getBlockByEpoch(no, pagination.toPageable())); |
68 | } | |
69 | ||
70 | @GetMapping | |
71 | @LogMessage | |
72 | @Operation( | |
73 | summary = "Get all epoch", | |
74 | tags = {"epoch"}) | |
75 | public ResponseEntity<BaseFilterResponse<EpochResponse>> filter( | |
76 | @ParameterObject | |
77 | @PaginationValid | |
78 | @PaginationDefault( | |
79 | size = 20, | |
80 | sort = {"id"}, | |
81 | direction = Sort.Direction.DESC) | |
82 | @Valid | |
83 | Pagination pagination) { | |
84 |
1
1. filter : replaced return value with null for org/cardanofoundation/explorer/api/controller/EpochController::filter → KILLED |
return ResponseEntity.ok(epochService.getAllEpoch(pagination.toPageable())); |
85 | } | |
86 | ||
87 | @GetMapping("/current") | |
88 | @LogMessage | |
89 | @Operation( | |
90 | summary = "Get information of current epoch", | |
91 | tags = {"epoch"}) | |
92 | public ResponseEntity<EpochSummary> findCurrentEpoch() { | |
93 |
1
1. findCurrentEpoch : replaced return value with null for org/cardanofoundation/explorer/api/controller/EpochController::findCurrentEpoch → KILLED |
return ResponseEntity.ok(epochService.getCurrentEpochSummary()); |
94 | } | |
95 | } | |
Mutations | ||
49 |
1.1 |
|
67 |
1.1 |
|
84 |
1.1 |
|
93 |
1.1 |