Skip to content

Commit

Permalink
#121 | refactor: Self Role Application Operations Have Been Separated…
Browse files Browse the repository at this point in the history
… with `RoleSelfApplicationController` and Permissions Have Been Renamed
  • Loading branch information
agitrubard committed Oct 3, 2024
1 parent 5780850 commit 7ff93d5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,6 @@ SuccessResponse<List<RoleApplicationsResponse>> findAll(@RequestBody @Valid List
return SuccessResponse.success(roleApplicationsResponses);
}

@PostMapping("/role-application/author")
@PreAuthorize("hasAnyAuthority('role:application:create:author')")
SuccessResponse<Void> createAuthorApplication() {

roleApplicationService.createAuthorApplication();
return SuccessResponse.success();
}

@PostMapping("/role-application/moderator")
@PreAuthorize("hasAnyAuthority('role:application:create:moderator')")
SuccessResponse<Void> createModeratorApplication() {

roleApplicationService.createModeratorApplication();
return SuccessResponse.success();
}

@PatchMapping("/role-application/{id}/approve")
@PreAuthorize("hasAnyAuthority('role:application:conclude')")
SuccessResponse<Void> approve(@PathVariable @UUID String id) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.gelecekbilimde.scienceplatform.auth.controller;

import lombok.RequiredArgsConstructor;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Validated
@RestController
@RequestMapping("/api/v1")
@RequiredArgsConstructor
class RoleSelfApplicationController {

private final RoleApplicationService roleApplicationService;


@PostMapping("/role-application/self/author")
@PreAuthorize("hasAnyAuthority('role:application:create:self:author')")
SuccessResponse<Void> createAuthorApplication() {

roleApplicationService.createAuthorApplication();
return SuccessResponse.success();
}

@PostMapping("/role-application/self/moderator")
@PreAuthorize("hasAnyAuthority('role:application:create:self:moderator')")
SuccessResponse<Void> createModeratorApplication() {

roleApplicationService.createModeratorApplication();
return SuccessResponse.success();
}

}
8 changes: 4 additions & 4 deletions src/main/resources/db/migration/V2__dml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ insert into gb_permission (id, description, name, is_hidden, created_by, created
values ('31366d9d-5282-4fe2-9d45-4551e114bc7d', 'Rol Başvurusunu Sonuçlandırır',
'role:application:conclude', false, 'gelecekbilimde', current_timestamp);
insert into gb_permission (id, description, name, is_hidden, created_by, created_at)
values ('edfb8180-92ef-4a9e-8913-1bdfa606d297', 'Yazar Olmak İçin Başvuru Oluşturur',
'role:application:create:author', false, 'gelecekbilimde', current_timestamp);
values ('edfb8180-92ef-4a9e-8913-1bdfa606d297', 'Yazar Olmak İçin Kendi Adına Başvuru Oluşturur',
'role:application:create:self:author', false, 'gelecekbilimde', current_timestamp);
insert into gb_permission (id, description, name, is_hidden, created_by, created_at)
values ('171ca9a7-311d-40b6-b538-024b5870471a', 'Moderatör Olmak İçin Başvuru Oluşturur',
'role:application:create:moderator', false, 'gelecekbilimde', current_timestamp);
values ('171ca9a7-311d-40b6-b538-024b5870471a', 'Moderatör Olmak İçin Kendi Adına Başvuru Oluşturur',
'role:application:create:self:moderator', false, 'gelecekbilimde', current_timestamp);


insert into gb_role_permission (role_id, permission_id)
Expand Down

0 comments on commit 7ff93d5

Please sign in to comment.