-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix : ManagerAuthInterceptor 디코딩 수정 * feat: 인터셉터에 검수중 장소 조회 path 등록 * feat: 검수할 장소 등록 기능 추가 * feat: 검수할 장소 등록 API 구현 * feat: 검수할 장소 목록 조회 기능 구현 * feat: 검수할 장소 목록 조회 API 구현 * fix: 서비스 객체 빈 등록 및 인터셉터 추가 * test: TemporaryPlaceBuilder 및 TemporaryPlaceFixture 작성 * test: ManagerAuthInterceptorTest 디코딩 문제 수정 * feat: TemporaryPlace예외 처리 추가 및 적용 * test: 검수할 장소 등록 테스트 추가 * test: 필요없는 테스트 삭제 * test: 20미터에 이미 등록된 목적지가 있다면 예외응답 테스트 * refactor: 필요없는 메서드 삭제 * refactor: PlaceCheckService 패키지 변경 및 예외 수정 * test: 검수할 장소 목록 조회 기능 테스트 * refactor: 콘솔 로깅 디버그 레벨로 변경 * refactor: TemporaryPlace관련 조회 쿼리 n+1문제 리팩터링 * refactor: TemporaryPlaceResponse에 플레이어 정보 추가 * chore: 개행 제거 * test: TemporaryPlaceControllerTest 수정 * refactor: 서비스 메서드명 변경 * refactor: TemporaryPlaceResponse 필드명 변경 * refactor: 검수할 장소 조회 오래된 순으로 정렬 순서 변경 --------- Co-authored-by: dooboocookie <[email protected]>
- Loading branch information
Showing
14 changed files
with
305 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 46 additions & 1 deletion
47
backend/src/main/java/com/now/naaga/temporaryplace/application/TemporaryPlaceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,65 @@ | ||
package com.now.naaga.temporaryplace.application; | ||
|
||
import com.now.naaga.common.infrastructure.FileManager; | ||
import com.now.naaga.place.domain.Position; | ||
import com.now.naaga.player.application.PlayerService; | ||
import com.now.naaga.player.domain.Player; | ||
import com.now.naaga.temporaryplace.application.dto.CreateTemporaryPlaceCommand; | ||
import com.now.naaga.temporaryplace.domain.TemporaryPlace; | ||
import com.now.naaga.temporaryplace.repository.TemporaryPlaceRepository; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.io.File; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
@Transactional | ||
@Service | ||
public class TemporaryPlaceService { | ||
|
||
private final TemporaryPlaceRepository temporaryPlaceRepository; | ||
|
||
public TemporaryPlaceService(final TemporaryPlaceRepository temporaryPlaceRepository) { | ||
private final PlayerService playerService; | ||
|
||
private final FileManager<MultipartFile> fileManager; | ||
|
||
public TemporaryPlaceService(final TemporaryPlaceRepository temporaryPlaceRepository, | ||
final PlayerService playerService, | ||
final FileManager<MultipartFile> fileManager) { | ||
this.temporaryPlaceRepository = temporaryPlaceRepository; | ||
this.playerService = playerService; | ||
this.fileManager = fileManager; | ||
} | ||
|
||
public TemporaryPlace createTemporaryPlace(final CreateTemporaryPlaceCommand createTemporaryPlaceCommand) { | ||
final Position position = createTemporaryPlaceCommand.position(); | ||
final File uploadPath = fileManager.save(createTemporaryPlaceCommand.imageFile()); | ||
try { | ||
final Long playerId = createTemporaryPlaceCommand.playerId(); | ||
final Player registeredPlayer = playerService.findPlayerById(playerId); | ||
final TemporaryPlace temporaryPlace = new TemporaryPlace( | ||
createTemporaryPlaceCommand.name(), | ||
createTemporaryPlaceCommand.description(), | ||
position, | ||
fileManager.convertToUrlPath(uploadPath), | ||
registeredPlayer); | ||
return temporaryPlaceRepository.save(temporaryPlace); | ||
} catch (final RuntimeException exception) { | ||
uploadPath.delete(); | ||
throw exception; | ||
} | ||
} | ||
|
||
public void deleteById(final Long id) { | ||
temporaryPlaceRepository.deleteById(id); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<TemporaryPlace> findAllTemporaryPlace() { | ||
final List<TemporaryPlace> temporaryPlaces = temporaryPlaceRepository.findAll(); | ||
temporaryPlaces.sort(Comparator.comparing(TemporaryPlace::getCreatedAt).reversed()); | ||
return temporaryPlaces; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...c/main/java/com/now/naaga/temporaryplace/application/dto/CreateTemporaryPlaceCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.now.naaga.temporaryplace.application.dto; | ||
|
||
import com.now.naaga.place.domain.Position; | ||
import com.now.naaga.player.presentation.dto.PlayerRequest; | ||
import com.now.naaga.temporaryplace.presentation.dto.CreateTemporaryPlaceRequest; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
public record CreateTemporaryPlaceCommand(Long playerId, | ||
String name, | ||
String description, | ||
Position position, | ||
MultipartFile imageFile) { | ||
|
||
public static CreateTemporaryPlaceCommand of(final PlayerRequest playerRequest, | ||
final CreateTemporaryPlaceRequest createTemporaryPlaceRequest) { | ||
Position position = Position.of(createTemporaryPlaceRequest.latitude(), createTemporaryPlaceRequest.longitude()); | ||
return new CreateTemporaryPlaceCommand( | ||
playerRequest.playerId(), | ||
createTemporaryPlaceRequest.name(), | ||
createTemporaryPlaceRequest.description(), | ||
position, | ||
createTemporaryPlaceRequest.imageFile()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../main/java/com/now/naaga/temporaryplace/presentation/dto/CreateTemporaryPlaceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.now.naaga.temporaryplace.presentation.dto; | ||
|
||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
public record CreateTemporaryPlaceRequest(String name, | ||
String description, | ||
Double latitude, | ||
Double longitude, | ||
MultipartFile imageFile) { | ||
} |
35 changes: 35 additions & 0 deletions
35
...d/src/main/java/com/now/naaga/temporaryplace/presentation/dto/TemporaryPlaceResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.now.naaga.temporaryplace.presentation.dto; | ||
|
||
import com.now.naaga.game.presentation.dto.CoordinateResponse; | ||
import com.now.naaga.temporaryplace.domain.TemporaryPlace; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public record TemporaryPlaceResponse(Long id, | ||
String name, | ||
CoordinateResponse coordinate, | ||
String imageUrl, | ||
String description, | ||
Long registeredPlayerId | ||
|
||
) { | ||
|
||
public static TemporaryPlaceResponse from(final TemporaryPlace savedTemporaryPlace) { | ||
CoordinateResponse coordinateResponse = CoordinateResponse.of(savedTemporaryPlace.getPosition()); | ||
return new TemporaryPlaceResponse( | ||
savedTemporaryPlace.getId(), | ||
savedTemporaryPlace.getName(), | ||
coordinateResponse, | ||
savedTemporaryPlace.getImageUrl(), | ||
savedTemporaryPlace.getDescription(), | ||
savedTemporaryPlace.getRegisteredPlayer().getId() | ||
); | ||
} | ||
|
||
public static List<TemporaryPlaceResponse> convertToResponses(final List<TemporaryPlace> temporaryPlaces) { | ||
return temporaryPlaces.stream() | ||
.map(TemporaryPlaceResponse::from) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
backend/src/test/java/com/now/naaga/common/fixture/TemporaryPlaceFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.now.naaga.common.fixture; | ||
|
||
import com.now.naaga.temporaryplace.domain.TemporaryPlace; | ||
|
||
import static com.now.naaga.common.fixture.PlayerFixture.PLAYER; | ||
import static com.now.naaga.common.fixture.PositionFixture.잠실_루터회관_정문_좌표; | ||
|
||
public class TemporaryPlaceFixture { | ||
|
||
public static final String NAME = "temp_place_name"; | ||
|
||
public static final String DESCRIPTION = "temp_place_description"; | ||
|
||
public static final String IMAGE_URL = "temp_place_imageUrl"; | ||
|
||
public static TemporaryPlace TEMPORARY_PLACE() { | ||
return new TemporaryPlace(NAME, DESCRIPTION, 잠실_루터회관_정문_좌표, IMAGE_URL, PLAYER()); | ||
} | ||
} |
File renamed without changes
Oops, something went wrong.