Skip to content

Commit

Permalink
#121 | refactor: @Positive Annotations Have Been Added to id Vari…
Browse files Browse the repository at this point in the history
…able in `approve` and `reject` Endpoints
  • Loading branch information
agitrubard committed Oct 1, 2024
1 parent ab556d9 commit 873075c
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
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;
import org.gelecekbilimde.scienceplatform.auth.model.response.RoleApplicationResponse;
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;
Expand All @@ -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<List<RoleApplicationResponse>> findAll(@RequestBody @Valid List<RoleChangeRequestsFilter> filters,
Expand Down Expand Up @@ -56,15 +62,15 @@ SuccessResponse<Void> createModeratorApplication() {

@PatchMapping("/role-application/{id}/approve")
@PreAuthorize("hasAuthority('role:application:conclude')")
SuccessResponse<Void> approve(@PathVariable Long id) {
SuccessResponse<Void> approve(@PathVariable @Positive Long id) {

roleApplicationService.approve(id);
return SuccessResponse.success();
}

@PatchMapping("/role-application/{id}/reject")
@PreAuthorize("hasAuthority('role:application:conclude')")
SuccessResponse<Void> reject(@PathVariable Long id) {
SuccessResponse<Void> reject(@PathVariable @Positive Long id) {

roleApplicationService.reject(id);
return SuccessResponse.success();
Expand Down

0 comments on commit 873075c

Please sign in to comment.