-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related: #54
- Loading branch information
Showing
16 changed files
with
71 additions
and
88 deletions.
There are no files selected for viewing
60 changes: 0 additions & 60 deletions
60
src/main/java/com/modoospace/data/service/DataService.java
This file was deleted.
Oops, something went wrong.
9 changes: 5 additions & 4 deletions
9
.../data/controller/dto/AddressResponse.java → ...a/controller/dto/MockAddressResponse.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
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
2 changes: 1 addition & 1 deletion
2
...data/controller/dto/address/Document.java → ...Data/controller/dto/address/Document.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
2 changes: 1 addition & 1 deletion
2
.../controller/dto/address/JibunAddress.java → .../controller/dto/address/JibunAddress.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
2 changes: 1 addition & 1 deletion
2
...a/controller/dto/address/RoadAddress.java → ...a/controller/dto/address/RoadAddress.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
2 changes: 1 addition & 1 deletion
2
...e/data/controller/dto/space/BreakDay.java → ...ckData/controller/dto/space/BreakDay.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
2 changes: 1 addition & 1 deletion
2
...ta/controller/dto/space/BreakHoliday.java → ...ta/controller/dto/space/BreakHoliday.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
2 changes: 1 addition & 1 deletion
2
.../data/controller/dto/space/BreakTime.java → ...kData/controller/dto/space/BreakTime.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
2 changes: 1 addition & 1 deletion
2
...ontroller/dto/space/FacilityCategory.java → ...ontroller/dto/space/FacilityCategory.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
2 changes: 1 addition & 1 deletion
2
...ta/controller/dto/space/FacilityInfo.java → ...ta/controller/dto/space/FacilityInfo.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
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
2 changes: 1 addition & 1 deletion
2
...e/data/controller/dto/space/Location.java → ...ckData/controller/dto/space/Location.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
2 changes: 1 addition & 1 deletion
2
.../data/controller/dto/space/SpaceInfo.java → ...kData/controller/dto/space/SpaceInfo.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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/modoospace/mockData/service/MockDataService.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,47 @@ | ||
package com.modoospace.mockData.service; | ||
|
||
import com.modoospace.member.domain.Member; | ||
import com.modoospace.member.service.MemberService; | ||
import com.modoospace.mockData.controller.dto.MockAddressResponse; | ||
import com.modoospace.mockData.controller.dto.MockSpaceResponse; | ||
import com.modoospace.space.domain.*; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Optional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MockDataService { | ||
|
||
private final MemberService memberService; | ||
private final CategoryRepository categoryRepository; | ||
private final SpaceRepository spaceRepository; | ||
private final SpaceIndexRepository spaceIndexRepository; | ||
private final FacilityRepository facilityRepository; | ||
|
||
public Long saveEntity(MockSpaceResponse spaceResponse, MockAddressResponse addressResponse, String email) { | ||
Space space = makeSpace(spaceResponse, addressResponse, email); | ||
spaceIndexRepository.save(SpaceIndex.of(space)); | ||
makeFacility(spaceResponse, space); | ||
return space.getId(); | ||
} | ||
|
||
private Space makeSpace(MockSpaceResponse spaceResponse, MockAddressResponse addressResponse, String email) { | ||
Member member = memberService.findMemberByEmail(email); | ||
Address address = addressResponse.toAddress(spaceResponse.getLocation().getDetailAddress()); | ||
Category category = findCategory(spaceResponse.getCategoryName()); | ||
|
||
return spaceRepository.save(spaceResponse.toSpace(address, category, member)); | ||
} | ||
|
||
private Category findCategory(String name) { | ||
Optional<Category> optionalCategory = categoryRepository.findByName(name); | ||
return optionalCategory.orElseGet(() -> categoryRepository.save(new Category(name))); | ||
} | ||
|
||
private void makeFacility(MockSpaceResponse spaceResponse, Space space) { | ||
spaceResponse.getFacilityResponses() | ||
.forEach(product -> facilityRepository.save(product.toFacility(spaceResponse.getTimeSettings(), spaceResponse.getWeekdaySettings(), space))); | ||
} | ||
} |
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