Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#81 워크스페이스 조회 API 버그 수정 #82

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.requestMatchers(new AntPathRequestMatcher("/api/bookmark/**"),
new AntPathRequestMatcher("/api/category/**"),
new AntPathRequestMatcher("/api/tag/**"),
new AntPathRequestMatcher("/api/auth/**")).authenticated()
new AntPathRequestMatcher("/api/auth/**"),
new AntPathRequestMatcher("/api/workspace/**")).authenticated()
// .hasRole(Role.ROLE_USER.getRoleName())
.anyRequest().permitAll()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.kakao.linknamu.user.entity.User;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
Expand All @@ -14,7 +15,7 @@
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@ToString(callSuper = true, exclude = {"user", "categoryList"})
@ToString(callSuper = true, exclude = {"user", "categorySet"})
@DynamicUpdate
@Table(
name = "workspace_tb",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public interface WorkspaceJPARepository extends JpaRepository<Workspace, Long> {
@Query(value = "select w from Workspace w where w.user.userId=:userId and w.workspaceName =:workspaceName")
Optional<Workspace> findByUserIdAndWorkspaceName(@Param("userId") Long userId, @Param("workspaceName") String workspaceName);

@Query(value = "select distinct w from Workspace w " +
"join fetch w.categorySet c " +
@Query(value = "select w from Workspace w " +
"where w.user.userId =:userId")
List<Workspace> findAllByUserIdFetchJoinCategory(@Param("userId") Long userId);
List<Workspace> findAllByUserId(@Param("userId") Long userId);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.kakao.linknamu.workspace.service;

import com.kakao.linknamu.category.entity.Category;
import com.kakao.linknamu.category.service.CategoryService;
import com.kakao.linknamu.user.entity.User;
import com.kakao.linknamu.workspace.dto.WorkspaceGetResponseDto;
import com.kakao.linknamu.workspace.entity.Workspace;
Expand All @@ -10,12 +8,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Comparator;
import java.util.List;
import java.util.TreeMap;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.groupingBy;

@Service
@RequiredArgsConstructor
Expand All @@ -24,7 +17,8 @@ public class WorkspaceReadService {
private final WorkspaceJPARepository workspaceJPARepository;

public List<WorkspaceGetResponseDto> getWorkspaceList(User user) {
List<Workspace> workspaceList = workspaceJPARepository.findAllByUserIdFetchJoinCategory(user.getUserId());
List<Workspace> workspaceList = workspaceJPARepository.findAllByUserId(user.getUserId());

if (workspaceList.isEmpty()) return List.of();

return workspaceList.stream()
Expand Down
5 changes: 2 additions & 3 deletions linknamu/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spring:
properties:
hibernate:
format_sql: true # Hibernate이 SQL 쿼리를 로그에 출력할 때 이를 보기 쉽게 포맷팅
default_batch_fetch_size: 100 # Hibernate의 기본 배치 페치 크기 설정
default_batch_fetch_size: 100 # Hibernate의 기본 배치 페치 크기 설정

application:
name: LinkNamuApplication # 애플리케이션의 이름 설정
Expand All @@ -34,8 +34,6 @@ spring:
host: localhost # Redis 데이터베이스에 연결할 호스트 주소




access-jwt-secret-key: KakaoTechCampusLinkNamu
refresh-jwt-secret-key: KakaoTechCampusLinkNamu1234

Expand All @@ -44,6 +42,7 @@ logging:
org.springframework: INFO # Spring Framework 패키지의 로깅 레벨을 INFO로 설정
com.example: DEBUG # com.example 패키지의 로깅 레벨을 DEBUG로 설정


oauth2:
google:
client_id: ${google-client-id}
Expand Down
2 changes: 1 addition & 1 deletion linknamu/src/main/resources/application-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spring:
# format_sql은 Hibernate이 SQL 쿼리를 로그에 출력할 때 이를 보기 쉽게 포맷팅할지 여부를 의미.
format_sql: true
# Hibernate의 기본 배치 페치 크기를 지정하는 설정입니다. 배치 페치 크기는 데이터베이스에서 여러 엔티티를 한 번에 가져올 때 사용되는 일괄 처리 크기를 나타냅니다.
default_batch_fetch_size: 100
default_batch_fetch_size: 100

# Open-in-view 설정 부분
open-in-view: false
Expand Down