diff --git a/src/main/java/kr/tgwing/tech/project/domain/Project.java b/src/main/java/kr/tgwing/tech/project/domain/Project.java index 9e59d8f..9e16798 100644 --- a/src/main/java/kr/tgwing/tech/project/domain/Project.java +++ b/src/main/java/kr/tgwing/tech/project/domain/Project.java @@ -21,7 +21,8 @@ @DynamicInsert @NoArgsConstructor @Table(name= "project") -public class Project extends BaseEntity { +public class +Project extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="project_id") private Long id; diff --git a/src/main/java/kr/tgwing/tech/project/dto/ProjectBriefDTO.java b/src/main/java/kr/tgwing/tech/project/dto/ProjectBriefDTO.java index 5dd4f0a..90d00da 100644 --- a/src/main/java/kr/tgwing/tech/project/dto/ProjectBriefDTO.java +++ b/src/main/java/kr/tgwing/tech/project/dto/ProjectBriefDTO.java @@ -1,5 +1,6 @@ package kr.tgwing.tech.project.dto; +import kr.tgwing.tech.project.domain.Image; import kr.tgwing.tech.project.domain.Project; import lombok.AccessLevel; import lombok.Builder; @@ -7,6 +8,7 @@ import lombok.NoArgsConstructor; import java.time.LocalDate; +import java.util.Optional; @Data @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -33,13 +35,20 @@ public ProjectBriefDTO(Long id, String title, LocalDate start, LocalDate end, St } public static ProjectBriefDTO of(Project project) { + String imgUrl; + Optional first = project.getImageUrls().stream().findFirst(); + if (first.isEmpty()) { + imgUrl = null; + } else { + imgUrl = first.get().getImageUrl(); + } return ProjectBriefDTO.builder() .id(project.getId()) .title(project.getTitle()) .start(project.getStartDate()) .end(project.getEndDate()) .description(project.getDescription()) - .thumbnail(project.getImageUrls().stream().findFirst().get().getImageUrl()) + .thumbnail(imgUrl) .devStatus(project.getDevStatus()) .devType(project.getDevType()) .build(); diff --git a/src/main/java/kr/tgwing/tech/security/config/SecurityConfig.java b/src/main/java/kr/tgwing/tech/security/config/SecurityConfig.java index 2fecd6f..0bfad4b 100644 --- a/src/main/java/kr/tgwing/tech/security/config/SecurityConfig.java +++ b/src/main/java/kr/tgwing/tech/security/config/SecurityConfig.java @@ -101,7 +101,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti // .hasRole("ADMIN") .requestMatchers("/**") .permitAll() - .anyRequest().authenticated()) + .anyRequest().authenticated() + ) .addFilterBefore(new JwtFilter(jwtUtil), LoginFilter.class) .addFilterAt(new LoginFilter(authenticationManager(authenticationConfiguration), jwtUtil, tempUserRepository), UsernamePasswordAuthenticationFilter.class) diff --git a/src/main/java/kr/tgwing/tech/security/filter/LoginFilter.java b/src/main/java/kr/tgwing/tech/security/filter/LoginFilter.java index 6091795..3d7435e 100644 --- a/src/main/java/kr/tgwing/tech/security/filter/LoginFilter.java +++ b/src/main/java/kr/tgwing/tech/security/filter/LoginFilter.java @@ -55,7 +55,7 @@ protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authentication) throws IOException { - //UserDetailsS + //UserDetailsS CustomUserDetails customUserDetails = (CustomUserDetails) authentication.getPrincipal(); String username = customUserDetails.getUsername();