-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FSADT1-1279): Set submission limits for users (#1140)
- Loading branch information
1 parent
7f9d0b5
commit 3e8d20f
Showing
28 changed files
with
379 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
backend/src/main/java/ca/bc/gov/app/controller/client/ClientSubmissionLimitController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package ca.bc.gov.app.controller.client; | ||
|
||
import ca.bc.gov.app.exception.ValidationException; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import ca.bc.gov.app.validator.SubmissionValidatorService; | ||
import io.micrometer.observation.annotation.Observed; | ||
import lombok.RequiredArgsConstructor; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RestController | ||
@RequestMapping(value = "/api/submission-limit", produces = MediaType.APPLICATION_JSON_VALUE) | ||
@RequiredArgsConstructor | ||
@Observed | ||
public class ClientSubmissionLimitController { | ||
|
||
private final SubmissionValidatorService submissionValidatorService; | ||
|
||
/** | ||
* Validates the submission limit for the authenticated user. | ||
* <p> | ||
* This endpoint checks whether the authenticated user has exceeded their allowed number of submissions | ||
* within a specified time frame. The time frame and submission limits are configurable parameters. | ||
* | ||
* @param principal the authentication token containing the details of the currently authenticated user. | ||
* This token is used to extract the user ID and determine the submission limits applicable to them. | ||
* @return a {@link Mono<Void>} that completes when the validation process is finished. If the user has | ||
* exceeded their submission limit, an error will be emitted; otherwise, the Mono will complete | ||
* successfully. | ||
* | ||
* @throws ValidationException if the user exceeds the maximum number of submissions allowed within | ||
* the specified time frame. | ||
*/ | ||
@GetMapping | ||
public Mono<Void> validateSubmissionLimit( | ||
JwtAuthenticationToken principal | ||
) { | ||
return submissionValidatorService.validateSubmissionLimit(principal); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/ca/bc/gov/app/repository/client/SubmissionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
package ca.bc.gov.app.repository.client; | ||
|
||
import ca.bc.gov.app.entity.client.SubmissionEntity; | ||
import reactor.core.publisher.Mono; | ||
import java.time.LocalDateTime; | ||
import org.springframework.data.repository.reactive.ReactiveCrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface SubmissionRepository extends ReactiveCrudRepository<SubmissionEntity, Integer> { | ||
|
||
Mono<Long> countBySubmissionDateBetweenAndCreatedByIgnoreCase( | ||
LocalDateTime startTime, | ||
LocalDateTime endTime, | ||
String createdBy); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
backend/src/main/java/ca/bc/gov/app/service/client/matches/LocationStepMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.