-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from swm-nodriversomabus/BUS-212-accommodatio…
…n-API Bus 212 accommodation api
- Loading branch information
Showing
20 changed files
with
457 additions
and
16 deletions.
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
60 changes: 60 additions & 0 deletions
60
...ava/com/example/api/matching/adapter/out/persistence/AccommodationPersistenceAdapter.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,60 @@ | ||
package com.example.api.matching.adapter.out.persistence; | ||
|
||
import com.example.api.matching.application.port.out.AccommodationPort; | ||
import com.example.api.matching.domain.Accommodation; | ||
import com.example.api.matching.repository.AccommodationRepository; | ||
import com.example.api.matching.repository.MatchingRepository; | ||
import com.example.api.matching.type.MatchingTypeEnum; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@ComponentScan | ||
public class AccommodationPersistenceAdapter implements AccommodationPort { | ||
private final MatchingRepository matchingRepository; | ||
private final AccommodationRepository accommodationRepository; | ||
private final MatchingMapperInterface matchingMapper; | ||
|
||
@Override | ||
public void createAccommodation(Accommodation accommodation) { | ||
accommodationRepository.save(matchingMapper.toEntity(accommodation)); | ||
} | ||
|
||
@Override | ||
public List<MatchingEntity> getAccommodationMatchingList() { | ||
return matchingRepository.getByType(MatchingTypeEnum.Accommodation); | ||
} | ||
|
||
@Override | ||
public List<AccommodationEntity> getAccommodationList() { | ||
return accommodationRepository.getAllBy(); | ||
} | ||
|
||
@Override | ||
public Accommodation getAccommodation(Long matchingId) { | ||
return matchingMapper.toDomain(accommodationRepository.getByMatchingId(matchingId). | ||
orElse(AccommodationEntity.builder() | ||
.matchingId(matchingId) | ||
.price(0) | ||
.pricePerOne(0) | ||
.room("") | ||
.build() | ||
)); | ||
} | ||
|
||
@Override | ||
public void updateAccommodation(Accommodation accommodation) { | ||
accommodationRepository.save(matchingMapper.toEntity(accommodation)); | ||
} | ||
|
||
@Override | ||
public void deleteAccommodation(Accommodation accommodation) { | ||
accommodationRepository.save(matchingMapper.toEntity(accommodation)); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/example/api/matching/application/port/in/AccommodationUsecase.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,16 @@ | ||
package com.example.api.matching.application.port.in; | ||
|
||
import com.example.api.matching.dto.AccommodationDto; | ||
import com.example.api.matching.dto.AccommodationMatchingDto; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface AccommodationUsecase { | ||
void createAccommodation(Long matchingId, AccommodationDto accommodationDto); | ||
List<AccommodationMatchingDto> getAccommodationMatchingList(); | ||
AccommodationDto getAccommodation(Long matchingId); | ||
List<AccommodationDto> getRecommendedAccommodationList(UUID userId); | ||
void updateAccommodation(Long matchingId, AccommodationDto accommodationDto); | ||
void deleteAccommodation(Long matchingId); | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/example/api/matching/application/port/out/AccommodationPort.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,16 @@ | ||
package com.example.api.matching.application.port.out; | ||
|
||
import com.example.api.matching.adapter.out.persistence.AccommodationEntity; | ||
import com.example.api.matching.adapter.out.persistence.MatchingEntity; | ||
import com.example.api.matching.domain.Accommodation; | ||
|
||
import java.util.List; | ||
|
||
public interface AccommodationPort { | ||
void createAccommodation(Accommodation accommodation); | ||
List<MatchingEntity> getAccommodationMatchingList(); | ||
List<AccommodationEntity> getAccommodationList(); | ||
Accommodation getAccommodation(Long matchingId); | ||
void updateAccommodation(Accommodation accommodation); | ||
void deleteAccommodation(Accommodation accommodation); | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/example/api/matching/domain/Accommodation.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,15 @@ | ||
package com.example.api.matching.domain; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Accommodation { | ||
private Long matchingId; | ||
private Integer price; | ||
private Integer pricePerOne; | ||
private String room; | ||
} |
Oops, something went wrong.