Skip to content

Commit

Permalink
chore: 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
clean2001 committed Jul 18, 2024
2 parents 30ae561 + 602490f commit cb3bd24
Show file tree
Hide file tree
Showing 22 changed files with 335 additions and 64 deletions.
3 changes: 3 additions & 0 deletions layer-api/src/main/java/org/layer/LayerApplication.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.layer;


import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.servers.Server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@OpenAPIDefinition(servers = {@Server(url = "https://api.layerapp.io", description = "운영서버")})
@SpringBootApplication
@EnableJpaAuditing
public class LayerApplication {
Expand Down
21 changes: 18 additions & 3 deletions layer-api/src/main/java/org/layer/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.method.HandlerMethod;

import java.util.Arrays;
import java.util.Collections;

@RequiredArgsConstructor
Expand Down Expand Up @@ -57,11 +59,24 @@ private void setHttp(HttpSecurity http) throws Exception {
.requestMatchers(new AntPathRequestMatcher("/h2-console/**")).permitAll()
.anyRequest().authenticated()
)
.headers(headers -> headers
.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)
);
.headers(headers -> headers
.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)
);
}


// @Bean
// public CorsConfigurationSource corsConfigurationSource() {
// CorsConfiguration configuration = new CorsConfiguration();
// configuration.setAllowedOrigins(Collections.singletonList("*"));
// configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
// configuration.setAllowedHeaders(Arrays.asList("*"));
// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
// source.registerCorsConfiguration("/**", configuration);
// return source;
// }


