Skip to content

Commit 1477106

Browse files
authored
Backend/yujin/qa (#16)
# 변경점 👍 - 목적지 검색 시 현재 위치의 거리 기준으로 결과를 정렬해 반환하도록 수정하였습니다. # 버그 해결 💊 - 그 결과, 목적지 검색 시 현재 위치에 근접한 목적지가 나오지 않는 문제를 해결하였습니다. # 리팩토링 💧 - 거리를 구하는 distance 함수를 길찾기 로직 수정시에도 사용하게 되어, 따로 DistanceService로 빼두었습니다. # 테스트 💻 - Postman으로 /places/search URL에 대해 요청을 보냈고, 정상 작동을 확인하였습니다. # 스크린샷 🖼 <img width="2880" height="1704" alt="스크린샷 2026-06-29 162234" src="https://github.com/user-attachments/assets/3f6e576c-4c3f-4ecf-8bd1-8b0c63c5bb9e" />
1 parent 28eb989 commit 1477106

44 files changed

Lines changed: 291200 additions & 7416 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
onmyway_data_add.sql
2+
onmyway_snapshot.sql
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package _team.onmyway.controller;
2+
3+
import _team.onmyway.dto.MyPageDTO;
4+
import _team.onmyway.service.MyPageService;
5+
import lombok.RequiredArgsConstructor;
6+
import org.springframework.http.HttpStatus;
7+
import org.springframework.http.ResponseEntity;
8+
import org.springframework.web.bind.annotation.GetMapping;
9+
import org.springframework.web.bind.annotation.RestController;
10+
11+
@RestController
12+
@RequiredArgsConstructor
13+
public class MyPageController {
14+
15+
private final MyPageService myPageService;
16+
17+
@GetMapping("myPage")
18+
public ResponseEntity<?> myPageHome() {
19+
MyPageDTO mypage = myPageService.Home();
20+
return new ResponseEntity<>(mypage, HttpStatus.OK);
21+
}
22+
}

backend/src/main/java/_team/onmyway/controller/SearchController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package _team.onmyway.controller;
22

33
import _team.onmyway.dto.PointDTO;
4+
import _team.onmyway.dto.PositionDTO;
45
import _team.onmyway.service.SearchService;
56
import lombok.RequiredArgsConstructor;
67
import org.springframework.http.ResponseEntity;
@@ -17,8 +18,9 @@ public class SearchController {
1718
private final SearchService searchService;
1819

1920
@GetMapping("/places/search")
20-
public ResponseEntity<Mono<List<PointDTO>>> searchPlace(@RequestParam String query) {
21-
Mono<List<PointDTO>> places = searchService.searchPlaces(query);
21+
public ResponseEntity<Mono<List<PointDTO>>> searchPlace(@RequestParam String query, @RequestParam Double lat, @RequestParam Double lon) {
22+
PositionDTO point = new PositionDTO(lat, lon);
23+
Mono<List<PointDTO>> places = searchService.searchPlaces(query, point);
2224
return ResponseEntity.ok(places);
2325
}
2426
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package _team.onmyway.dto;
2+
3+
4+
import jakarta.validation.constraints.NotNull;
5+
import lombok.AllArgsConstructor;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.util.List;
9+
10+
public record MyPageDTO (
11+
String username,
12+
String profileImageURL,
13+
String catchPhrase,
14+
Integer follower,
15+
Integer following,
16+
List<PostDTO> thumbPosts
17+
) {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package _team.onmyway.dto;
2+
3+
import _team.onmyway.entity.PostPhotos;
4+
import _team.onmyway.entity.Posts;
5+
6+
import java.util.List;
7+
import java.util.stream.Collectors;
8+
9+
public record PostDTO(
10+
String title,
11+
String author,
12+
String content,
13+
List<String> imageURLs
14+
) {
15+
public static PostDTO fromPost(Posts post) {
16+
PostDTO postDTO = new PostDTO(
17+
post.getTitle(),
18+
post.getAuthor().getNickname(),
19+
post.getContent(),
20+
post.getPhotos().stream()
21+
.map(PostPhotos::getPhoto)
22+
.collect(Collectors.toList())
23+
);
24+
return postDTO;
25+
}
26+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package _team.onmyway.entity;
2+
3+
import jakarta.persistence.*;
4+
import org.apache.catalina.User;
5+
6+
@Entity
7+
public class Follow {
8+
@Id
9+
@GeneratedValue
10+
private Long id;
11+
12+
@ManyToOne(fetch = FetchType.LAZY)
13+
@JoinColumn
14+
private Users fromUser;
15+
16+
@ManyToOne(fetch = FetchType.LAZY)
17+
@JoinColumn
18+
private Users toUser;
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package _team.onmyway.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.Getter;
5+
6+
@Entity
7+
@Getter
8+
public class PostPhotos {
9+
@Id
10+
@GeneratedValue(strategy = GenerationType.IDENTITY)
11+
private Long id;
12+
13+
@ManyToOne
14+
@JoinColumn(name="posts_id")
15+
private Posts post;
16+
17+
private String photo;
18+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package _team.onmyway.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.Getter;
5+
6+
import java.time.LocalDateTime;
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
@Entity
11+
@Getter
12+
public class Posts {
13+
@Id
14+
@GeneratedValue(strategy = GenerationType.IDENTITY)
15+
private Long id;
16+
17+
private String title;
18+
19+
private String content;
20+
21+
@ManyToOne
22+
@JoinColumn(name="users_id")
23+
private Users author;
24+
25+
@OneToMany(mappedBy = "post")
26+
private List<PostPhotos> photos = new ArrayList<PostPhotos>();
27+
28+
private LocalDateTime created = LocalDateTime.now();
29+
30+
private LocalDateTime modified = LocalDateTime.now();
31+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package _team.onmyway.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
9+
import java.time.LocalDateTime;
10+
11+
@Entity
12+
@Getter
13+
@NoArgsConstructor
14+
@AllArgsConstructor
15+
public class Profile {
16+
@Id
17+
private Long id;
18+
19+
@MapsId
20+
@OneToOne
21+
@JoinColumn(name="users_id")
22+
private Users user;
23+
24+
private String profileName;
25+
26+
private String catchPhrase;
27+
28+
private String imageURL;
29+
30+
private LocalDateTime updatedAt;
31+
32+
@Builder
33+
public Profile(Users user, String profileName, String catchPhrase, String imageURL, LocalDateTime updatedAt) {
34+
this.user = user;
35+
this.profileName = profileName;
36+
this.catchPhrase = catchPhrase;
37+
this.imageURL = imageURL;
38+
this.updatedAt = updatedAt;
39+
}
40+
41+
public void updateProfile(String imageURL, String profileName) {
42+
this.imageURL = imageURL;
43+
this.profileName = profileName;
44+
this.updatedAt = LocalDateTime.now();
45+
}
46+
47+
public void updateCatchPhrase(String catchPhrase) {
48+
this.catchPhrase = catchPhrase;
49+
}
50+
51+
public void updateProfileImage(String imageURL) {
52+
this.imageURL = imageURL;
53+
this.updatedAt = LocalDateTime.now();
54+
}
55+
}

backend/src/main/java/_team/onmyway/entity/Users.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ public class Users {
2424

2525
private String email;
2626

27-
@Column(name = "profile_image_url")
28-
private String profileImageUrl;
27+
@OneToOne(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
28+
private Profile profile;
29+
// @Column(name = "profile_image_url")
30+
// private String profileImageUrl;
2931

3032
@Enumerated(EnumType.STRING)
3133
private Role role;
@@ -45,10 +47,14 @@ public class Users {
4547
@Column(name = "refresh_token")
4648
private String refreshToken;
4749

48-
public void updateProfile(String nickname, String email, String profileImageUrl) {
50+
public void setProfile(Profile profile) {
51+
this.profile = profile;
52+
}
53+
54+
public void updateProfile(String nickname, String email) {
4955
this.nickname = nickname;
5056
this.email = email;
51-
this.profileImageUrl = profileImageUrl;
57+
//this.profileImageUrl = profileImageUrl;
5258
this.isActive = true;
5359
// updatedAt은 @UpdateTimestamp가 자동 갱신
5460
}

0 commit comments

Comments
 (0)