Skip to content

Commit

Permalink
refactor: 가능 시간 reqeust dto list형식으로 변환
Browse files Browse the repository at this point in the history
  • Loading branch information
oxdjww committed Sep 24, 2024
1 parent c75c862 commit 55e52bd
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.soongsil.CoffeeChat.controller;

import static com.soongsil.CoffeeChat.enums.RequestUri.*;
import static org.springframework.http.HttpStatus.*;

import java.net.URI;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
Expand Down Expand Up @@ -42,13 +42,17 @@ private String getUserNameByAuthentication(Authentication authentication) throws
@PostMapping()
@Operation(summary = "멘토가 직접 커피챗 가능시간 추가하기")
@ApiResponse(responseCode = "201", description = "DTO형식으로 정보 반환")
public ResponseEntity<ApiResponseGenerator<PossibleDateCreateGetResponseDto>> addPossibleDate(
public ResponseEntity<ApiResponseGenerator<List<PossibleDateCreateGetResponseDto>>> addPossibleDate(
Authentication authentication,
@RequestBody PossibleDateCreateRequestDto dto) throws Exception {
@RequestBody List<PossibleDateCreateRequestDto> dtos) throws Exception {
String username = getUserNameByAuthentication(authentication);

List<PossibleDateCreateGetResponseDto> responseDtos = dtos.stream()
.map(dto -> possibleDateService.createPossibleDate(dto, username))
.collect(Collectors.toList());

return ResponseEntity.created(URI.create(POSSIBLEDATE_URI)).body(
ApiResponseGenerator.onSuccessCREATED(
possibleDateService.createPossibleDate(dto, getUserNameByAuthentication(authentication))
)
ApiResponseGenerator.onSuccessCREATED(responseDtos)
);
}

Expand Down

0 comments on commit 55e52bd

Please sign in to comment.