-
Notifications
You must be signed in to change notification settings - Fork 2
feat : 사장님 식당 생성, 특정 상점 조회 API구현 #199
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
220b4a5
feat: 상점 생성 기능 추가
618a17f
feat: 상점등록을 하기 위해 연관된 model정의
925a85f
feat: shop과 관련된 repository, exception작성
bd63f1d
feat: 1차 테스트 완료
62d48d3
feat: 사장님 상점 생성 기능 구현
616da6b
feat: 특정상점조회 API구현
af87e07
refactor: 특정상점조회 테스트코드 수정
4bcef46
chore: develop충돌 해결
7934811
chore: import경로 오류 수정
4b81136
chore: pull충돌 해결
5132e89
refactor: saveAll제거
357d740
feat: 스웨거 설명 추가
b728c93
refactor: Builder생성자 접근제어 변경
1fdd1f0
refactor: ShopResponse 적팩메이름 of로 변경
f56adaa
refactor: ShopResponse 적팩메이름 of로 변경
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 hidden or 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 hidden or 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: 85 additions & 0 deletions
85
src/main/java/in/koreatech/koin/domain/ownershop/dto/OwnerShopsRequest.java
This file contains hidden or 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,85 @@ | ||
| package in.koreatech.koin.domain.ownershop.dto; | ||
|
|
||
| import java.time.LocalTime; | ||
| import java.util.List; | ||
|
|
||
| import in.koreatech.koin.domain.owner.model.Owner; | ||
| import in.koreatech.koin.domain.shop.model.Shop; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record OwnerShopsRequest( | ||
| @Schema(description = "주소", example = "충청남도 천안시 동남구 병천면 충절로 1600") | ||
| @NotBlank(message = "주소를 입력해주세요.") | ||
| String address, | ||
|
|
||
| @Schema(description = "상점 카테고리 고유 id 리스트", example = "[1]") | ||
| List<Long> categoryIds, | ||
|
|
||
| @Schema(description = "배달 가능 여부", example = "false") | ||
| Boolean delivery, | ||
|
|
||
| @Schema(description = "배달 금액", example = "1000") | ||
| Long deliveryPrice, | ||
|
|
||
| @Schema(description = "기타정보", example = "이번주 전 메뉴 10% 할인 이벤트합니다.") | ||
| String description, | ||
|
|
||
| @Schema(description = "이미지 URL 리스트", example = "[\"string\"]") | ||
| List<String> imageUrls, | ||
|
|
||
| @Schema(description = "가게명", example = "써니 숯불 도시락") | ||
| @NotBlank(message = "상점 이름을 입력해주세요.") | ||
| String name, | ||
|
|
||
| @Schema(description = "요일별 운영 시간과 휴무 여부") | ||
| List<InnerOpenRequest> open, | ||
|
|
||
| @Schema(description = "계좌 이체 가능 여부", example = "true") | ||
| Boolean payBank, | ||
|
|
||
| @Schema(description = "카드 가능 여부", example = "true") | ||
| Boolean payCard, | ||
|
|
||
| @Schema(description = "전화번호", example = "041-123-4567") | ||
| @NotBlank(message = "전화번호를 입력해주세요.") | ||
| String phone | ||
| ) { | ||
|
|
||
| public Shop toEntity(Owner owner) { | ||
| return Shop.builder() | ||
| .owner(owner) | ||
| .address(address) | ||
| .deliveryPrice(deliveryPrice) | ||
| .delivery(delivery) | ||
| .description(description) | ||
| .payBank(payBank) | ||
| .payCard(payCard) | ||
| .phone(phone) | ||
| .name(name) | ||
| .internalName(name) | ||
| .chosung(name().substring(0, 1)) | ||
| .isDeleted(false) | ||
| .isEvent(false) | ||
| .remarks("") | ||
| .hit(0L) | ||
| .build(); | ||
| } | ||
|
|
||
| public record InnerOpenRequest( | ||
| @Schema(description = "닫는 시간", example = "22:30") | ||
| LocalTime closeTime, | ||
|
|
||
| @Schema(description = "휴무 여부", example = "false") | ||
| Boolean closed, | ||
|
|
||
| @Schema(description = "요일", example = "MONDAY") | ||
| @NotBlank(message = "영업 요일을 입력해주세요.") | ||
| String dayOfWeek, | ||
|
|
||
| @Schema(description = "여는 시간", example = "10:00") | ||
| LocalTime openTime | ||
| ) { | ||
|
|
||
| } | ||
| } |
This file contains hidden or 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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,8 +5,19 @@ | |||||||||||||||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||||||||||||||||
| import org.springframework.transaction.annotation.Transactional; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.owner.model.Owner; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.owner.repository.OwnerRepository; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.ownershop.dto.OwnerShopsRequest; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.ownershop.dto.OwnerShopsResponse; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.model.Shop; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.model.ShopCategory; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.model.ShopCategoryMap; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.model.ShopImage; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.model.ShopOpen; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.repository.ShopCategoryMapRepository; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.repository.ShopCategoryRepository; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.repository.ShopImageRepository; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.repository.ShopOpenRepository; | ||||||||||||||||||||||||||||
| import in.koreatech.koin.domain.shop.repository.ShopRepository; | ||||||||||||||||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -16,9 +27,46 @@ | |||||||||||||||||||||||||||
| public class OwnerShopService { | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| private final ShopRepository shopRepository; | ||||||||||||||||||||||||||||
| private final OwnerRepository ownerRepository; | ||||||||||||||||||||||||||||
| private final ShopOpenRepository shopOpenRepository; | ||||||||||||||||||||||||||||
| private final ShopCategoryMapRepository shopCategoryMapRepository; | ||||||||||||||||||||||||||||
| private final ShopCategoryRepository shopCategoryRepository; | ||||||||||||||||||||||||||||
| private final ShopImageRepository shopImageRepository; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public OwnerShopsResponse getOwnerShops(Long ownerId) { | ||||||||||||||||||||||||||||
| List<Shop> shops = shopRepository.findAllByOwnerId(ownerId); | ||||||||||||||||||||||||||||
| return OwnerShopsResponse.from(shops); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @Transactional | ||||||||||||||||||||||||||||
| public void createOwnerShops(Long ownerId, OwnerShopsRequest ownerShopsRequest) { | ||||||||||||||||||||||||||||
| Owner owner = ownerRepository.getById(ownerId); | ||||||||||||||||||||||||||||
| Shop newShop = ownerShopsRequest.toEntity(owner); | ||||||||||||||||||||||||||||
| shopRepository.save(newShop); | ||||||||||||||||||||||||||||
| for (String imageUrl : ownerShopsRequest.imageUrls()) { | ||||||||||||||||||||||||||||
| ShopImage shopImage = ShopImage.builder() | ||||||||||||||||||||||||||||
| .shop(newShop) | ||||||||||||||||||||||||||||
| .imageUrl(imageUrl) | ||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||
| shopImageRepository.save(shopImage); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+46
to
+52
Collaborator
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. R
Suggested change
코드를 조금 손보면 이런 식으로도 쓸 수 있지 않을까요?
Member
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. 이거는 stream 내부에서 예외 발생하면 안멈추고 계속 돌아버려서 |
||||||||||||||||||||||||||||
| for (OwnerShopsRequest.InnerOpenRequest open : ownerShopsRequest.open()) { | ||||||||||||||||||||||||||||
| ShopOpen shopOpen = ShopOpen.builder() | ||||||||||||||||||||||||||||
| .shop(newShop) | ||||||||||||||||||||||||||||
| .openTime(open.openTime()) | ||||||||||||||||||||||||||||
| .closeTime(open.closeTime()) | ||||||||||||||||||||||||||||
| .dayOfWeek(open.dayOfWeek()) | ||||||||||||||||||||||||||||
| .closed(open.closed()) | ||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||
| shopOpenRepository.save(shopOpen); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| List<ShopCategory> shopCategories = shopCategoryRepository.findAllByIdIn(ownerShopsRequest.categoryIds()); | ||||||||||||||||||||||||||||
| for (ShopCategory shopCategory : shopCategories) { | ||||||||||||||||||||||||||||
| ShopCategoryMap shopCategoryMap = ShopCategoryMap.builder() | ||||||||||||||||||||||||||||
| .shopCategory(shopCategory) | ||||||||||||||||||||||||||||
| .shop(newShop) | ||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||
| shopCategoryMapRepository.save(shopCategoryMap); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
This file contains hidden or 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 hidden or 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
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.
A
뭐가 많네요.. ㅇㅁㅇ;;