// swagger
private void permitSwaggerUri(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(authorizeHttpRequests -> authorizeHttpRequests
Expand Down
9 changes: 5 additions & 4 deletions layer-api/src/main/java/org/layer/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
public class WebConfig implements WebMvcConfigurer {

@Value("${webmvc.cors.allowedOrigins}")
private String allowedOrigins;
Expand All @@ -22,18 +22,19 @@ public class WebConfig implements WebMvcConfigurer {


@Bean
public WebMvcConfigurer corsConfigurer(){
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins(allowedOrigins.split(","))
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.allowCredentials(true);
.allowedHeaders("*");
// .allowCredentials(true);
}
};
}

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(memberIdResolver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import org.layer.domain.actionItem.dto.*;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Tag(name = "액션아이템 API")
public interface ActionItemApi {
@Operation(summary = "액션 아이템 생성", method = "POST", description = """
Expand Down Expand Up @@ -46,7 +49,8 @@ ResponseEntity<CreateActionItemResponse> createActionItem(@MemberId Long memberI
)
}
)
ResponseEntity<CreateActionItemResponse> memberActionItem(@MemberId Long memberId);
ResponseEntity<List<MemberActionItemResponse>> memberActionItem(@MemberId Long currentMemberId,
Long memberId);

@Operation(summary = "팀의 액션 아이템 조회", method = "GET", description = """
팀 아이디로 팀의 모든 액션아이템을 조회합니다.
Expand All @@ -56,14 +60,14 @@ ResponseEntity<CreateActionItemResponse> createActionItem(@MemberId Long memberI
content = {
@Content(
mediaType = "application/json",
schema = @Schema(implementation = TeamActionItemResponse.class)
schema = @Schema(implementation = SpaceActionItemElementResponse.class)
)
}
)
}
)
ResponseEntity<CreateActionItemResponse> teamActionItem(@MemberId Long memberId,
@Validated @RequestBody TeamActionItemRequest teamActionItemRequest);
ResponseEntity<SpaceActionItemResponse> teamActionItem(@MemberId Long memberId,
@PathVariable Long spaceId);

@Operation(summary = "액션 아이템 삭제", method = "DELETE", description = """
액션 아이템을 삭제합니다.
Expand All @@ -72,6 +76,5 @@ ResponseEntity<CreateActionItemResponse> teamActionItem(@MemberId Long memberId,
@ApiResponse(responseCode = "200")
}
)
ResponseEntity<CreateActionItemResponse> deleteActionItem(@MemberId Long memberId,
@Validated @RequestBody DeleteActionItemRequest deleteActionItemRequest);
}
ResponseEntity<DeleteActionItemResponse> deleteActionItem(@MemberId Long memberId, @PathVariable("actionItemId") Long actionItemId);
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package org.layer.domain.actionItem.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.layer.common.annotation.MemberId;
import org.layer.domain.actionItem.api.ActionItemApi;
import org.layer.domain.actionItem.dto.CreateActionItemRequest;
import org.layer.domain.actionItem.dto.CreateActionItemResponse;
import org.layer.domain.actionItem.dto.DeleteActionItemRequest;
import org.layer.domain.actionItem.dto.TeamActionItemRequest;
import org.layer.domain.actionItem.dto.*;
import org.layer.domain.actionItem.service.ActionItemService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RequestMapping("/api/action-item")
@RestController
Expand All @@ -35,21 +33,29 @@ public ResponseEntity<CreateActionItemResponse> createActionItem(@MemberId Long
}

@Override
@GetMapping("/member/{memberId}")
@PreAuthorize("isAuthenticated()")
public ResponseEntity<CreateActionItemResponse> memberActionItem(@MemberId Long memberId) {
public ResponseEntity<List<MemberActionItemResponse>> memberActionItem(@MemberId Long currentMemberId, @PathVariable("memberId") Long memberId) {
List<MemberActionItemResponse> memberActionItemList = actionItemService.getMemberActionItemList(currentMemberId, memberId);

return null;
return new ResponseEntity<>(memberActionItemList, HttpStatus.OK);
}

@Override
@GetMapping("/space/{spaceId}")
@PreAuthorize("isAuthenticated()")
public ResponseEntity<CreateActionItemResponse> teamActionItem(@MemberId Long memberId, TeamActionItemRequest teamActionItemRequest) {
return null;
public ResponseEntity<SpaceActionItemResponse> teamActionItem(@MemberId Long memberId, @PathVariable("spaceId") Long spaceId) {
SpaceActionItemResponse teamActionItem = actionItemService.getSpaceActionItemList(memberId, spaceId);

return new ResponseEntity<>(teamActionItem, HttpStatus.OK);
}

@Override
@DeleteMapping("/{actionItemId}")
@PreAuthorize("isAuthenticated()")
public ResponseEntity<CreateActionItemResponse> deleteActionItem(@MemberId Long memberId, DeleteActionItemRequest deleteActionItemRequest) {
return null;
public ResponseEntity<DeleteActionItemResponse> deleteActionItem(@MemberId Long memberId, @PathVariable("actionItemId") Long actionItemId) {
DeleteActionItemResponse deleteActionItemResponse = actionItemService.deleteActionItem(memberId, actionItemId);

return new ResponseEntity<>(deleteActionItemResponse, HttpStatus.OK);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.layer.domain.actionItem.dto;

import io.swagger.v3.oas.annotations.media.Schema;

public record DeleteActionItemResponse(@Schema(description = "삭제된 액션 아이템 아이디") Long actionItemId) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import org.layer.domain.actionItem.entity.ActionItem;

@Builder
@Schema(description = "특정 회원이 작성한 액션 아이템")
Expand All @@ -27,4 +28,16 @@ public record MemberActionItemResponse (@NotNull
@NotNull
@Schema(description = "팀 스페이스의 액션 아이템인지, 개인 스페이스의 액션 아이템인지")
Boolean isTeam){

public static MemberActionItemResponse toResponse(ActionItem actionItem, String spaceName, String retrospectName, boolean isTeam) {
return MemberActionItemResponse.builder()
.actionItemId(actionItem.getId())
.actionItemContent(actionItem.getContent())
.spaceId(actionItem.getSpaceId())
.spaceName(spaceName)
.retrospectId(actionItem.getRetrospectId())
.retrospectName(retrospectName)
.isTeam(isTeam)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import org.layer.domain.actionItem.entity.ActionItem;

public record TeamActionItemRequest(
@Builder
public record SpaceActionItemElementResponse(
@NotNull
@Schema(description = "액션 아이템 ID")
Long actionItemId,
@NotNull
@Schema(description = "액션 아이템과 내용")
String actionItemContent,
@NotNull
@Schema(description = "액션 아이템이 속한 스페이스 ID")
Long spaceId,
@NotNull
@Schema(description = "액션 아이템이 속한 스페이스 이름")
String spaceName,
@NotNull
@Schema(description = "액션 아이템과 매핑되는 회고 ID")
Long retrospectId,
@NotNull
@Schema(description = "액션 아이템과 매핑되는 회고 이름")
String retrospectName) {
}

public static SpaceActionItemElementResponse toResponse(ActionItem actionItem, String retrospectName) {
return SpaceActionItemElementResponse.builder()
.actionItemId(actionItem.getId())
.actionItemContent(actionItem.getContent())
.retrospectId(actionItem.getRetrospectId())
.retrospectName(retrospectName)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.layer.domain.actionItem.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Builder;

import java.util.List;

@Builder
public record SpaceActionItemResponse(@NotNull
@Schema(description = "액션 아이템이 속한 스페이스 ID")
Long spaceId,
@NotNull
@Schema(description = "액션 아이템이 속한 스페이스 이름")
String spaceName,
@NotNull
@Schema(description = "스페이스의 액션아이템 리스트")
List<SpaceActionItemElementResponse> teamActionItemList
) {
}

This file was deleted.

Loading

0 comments on commit cb3bd24

Please sign in to comment.