1 | package org.cardanofoundation.explorer.api.controller; | |
2 | ||
3 | import java.util.List; | |
4 | ||
5 | import jakarta.validation.Valid; | |
6 | ||
7 | import lombok.RequiredArgsConstructor; | |
8 | ||
9 | import org.springframework.data.domain.Sort; | |
10 | import org.springframework.http.ResponseEntity; | |
11 | import org.springframework.validation.annotation.Validated; | |
12 | import org.springframework.web.bind.annotation.*; | |
13 | ||
14 | import io.swagger.v3.oas.annotations.Operation; | |
15 | import io.swagger.v3.oas.annotations.Parameter; | |
16 | import io.swagger.v3.oas.annotations.tags.Tag; | |
17 | import org.springdoc.core.annotations.ParameterObject; | |
18 | ||
19 | import org.cardanofoundation.explorer.api.common.enumeration.BlockPropagationChartType; | |
20 | import org.cardanofoundation.explorer.api.config.LogMessage; | |
21 | import org.cardanofoundation.explorer.api.model.response.*; | |
22 | import org.cardanofoundation.explorer.api.service.BlockService; | |
23 | import org.cardanofoundation.explorer.api.service.TxService; | |
24 | import org.cardanofoundation.explorer.common.validation.pagination.Pagination; | |
25 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault; | |
26 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid; | |
27 | ||
28 | @RestController | |
29 | @RequestMapping("/api/v1/blocks") | |
30 | @RequiredArgsConstructor | |
31 | @Validated | |
32 | @Tag(name = "block", description = "The block APIs") | |
33 | public class BlockController { | |
34 | ||
35 | private final BlockService blockService; | |
36 | private final TxService txService; | |
37 | ||
38 | @GetMapping("/{blockId}") | |
39 | @LogMessage | |
40 | @Operation( | |
41 | summary = "Get detail information of block", | |
42 | tags = {"block"}) | |
43 | public ResponseEntity<BlockResponse> getBlockDetailByBlockId( | |
44 | @PathVariable @Parameter(description = "The hash identifier of the block.") String blockId) { | |
45 |
1
1. getBlockDetailByBlockId : replaced return value with null for org/cardanofoundation/explorer/api/controller/BlockController::getBlockDetailByBlockId → KILLED |
return ResponseEntity.ok(blockService.getBlockDetailByBlockId(blockId)); |
46 | } | |
47 | ||
48 | @GetMapping | |
49 | @LogMessage | |
50 | @Operation( | |
51 | summary = "Get summary information of all block", | |
52 | tags = {"block"}) | |
53 | public ResponseEntity<BaseFilterResponse<BlockFilterResponse>> getAll( | |
54 | @ParameterObject | |
55 | @PaginationValid | |
56 | @PaginationDefault( | |
57 | size = 20, | |
58 | sort = {"id"}, | |
59 | direction = Sort.Direction.DESC) | |
60 | @Valid | |
61 | Pagination pagination) { | |
62 |
1
1. getAll : replaced return value with null for org/cardanofoundation/explorer/api/controller/BlockController::getAll → KILLED |
return ResponseEntity.ok(blockService.filterBlock(pagination.toPageable())); |
63 | } | |
64 | ||
65 | @GetMapping("/{blockId}/txs") | |
66 | @LogMessage | |
67 | @Operation( | |
68 | summary = "Get tx list of block", | |
69 | tags = {"block"}) | |
70 | public ResponseEntity<BaseFilterResponse<TxFilterResponse>> getTransactionsByBlock( | |
71 | @PathVariable @Parameter(description = "The hash identifier of the block.") String blockId, | |
72 | @ParameterObject | |
73 | @PaginationValid | |
74 | @PaginationDefault( | |
75 | size = 20, | |
76 | sort = {"blockId", "blockIndex"}, | |
77 | direction = Sort.Direction.DESC) | |
78 | @Valid | |
79 | Pagination pagination) { | |
80 |
1
1. getTransactionsByBlock : replaced return value with null for org/cardanofoundation/explorer/api/controller/BlockController::getTransactionsByBlock → KILLED |
return ResponseEntity.ok(txService.getTransactionsByBlock(blockId, pagination.toPageable())); |
81 | } | |
82 | ||
83 | @GetMapping("/block-propagation") | |
84 | @LogMessage | |
85 | @Operation( | |
86 | summary = "Get block propagation", | |
87 | tags = {"block"}) | |
88 | public ResponseEntity<List<BlockPropagationResponse>> getBlockPropagation( | |
89 | @Parameter(description = "The type of chart.") @RequestParam(required = false) | |
90 | BlockPropagationChartType type, | |
91 | @ParameterObject | |
92 | @PaginationValid | |
93 | @PaginationDefault( | |
94 | size = 6, | |
95 | sort = {"time"}, | |
96 | direction = Sort.Direction.DESC) | |
97 | @Valid | |
98 | Pagination pagination) { | |
99 |
1
1. getBlockPropagation : replaced return value with null for org/cardanofoundation/explorer/api/controller/BlockController::getBlockPropagation → NO_COVERAGE |
return ResponseEntity.ok(blockService.getBlockPropagation(type, pagination.toPageable())); |
100 | } | |
101 | } | |
Mutations | ||
45 |
1.1 |
|
62 |
1.1 |
|
80 |
1.1 |
|
99 |
1.1 |