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.data.domain.Sort.Direction; | |
9 | import org.springframework.http.ResponseEntity; | |
10 | import org.springframework.validation.annotation.Validated; | |
11 | import org.springframework.web.bind.annotation.GetMapping; | |
12 | import org.springframework.web.bind.annotation.PathVariable; | |
13 | import org.springframework.web.bind.annotation.RequestMapping; | |
14 | import org.springframework.web.bind.annotation.RequestParam; | |
15 | import org.springframework.web.bind.annotation.RestController; | |
16 | ||
17 | import io.swagger.v3.oas.annotations.Operation; | |
18 | import io.swagger.v3.oas.annotations.Parameter; | |
19 | import io.swagger.v3.oas.annotations.tags.Tag; | |
20 | import org.springdoc.core.annotations.ParameterObject; | |
21 | ||
22 | import org.cardanofoundation.explorer.api.config.LogMessage; | |
23 | import org.cardanofoundation.explorer.api.model.request.drep.DRepFilterRequest; | |
24 | import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse; | |
25 | import org.cardanofoundation.explorer.api.model.response.drep.DRepCertificateHistoryResponse; | |
26 | import org.cardanofoundation.explorer.api.model.response.drep.DRepDelegatorsResponse; | |
27 | import org.cardanofoundation.explorer.api.model.response.drep.DRepDetailsResponse; | |
28 | import org.cardanofoundation.explorer.api.model.response.drep.DRepFilterResponse; | |
29 | import org.cardanofoundation.explorer.api.model.response.drep.DRepOverviewResponse; | |
30 | import org.cardanofoundation.explorer.api.model.response.drep.DRepRangeValuesResponse; | |
31 | import org.cardanofoundation.explorer.api.model.response.drep.VotingProcedureChartResponse; | |
32 | import org.cardanofoundation.explorer.api.service.DRepService; | |
33 | import org.cardanofoundation.explorer.common.entity.enumeration.GovActionType; | |
34 | import org.cardanofoundation.explorer.common.entity.ledgersync.Tx_; | |
35 | import org.cardanofoundation.explorer.common.validation.pagination.Pagination; | |
36 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault; | |
37 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid; | |
38 | ||
39 | @RestController | |
40 | @RequestMapping("/api/v1/dreps") | |
41 | @RequiredArgsConstructor | |
42 | @Validated | |
43 | @Tag(name = "dRep", description = "The delegated representatives APIs") | |
44 | public class DRepController { | |
45 | ||
46 | private final DRepService dRepService; | |
47 | ||
48 | @GetMapping("/{drepHashOrDrepId}/certificates-history") | |
49 | @LogMessage | |
50 | @Operation( | |
51 | summary = "Get list of DRep certificate history", | |
52 | tags = {"dRep"}) | |
53 | public ResponseEntity<BaseFilterResponse<DRepCertificateHistoryResponse>> | |
54 | getTxDRepCertificatesHistory( | |
55 | @PathVariable @Parameter(description = "The DRep id or DRep hash") | |
56 | String drepHashOrDrepId, | |
57 | @ParameterObject | |
58 | @PaginationValid | |
59 | @PaginationDefault( | |
60 | size = 20, | |
61 | sort = {"createdAt"}, | |
62 | direction = Sort.Direction.DESC) | |
63 | Pagination pagination) { | |
64 |
1
1. getTxDRepCertificatesHistory : replaced return value with null for org/cardanofoundation/explorer/api/controller/DRepController::getTxDRepCertificatesHistory → KILLED |
return ResponseEntity.ok( |
65 | dRepService.getTxDRepCertificateHistory(drepHashOrDrepId, pagination.toPageable())); | |
66 | } | |
67 | ||
68 | @GetMapping("/{dRepHashOrId}/vote-procedure-chart") | |
69 | @LogMessage | |
70 | @Operation( | |
71 | summary = "Get chart of DRep vote on Governance Action", | |
72 | tags = {"dRep"}) | |
73 | public ResponseEntity<VotingProcedureChartResponse> getChartOfDRepVotesOnGovernanceAction( | |
74 | @PathVariable @Parameter(description = "The DRep hash or id") String dRepHashOrId, | |
75 | @RequestParam(value = "govActionType") | |
76 | @Parameter(description = "The type of Governance Action") | |
77 | GovActionType govActionType) { | |
78 |
1
1. getChartOfDRepVotesOnGovernanceAction : replaced return value with null for org/cardanofoundation/explorer/api/controller/DRepController::getChartOfDRepVotesOnGovernanceAction → KILLED |
return ResponseEntity.ok(dRepService.getVoteProcedureChart(dRepHashOrId, govActionType)); |
79 | } | |
80 | ||
81 | @GetMapping("/{dRepHashOrDRepId}/drep-details") | |
82 | @LogMessage | |
83 | @Operation( | |
84 | summary = "Get details of Delegated Representative (DRep)", | |
85 | tags = {"dRep"}) | |
86 | public ResponseEntity<DRepDetailsResponse> getDRepDetails( | |
87 | @Valid @PathVariable @Parameter(description = "The DRep id or DRep hash") | |
88 | String dRepHashOrDRepId) { | |
89 |
1
1. getDRepDetails : replaced return value with null for org/cardanofoundation/explorer/api/controller/DRepController::getDRepDetails → KILLED |
return ResponseEntity.ok(dRepService.getDRepDetails(dRepHashOrDRepId)); |
90 | } | |
91 | ||
92 | @GetMapping("/{dRepHashOrDRepId}/get-delegation") | |
93 | @LogMessage | |
94 | @Operation( | |
95 | summary = "Get stake that delegated to Delegated Representative (DRep)", | |
96 | tags = {"dRep"}) | |
97 | public ResponseEntity<BaseFilterResponse<DRepDelegatorsResponse>> getDRepDelegation( | |
98 | @Valid @PathVariable @Parameter(description = "dRepHashOrDRepId") String dRepHashOrDRepId, | |
99 | @ParameterObject | |
100 | @PaginationValid | |
101 | @PaginationDefault( | |
102 | sort = {Tx_.ID}, | |
103 | direction = Direction.DESC) | |
104 | Pagination pagination) { | |
105 |
1
1. getDRepDelegation : replaced return value with null for org/cardanofoundation/explorer/api/controller/DRepController::getDRepDelegation → KILLED |
return ResponseEntity.ok( |
106 | dRepService.getDRepDelegators(dRepHashOrDRepId, pagination.toPageable())); | |
107 | } | |
108 | ||
109 | @GetMapping("/overview") | |
110 | @LogMessage | |
111 | @Operation( | |
112 | summary = "Get overview of Delegated Representatives (DRep)", | |
113 | tags = {"dRep"}) | |
114 | public ResponseEntity<DRepOverviewResponse> getDRepOverview() { | |
115 |
1
1. getDRepOverview : replaced return value with null for org/cardanofoundation/explorer/api/controller/DRepController::getDRepOverview → KILLED |
return ResponseEntity.ok(dRepService.getDRepOverview()); |
116 | } | |
117 | ||
118 | @GetMapping("/filter") | |
119 | @LogMessage | |
120 | @Operation( | |
121 | summary = "Get list of DRep by filter", | |
122 | tags = {"dRep"}) | |
123 | public ResponseEntity<BaseFilterResponse<DRepFilterResponse>> getDRepsByFilter( | |
124 | @ParameterObject @Valid DRepFilterRequest dRepFilterRequest, | |
125 | @ParameterObject | |
126 | @PaginationValid | |
127 | @PaginationDefault( | |
128 | size = 20, | |
129 | sort = {"createdAt"}, | |
130 | direction = Sort.Direction.DESC) | |
131 | @Valid | |
132 | Pagination pagination) { | |
133 | ||
134 |
1
1. getDRepsByFilter : replaced return value with null for org/cardanofoundation/explorer/api/controller/DRepController::getDRepsByFilter → KILLED |
return ResponseEntity.ok( |
135 | dRepService.getDRepsByFilter(dRepFilterRequest, pagination.toPageable())); | |
136 | } | |
137 | ||
138 | @GetMapping("/range-values-for-filter") | |
139 | @LogMessage | |
140 | @Operation( | |
141 | summary = "Get range value to filter on DRep overview page", | |
142 | tags = {"dRep"}) | |
143 | public ResponseEntity<DRepRangeValuesResponse> getDRepRangeValues() { | |
144 |
1
1. getDRepRangeValues : replaced return value with null for org/cardanofoundation/explorer/api/controller/DRepController::getDRepRangeValues → NO_COVERAGE |
return ResponseEntity.ok(dRepService.getDRepRangeValues()); |
145 | } | |
146 | } | |
Mutations | ||
64 |
1.1 |
|
78 |
1.1 |
|
89 |
1.1 |
|
105 |
1.1 |
|
115 |
1.1 |
|
134 |
1.1 |
|
144 |
1.1 |