-
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 #6 from catchroom/develop
Develop merge
- Loading branch information
Showing
9 changed files
with
181 additions
and
0 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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/catchroom/chat/global/config/FeignConfig.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.catchroom.chat.global.config; | ||
|
||
import feign.Logger; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class FeignConfig { | ||
|
||
@Bean | ||
Logger.Level feignLoggerLevel(){ | ||
return Logger.Level.FULL; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/catchroom/chat/message/controller/MainFeignController.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,20 @@ | ||
package com.catchroom.chat.message.controller; | ||
|
||
import com.catchroom.chat.message.dto.AccommodationResponse; | ||
import com.catchroom.chat.message.service.MainFeignService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/v1") | ||
@RestController | ||
public class MainFeignController { | ||
private final MainFeignService mainFeignService; | ||
@GetMapping("/accommodation/{accommodationId}") | ||
public AccommodationResponse getAccommodation(@PathVariable Long accommodationId) { | ||
return mainFeignService.getAccommodationResponse(accommodationId); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/catchroom/chat/message/dto/AccommodationResponse.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,40 @@ | ||
package com.catchroom.chat.message.dto; | ||
|
||
import com.catchroom.chat.message.type.AccommodationType; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
@Builder | ||
public class AccommodationResponse { | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private String region; | ||
|
||
private String introduction; | ||
|
||
private String service; | ||
|
||
private String thumbnailUrl; | ||
|
||
private String latitude; | ||
|
||
private String longitude; | ||
|
||
private String address; | ||
|
||
private AccommodationType type; | ||
|
||
private double star; | ||
|
||
private int roomCount; | ||
|
||
private List<RoomResponse> roomList; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/catchroom/chat/message/dto/RoomResponse.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,28 @@ | ||
package com.catchroom.chat.message.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Builder | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
public class RoomResponse { | ||
private Long id; | ||
|
||
private int normalCapacity; | ||
|
||
private int maxCapacity; | ||
|
||
private int price; | ||
|
||
private String introduction; | ||
|
||
private String name; | ||
|
||
private String service; | ||
|
||
private int count; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/catchroom/chat/message/feign/MainFeignClient.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,18 @@ | ||
package com.catchroom.chat.message.feign; | ||
|
||
import com.catchroom.chat.global.config.FeignConfig; | ||
import com.catchroom.chat.message.dto.AccommodationResponse; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
@FeignClient( | ||
name = "mainFeign", url = "https://catchroom.xyz/v1", | ||
configuration = FeignConfig.class | ||
) | ||
public interface MainFeignClient { | ||
|
||
@RequestMapping(method = RequestMethod.GET, value = "/accommodation/{accommodationId}") | ||
AccommodationResponse getAccommodationDto(@PathVariable Long accommodationId); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/catchroom/chat/message/service/MainFeignService.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,21 @@ | ||
package com.catchroom.chat.message.service; | ||
|
||
import com.catchroom.chat.message.dto.AccommodationResponse; | ||
import com.catchroom.chat.message.feign.MainFeignClient; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
|
||
@Service | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class MainFeignService { | ||
|
||
private final MainFeignClient mainFeignClient; | ||
|
||
public AccommodationResponse getAccommodationResponse(Long accommodationId) { | ||
return mainFeignClient.getAccommodationDto(accommodationId); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/catchroom/chat/message/type/AccommodationType.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.catchroom.chat.message.type; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public enum AccommodationType { | ||
HOTEL, | ||
RESORT, | ||
PENSION, | ||
POOL_VILLA | ||
; | ||
|
||
} |