-
Notifications
You must be signed in to change notification settings - Fork 2
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 #23 from kakao-tech-campus-2nd-step3/develop
[develop] 2주차 Master PR
- Loading branch information
Showing
65 changed files
with
1,447 additions
and
309 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "src/main/resources/InplaceSecurity"] | ||
path = src/main/resources/InplaceSecurity | ||
url = https://github.com/suhyeon7497/InplaceSecurity.git |
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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
# Team7_BE | ||
|
||
## Project Version | ||
- Spring Boots 3.3.3 | ||
- Java 17 LTS | ||
|
||
--- | ||
## 리뷰 요청 | ||
### PlaceControllerTest | ||
- Mock을 사용하여 테스트를 진행했는데, 적절히 사용했는지 잘 모르겠습니다. | ||
- PlaceService를 mock, PlaceController를 InjectedMocks로 지정했는데 블로그 찾아보니 사람마다 조금씩 달라 적절한지 궁금합니다. | ||
- Spring Boots 3.3.3 | ||
- Java 17 LTS |
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 |
---|---|---|
@@ -1,41 +1,45 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '3.3.3' | ||
id 'io.spring.dependency-management' version '1.1.6' | ||
id 'java' | ||
id 'org.springframework.boot' version '3.3.3' | ||
id 'io.spring.dependency-management' version '1.1.6' | ||
} | ||
|
||
group = 'inplace' | ||
version = '0.0.1-SNAPSHOT' | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
} | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
} | ||
} | ||
|
||
configurations { | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
|
||
|
||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
runtimeOnly 'com.mysql:mysql-connector-j' | ||
runtimeOnly 'com.h2database:h2' | ||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
implementation 'org.springframework.boot:spring-boot-starter-security' | ||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' | ||
implementation 'io.jsonwebtoken:jjwt-api:0.12.3' | ||
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3' | ||
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3' | ||
|
||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
runtimeOnly 'com.mysql:mysql-connector-j' | ||
runtimeOnly 'com.h2database:h2' | ||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
} | ||
|
||
tasks.named('test') { | ||
useJUnitPlatform() | ||
useJUnitPlatform() | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/team7/inplace/influencer/domain/Influencer.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,34 @@ | ||
package team7.inplace.influencer.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@RequiredArgsConstructor // 테스팅을 위한 부분 추가, 협의 하에 다른 방식 채택 가능 | ||
public class Influencer { | ||
/* | ||
* 더미 데이터 입니다 !!! | ||
*/ | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column | ||
@NonNull | ||
private String name; | ||
@Column | ||
@NonNull | ||
private String job; | ||
@Column | ||
@NonNull | ||
private String imgUrl; | ||
} |
7 changes: 3 additions & 4 deletions
7
...ideo/repository/InfluencerRepository.java → ...cer/persistence/InfluencerRepository.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
21 changes: 21 additions & 0 deletions
21
src/main/java/team7/inplace/place/application/CategoryService.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 team7.inplace.place.application; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import team7.inplace.place.application.dto.CategoryInfo; | ||
import team7.inplace.place.domain.Category; | ||
import team7.inplace.place.persistence.PlaceRepository; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CategoryService { | ||
|
||
private final PlaceRepository placeRepository; | ||
|
||
public List<CategoryInfo> getCategories() { | ||
return Arrays.stream(Category.values()).map(category -> new CategoryInfo(category.name())) | ||
.toList(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/team7/inplace/place/application/PlaceService.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,33 @@ | ||
package team7.inplace.place.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.stereotype.Service; | ||
import team7.inplace.place.application.command.PlacesCommand.PlacesCoordinateCommand; | ||
import team7.inplace.place.application.dto.PlaceInfo; | ||
import team7.inplace.place.domain.Place; | ||
import team7.inplace.place.persistence.PlaceRepository; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PlaceService { | ||
|
||
private final PlaceRepository placeRepository; | ||
|
||
public Page<PlaceInfo> getPlacesWithinRadius( | ||
PlacesCoordinateCommand placesCoordinateCommand) { | ||
|
||
// 주어진 좌표로 장소를 찾고, 해당 페이지의 결과를 가져옵니다. | ||
Page<Place> placesPage = getPlacesByDistance(placesCoordinateCommand); | ||
|
||
return placesPage.map(PlaceInfo::of); | ||
} | ||
|
||
private Page<Place> getPlacesByDistance(PlacesCoordinateCommand comm) { | ||
return placeRepository.getPlacesByDistance( | ||
comm.latitude(), | ||
comm.longitude(), | ||
comm.pageable()); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/team7/inplace/place/application/command/PlacesCommand.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,14 @@ | ||
package team7.inplace.place.application.command; | ||
|
||
import org.springframework.data.domain.Pageable; | ||
|
||
public record PlacesCommand() { | ||
|
||
public record PlacesCoordinateCommand( | ||
String longitude, | ||
String latitude, | ||
Pageable pageable | ||
) { | ||
|
||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/team7/inplace/place/application/dto/CategoryInfo.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,5 @@ | ||
package team7.inplace.place.application.dto; | ||
|
||
public record CategoryInfo(String name) { | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/team7/inplace/place/application/dto/PlaceForVideo.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,13 @@ | ||
package team7.inplace.place.application.dto; | ||
|
||
public record PlaceForVideo( | ||
Long placeId, | ||
String placeName | ||
) { | ||
public static PlaceForVideo of(Long placeId, String placeName) { | ||
return new PlaceForVideo( | ||
placeId, | ||
placeName | ||
); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/team7/inplace/place/application/dto/PlaceInfo.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 team7.inplace.place.application.dto; | ||
|
||
|
||
import team7.inplace.place.domain.Address; | ||
import team7.inplace.place.domain.Place; | ||
|
||
public record PlaceInfo( | ||
Long placeId, | ||
String placeName, | ||
AddressInfo address, | ||
String category, | ||
String influencerName, | ||
String longitude, | ||
String latitude, | ||
Boolean likes | ||
) { | ||
|
||
|
||
// influencer, likes 추가 예정 | ||
public record AddressInfo( | ||
String address1, | ||
String address2, | ||
String address3 | ||
) { | ||
|
||
public static AddressInfo of(Address address) { | ||
return new PlaceInfo.AddressInfo( | ||
address.getAddress1(), | ||
address.getAddress2(), | ||
address.getAddress3() | ||
); | ||
} | ||
} | ||
|
||
public static PlaceInfo of(Place place) { | ||
return new PlaceInfo( | ||
place.getId(), | ||
place.getName(), | ||
AddressInfo.of(place.getAddress()), | ||
place.getCategory().toString(), | ||
null, | ||
place.getCoordinate().getLongitude(), | ||
place.getCoordinate().getLatitude(), | ||
null | ||
); | ||
} | ||
} |
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,97 @@ | ||
package team7.inplace.place.config; | ||
|
||
import java.util.Arrays; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.stereotype.Component; | ||
import team7.inplace.place.domain.Address; | ||
import team7.inplace.place.domain.Category; | ||
import team7.inplace.place.domain.Coordinate; | ||
import team7.inplace.place.domain.Menu; | ||
import team7.inplace.place.domain.Place; | ||
import team7.inplace.place.domain.PlaceTime; | ||
import team7.inplace.place.persistence.PlaceRepository; | ||
|
||
@Component | ||
public class DataLoader implements CommandLineRunner { | ||
|
||
private final PlaceRepository placeRepository; | ||
|
||
public DataLoader(PlaceRepository placeRepository) { | ||
this.placeRepository = placeRepository; | ||
} | ||
|
||
@Override | ||
public void run(String... args) throws Exception { | ||
// 더미 데이터 생성 | ||
Place place1 = Place.builder() | ||
.name("Place 1") | ||
.pet(false) | ||
.wifi(true) | ||
.parking(false) | ||
.fordisabled(true) | ||
.nursery(false) | ||
.smokingroom(false) | ||
.address(new Address("Address 1", "Address 2", "Address 3")) | ||
.menuImgUrl("menu.jpg") | ||
.category(Category.CAFE) | ||
.coordinate(new Coordinate("127.0", "37.0")) | ||
.timeList(Arrays.asList( | ||
new PlaceTime("Opening Hours", "9:00 AM", "Monday"), | ||
new PlaceTime("Closing Hours", "10:00 PM", "Monday") | ||
)) | ||
.menuList(Arrays.asList( | ||
new Menu(5000L, true, "Coffee"), | ||
new Menu(7000L, false, "Cake") | ||
)) | ||
.build(); | ||
|
||
Place place2 = Place.builder() | ||
.name("Place 2") | ||
.pet(false) | ||
.wifi(true) | ||
.parking(false) | ||
.fordisabled(true) | ||
.nursery(false) | ||
.smokingroom(false) | ||
.address(new Address("Address 1", "Address 2", "Address 3")) | ||
.menuImgUrl("menu.jpg") | ||
.category(Category.CAFE) | ||
.coordinate(new Coordinate("137.0", "10.0")) | ||
.timeList(Arrays.asList( | ||
new PlaceTime("Opening Hours", "9:00 AM", "Monday"), | ||
new PlaceTime("Closing Hours", "10:00 PM", "Monday") | ||
)) | ||
.menuList(Arrays.asList( | ||
new Menu(5000L, true, "Coffee"), | ||
new Menu(7000L, false, "Cake") | ||
)) | ||
.build(); | ||
|
||
Place place3 = Place.builder() | ||
.name("Place 3") | ||
.pet(false) | ||
.wifi(true) | ||
.parking(false) | ||
.fordisabled(true) | ||
.nursery(false) | ||
.smokingroom(false) | ||
.address(new Address("Address 1", "Address 2", "Address 3")) | ||
.menuImgUrl("menu.jpg") | ||
.category(Category.CAFE) | ||
.coordinate(new Coordinate("126.0", "30.0")) | ||
.timeList(Arrays.asList( | ||
new PlaceTime("Opening Hours", "9:00 AM", "Monday"), | ||
new PlaceTime("Closing Hours", "10:00 PM", "Monday") | ||
)) | ||
.menuList(Arrays.asList( | ||
new Menu(5000L, true, "Coffee"), | ||
new Menu(7000L, false, "Cake") | ||
)) | ||
.build(); | ||
|
||
// 저장 | ||
placeRepository.save(place1); | ||
placeRepository.save(place2); | ||
placeRepository.save(place3); | ||
} | ||
} |
Oops, something went wrong.