Skip to content

Commit

Permalink
Merge pull request #6 from catchroom/develop
Browse files Browse the repository at this point in the history
Develop merge
  • Loading branch information
sungjiwoon authored Jan 16, 2024
2 parents b43eac2 + 7165ef4 commit 4bf3485
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 0 deletions.
22 changes: 22 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ configurations {
}
}

ext {
set('springCloudVersion', "2022.0.3")

}

repositories {
mavenCentral()
maven { url 'https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates' }
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

repositories {
mavenCentral()
}
Expand Down Expand Up @@ -55,6 +71,12 @@ dependencies {
//jpa
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

//feign
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation group: 'io.github.openfeign', name: 'feign-gson', version: '11.0'
// implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign'
// implementation group: 'io.github.openfeign', name: 'feign-gson', version: '11.0'


implementation 'org.webjars.bower:bootstrap:4.3.1'
implementation 'org.webjars.bower:vue:2.5.16'
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/catchroom/ChatApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;

@EnableFeignClients
@SpringBootApplication
public class ChatApplication {

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/catchroom/chat/global/config/FeignConfig.java
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;
}

}
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);
}
}
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 src/main/java/com/catchroom/chat/message/dto/RoomResponse.java
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;
}
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);
}
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);
}

}
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
;

}

0 comments on commit 4bf3485

Please sign in to comment.