From 873075cd208ba9a0a2590639d5507c866f8e2c86 Mon Sep 17 00:00:00 2001 From: agitrubard Date: Tue, 1 Oct 2024 16:42:49 +0300 Subject: [PATCH] #121 | refactor: `@Positive` Annotations Have Been Added to `id` Variable in `approve` and `reject` Endpoints --- .../auth/controller/RoleApplicationController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gelecekbilimde/scienceplatform/auth/controller/RoleApplicationController.java b/src/main/java/org/gelecekbilimde/scienceplatform/auth/controller/RoleApplicationController.java index ab8579f1..256fe23a 100644 --- a/src/main/java/org/gelecekbilimde/scienceplatform/auth/controller/RoleApplicationController.java +++ b/src/main/java/org/gelecekbilimde/scienceplatform/auth/controller/RoleApplicationController.java @@ -1,6 +1,7 @@ package org.gelecekbilimde.scienceplatform.auth.controller; import jakarta.validation.Valid; +import jakarta.validation.constraints.Positive; import lombok.RequiredArgsConstructor; import org.gelecekbilimde.scienceplatform.auth.model.mapper.RoleApplicationDomainToRoleApplicationResponse; import org.gelecekbilimde.scienceplatform.auth.model.request.RoleChangeRequestsFilter; @@ -8,6 +9,7 @@ import org.gelecekbilimde.scienceplatform.auth.service.RoleApplicationService; import org.gelecekbilimde.scienceplatform.common.model.response.SuccessResponse; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -19,14 +21,18 @@ import java.util.List; +@Validated @RestController @RequestMapping("/api/v1") @RequiredArgsConstructor class RoleApplicationController { private final RoleApplicationService roleApplicationService; + + private final RoleApplicationDomainToRoleApplicationResponse roleApplicationDomainToRoleApplicationResponse = RoleApplicationDomainToRoleApplicationResponse.initialize(); + @PostMapping("/role-applications") @PreAuthorize("hasAuthority('role:application:list')") SuccessResponse> findAll(@RequestBody @Valid List filters, @@ -56,7 +62,7 @@ SuccessResponse createModeratorApplication() { @PatchMapping("/role-application/{id}/approve") @PreAuthorize("hasAuthority('role:application:conclude')") - SuccessResponse approve(@PathVariable Long id) { + SuccessResponse approve(@PathVariable @Positive Long id) { roleApplicationService.approve(id); return SuccessResponse.success(); @@ -64,7 +70,7 @@ SuccessResponse approve(@PathVariable Long id) { @PatchMapping("/role-application/{id}/reject") @PreAuthorize("hasAuthority('role:application:conclude')") - SuccessResponse reject(@PathVariable Long id) { + SuccessResponse reject(@PathVariable @Positive Long id) { roleApplicationService.reject(id); return SuccessResponse.success();