-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from Kernel360/feature/project-authorization-…
…refactor-#191 Feat : 프로젝트 접근 권한 수정 #191
- Loading branch information
Showing
23 changed files
with
265 additions
and
152 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
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
4 changes: 4 additions & 0 deletions
4
...src/main/java/com/seveneleven/util/security/service/ProjectAuthorizationCheckService.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,4 @@ | ||
package com.seveneleven.util.security.service; | ||
|
||
public interface ProjectAuthorizationCheckService { | ||
} |
9 changes: 9 additions & 0 deletions
9
...main/java/com/seveneleven/util/security/service/ProjectAuthorizationCheckServiceImpl.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,9 @@ | ||
package com.seveneleven.util.security.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ProjectAuthorizationCheckServiceImpl { | ||
|
||
// TODO - 프로젝트 권한 체크 서비스 - For @PreAuthorization - SpEL 사용 | ||
} |
65 changes: 65 additions & 0 deletions
65
Main/src/main/java/com/seveneleven/project/controller/ProjectAuthorizationController.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,65 @@ | ||
package com.seveneleven.project.controller; | ||
|
||
import com.seveneleven.project.dto.GetMemberAuthorization; | ||
import com.seveneleven.project.dto.GetProjectAuthorization; | ||
import com.seveneleven.project.dto.PostProjectAuthorization; | ||
import com.seveneleven.response.APIResponse; | ||
import com.seveneleven.response.SuccessCode; | ||
import com.seveneleven.util.security.dto.CustomUserDetails; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/projects") | ||
public class ProjectAuthorizationController { | ||
|
||
private final ProjectAuthorizationFacade projectAuthorizationFacade; | ||
|
||
/** | ||
* 함수명 : postProjectAuthorization | ||
* 프로젝트 접근 권한을 편집하는 함수 | ||
*/ | ||
@PostMapping("/{projectId}/authorizations") | ||
public ResponseEntity<APIResponse<PostProjectAuthorization.Response>> postProjectAuthorization( | ||
@PathVariable Long projectId, | ||
@RequestBody PostProjectAuthorization.Request requestDto | ||
) { | ||
// TODO - ProjectId로 변경 | ||
PostProjectAuthorization.Response responseDto = projectAuthorizationFacade.postProjectAuthorization(requestDto, projectId); | ||
|
||
if(responseDto.getFailList().isEmpty()) { | ||
return ResponseEntity.status(SuccessCode.CREATED.getStatusCode()) | ||
.body(APIResponse.success(SuccessCode.OK, responseDto)); | ||
} | ||
return ResponseEntity.status(SuccessCode.MULTISTATUS.getStatusCode()) | ||
.body(APIResponse.success(SuccessCode.MULTISTATUS, responseDto)); | ||
} | ||
|
||
/** | ||
* 함수명 : getProjectAuthorization | ||
* 해당 프로젝트의 접근 권한자 목록을 반환하는 함수 | ||
*/ | ||
@GetMapping("/{projectId}/authorizations") | ||
public ResponseEntity<APIResponse<GetProjectAuthorization.Response>> getProjectAuthorization( | ||
@PathVariable Long projectId | ||
) { | ||
return ResponseEntity.status(SuccessCode.OK.getStatusCode()) | ||
.body(APIResponse.success(SuccessCode.OK, projectAuthorizationFacade.getProjectAuthorization(projectId))); | ||
} | ||
|
||
/** | ||
* 함수명 : getMemberAuthorization | ||
* 해당 멤버가 접근 권한을 확인하는 함수 | ||
*/ | ||
@GetMapping("/{projectId}/authorizations/members") | ||
public ResponseEntity<APIResponse<GetMemberAuthorization.Response>> getMemberAuthorization( | ||
@PathVariable Long projectId, | ||
@AuthenticationPrincipal CustomUserDetails customUserDetails | ||
) { | ||
// TODO - 구현 | ||
return null; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
Main/src/main/java/com/seveneleven/project/controller/ProjectAuthorizationDocs.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,62 @@ | ||
package com.seveneleven.project.controller; | ||
|
||
import com.seveneleven.project.dto.GetProjectAuthorization; | ||
import com.seveneleven.project.dto.PostProjectAuthorization; | ||
import com.seveneleven.response.APIResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RequestMapping("/api/projects") | ||
public interface ProjectAuthorizationDocs { | ||
|
||
@PostMapping("/steps/{stepId}/authorizations") | ||
@Operation( | ||
summary = "프로젝트 권한 생성", | ||
description = "특정 단계의 프로젝트 권한을 생성합니다.", | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "201", | ||
description = "프로젝트 권한이 성공적으로 생성되었습니다.", | ||
content = @Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = PostProjectAuthorization.Response.class) | ||
) | ||
), | ||
@ApiResponse( | ||
responseCode = "207", | ||
description = "일부 요청이 실패하였습니다.", | ||
content = @Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = PostProjectAuthorization.Response.class) | ||
) | ||
) | ||
} | ||
) | ||
ResponseEntity<APIResponse<PostProjectAuthorization.Response>> postProjectAuthorization( | ||
@PathVariable Long stepId, | ||
@RequestBody PostProjectAuthorization.Request requestDto | ||
); | ||
|
||
@GetMapping("/steps/{stepId}/authorizations") | ||
@Operation( | ||
summary = "프로젝트 권한 조회", | ||
description = "특정 단계의 프로젝트 권한을 조회합니다.", | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "프로젝트 권한이 성공적으로 조회되었습니다.", | ||
content = @Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = GetProjectAuthorization.Response.class) | ||
) | ||
) | ||
} | ||
) | ||
ResponseEntity<APIResponse<GetProjectAuthorization.Response>> getProjectAuthorization( | ||
@PathVariable Long stepId | ||
); | ||
} |
40 changes: 40 additions & 0 deletions
40
Main/src/main/java/com/seveneleven/project/controller/ProjectAuthorizationFacade.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,40 @@ | ||
package com.seveneleven.project.controller; | ||
|
||
import com.seveneleven.entity.project.Project; | ||
import com.seveneleven.project.dto.GetProjectAuthorization; | ||
import com.seveneleven.project.dto.PostProjectAuthorization; | ||
import com.seveneleven.project.service.ProjectAuthorizationService; | ||
import com.seveneleven.project.service.dashboard.ProjectReader; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class ProjectAuthorizationFacade { | ||
|
||
private final ProjectReader projectReader; | ||
private final ProjectAuthorizationService projectAuthorizationService; | ||
|
||
/** | ||
* 함수명 : postProjectAuthorization | ||
* 프로젝트 접근 권한을 편힙하는 함수 | ||
*/ | ||
public PostProjectAuthorization.Response postProjectAuthorization( | ||
PostProjectAuthorization.Request requestDto, | ||
Long projectId | ||
) { | ||
Project project = projectReader.read(projectId); | ||
return projectAuthorizationService.createProjectAuthorization(project, requestDto); | ||
} | ||
|
||
/** | ||
* 함수명 : getProjectAuthorization | ||
* 해당 단계에 접근할 수 있는 인원을 반환하는 함수 | ||
*/ | ||
public GetProjectAuthorization.Response getProjectAuthorization(Long projectId) { | ||
Project project = projectReader.read(projectId); | ||
return projectAuthorizationService.getProjectAuthorization(project); | ||
} | ||
} |
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.