-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/admin concert place #2
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
44aed94
오타수정
plere 8a102da
admin-concert 프로젝트 추가
plere d89a845
장소 등록 API 개발
plere 97d9d9c
요청 파라미터 validation exception advice 추가
plere d55d52b
장소명으로 장소 조회하는 API 개발
plere af6df1a
코드리뷰 반영
plere dc5ef32
placeVersion을 제거하고 verison 정보를 place 한곳에서 관리하도록 수정
plere e38287f
admin-concert example http 코드 추가
plere e667323
reader/writer 분리
plere 53842b8
model과 entity 분리
plere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
85 changes: 0 additions & 85 deletions
85
...n-concert/src/main/java/co/kr/ticketing/adminconcert/place/domain/model/PlaceVersion.java
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...-concert/src/main/java/co/kr/ticketing/adminconcert/place/repository/PlaceRepository.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,10 +1,16 @@ | ||
package co.kr.ticketing.adminconcert.place.repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import co.kr.ticketing.adminconcert.place.domain.model.Place; | ||
|
||
@Repository | ||
public interface PlaceRepository extends JpaRepository<Place, Long> { | ||
Optional<Place> findTopByIdentifierOrderByVersionDesc(String identifier); | ||
|
||
List<Place> findByNameContainsAndLastIsTrue(String name); | ||
} |
16 changes: 0 additions & 16 deletions
16
...t/src/main/java/co/kr/ticketing/adminconcert/place/repository/PlaceVersionRepository.java
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package co.kr.ticketing.adminconcert.place.service; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.dao.DataIntegrityViolationException; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import co.kr.ticketing.adminconcert.common.exception.DuplicateException; | ||
import co.kr.ticketing.adminconcert.common.exception.ResourceNotFoundException; | ||
import co.kr.ticketing.adminconcert.place.domain.model.Place; | ||
import co.kr.ticketing.adminconcert.place.repository.PlaceRepository; | ||
|
@@ -15,14 +19,30 @@ | |
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) | ||
public class PlaceService { | ||
PlaceRepository placeRepository; | ||
UUIDGenerator uuidGenerator; | ||
|
||
public Place getLastVersion(String identifier) { | ||
return placeRepository.findTopByIdentifierOrderByVersionDesc(identifier) | ||
.orElseThrow(() -> new ResourceNotFoundException("place", identifier)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사소한 부분이지만 나중에는 Service 레벨에서는 Entity 를 직접 다루기 보다 VO 를 사용하는 연습해보시면 좋을것 같습니다. |
||
|
||
public Place getById(long id) { | ||
return placeRepository.findById(id) | ||
.orElseThrow(() -> new ResourceNotFoundException("concert place", id)); | ||
public List<Place> getLastVersionsByPlaceName(String placeName) { | ||
return placeRepository.findByNameContainsAndLastIsTrue(placeName); | ||
} | ||
|
||
@Transactional | ||
public long create(Place place) { | ||
return placeRepository.save(Place.getNewPlace(place, uuidGenerator)).getId(); | ||
} | ||
|
||
@Transactional | ||
public long add(Place place) { | ||
return placeRepository.save(place).getId(); | ||
try { | ||
Place lastPlace = getLastVersion(place.getIdentifier()); | ||
|
||
return placeRepository.save(place.getNextPlace(lastPlace)).getId(); | ||
} catch (DataIntegrityViolationException e) { | ||
throw new DuplicateException("정보가 수정됐습니다. 확인 후 다시 작성 해주세요"); | ||
} | ||
} | ||
} |
49 changes: 0 additions & 49 deletions
49
...concert/src/main/java/co/kr/ticketing/adminconcert/place/service/PlaceVersionService.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get 에서 last 를 셋팅하는 write operation 이 같이 있는데요. 분리하면 좋을 것 같습니다.
함수는 getNextPlace 로 DB 변경이 없을 것이 기대되지만 실재로는 beforePlace 의 last 가 Update 되는 함수라 안정적이지 않아보입니다.
차라리 last 를 별도 루틴에서 셋팅하게해서 read / write 를 분리하는게 좋을것 같습니다.