Skip to content

Commit

Permalink
feat: 본인의 워크스페이스 조회 기능
Browse files Browse the repository at this point in the history
  • Loading branch information
kimday0326 committed May 29, 2024
1 parent 673cf7e commit d9ac21b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public FilterRegistrationBean<JwtAuthenticationFilter> filterRegistration(JwtAut

private void configureSecurityDefaults(HttpSecurity http) throws Exception {
http
.cors(AbstractHttpConfigurer::disable)
.csrf(AbstractHttpConfigurer::disable)
.anonymous(AbstractHttpConfigurer::disable)
.formLogin(AbstractHttpConfigurer::disable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.khu.gitbox.domain.workspace.presentation.dto.MemberInfo;
import com.khu.gitbox.domain.workspace.presentation.dto.OwnerInfo;
import com.khu.gitbox.domain.workspace.presentation.dto.WorkspaceDetail;
import com.khu.gitbox.domain.workspace.presentation.dto.WorkspaceSummary;

import lombok.RequiredArgsConstructor;

Expand Down Expand Up @@ -96,6 +97,15 @@ public void deleteMembers(Long workspaceId, Long requestOwnerId, List<String> me
});
}

// 내 워크스페이스 목록
public List<WorkspaceSummary> getWorkspaces(Long memberId) {
return workspaceMemberRepository.findByMemberId(memberId).stream()
.map((workspaceMember) -> {
Workspace workspace = findWorkspaceById(workspaceMember.getWorkspaceId());
return new WorkspaceSummary(workspace.getId(), workspace.getName());
}).toList();
}

// 워크스페이스 정보
public WorkspaceDetail getWorkspaceDetail(Long workspaceId, Long memberId) {
// 워크스페이스 정보 가져오기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public interface WorkspaceMemberRepository extends JpaRepository<WorkspaceMember
void deleteByWorkspaceId(Long workspaceId);

void deleteByWorkspaceIdAndMemberId(Long workspaceId, Long memberId);

List<WorkspaceMember> findByMemberId(Long memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.khu.gitbox.domain.workspace.presentation.dto.CreateWorkspace;
import com.khu.gitbox.domain.workspace.presentation.dto.DeleteMembers;
import com.khu.gitbox.domain.workspace.presentation.dto.WorkspaceDetail;
import com.khu.gitbox.domain.workspace.presentation.dto.WorkspaceSummary;
import com.khu.gitbox.util.SecurityContextUtil;

import jakarta.validation.Valid;
Expand All @@ -42,6 +43,13 @@ public ApiResponse<Long> createWorkspace(@Valid @RequestBody CreateWorkspace wor
return ApiResponse.created(workspaceId);
}

@GetMapping
public ApiResponse<List<WorkspaceSummary>> getMyWorkspace() {
Long memberId = SecurityContextUtil.getCurrentMemberId();
List<WorkspaceSummary> response = workspaceService.getWorkspaces(memberId);
return ApiResponse.ok(response);
}

//워크스페이스 정보 가져오기
@GetMapping("/{workspaceId}")
public ApiResponse<WorkspaceDetail> getWorkspace(@PathVariable Long workspaceId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.khu.gitbox.domain.workspace.presentation.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class WorkspaceSummary {
private Long workspaceId;
private String workspaceName;
}

0 comments on commit d9ac21b

Please sign in to comment.