Skip to content

Add walk route creation feature#10

Open
Alnair-dev wants to merge 1 commit into
mainfrom
feature/walk-route-recommendation
Open

Add walk route creation feature#10
Alnair-dev wants to merge 1 commit into
mainfrom
feature/walk-route-recommendation

Conversation

@Alnair-dev

Copy link
Copy Markdown
Member
  • 산책 경로 생성 API 추가
  • WalkRouteUseCase 및 컨트롤러 연동
  • 장소 리스트 및 rating 기반 경로 저장 로직 구현
  • SHA-256 기반 routeKey 생성 적용
  • 기본 검증 로직 추가(장소 최소 2개)

import java.util.List;

public record WalkRecommendationRes(
List<String> places,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 부분 나중에 places가 아니라 경로 id(Long)로 처리할 것 같네요.
저희 MongoDB 사용할거니까 그 DB에 있는 id로 저장할 것 같아요. 지금 수정할 건 아닌데, 참고해 두세요.

Comment on lines +6 to +7
List<String> places,
int rating

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분도 AI 서버 되면 고치긴 해야할 듯 ㅇㅇ
일단 현준이한테 물어보면 반환 형식 어떻게 하면 좋은지 알려줄거니까 한번 물어봐

@daehyeong2 daehyeong2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다.
리뷰 내용만 읽어 주시고, 수정이 필요한 부분은 수정해서 다시 리뷰 요청해 주세요!

@OneToMany(mappedBy = "route", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("stepOrder ASC")
@Builder.Default
private List<WalkRoutePlace> places = new ArrayList<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런식으로 places 말고 우리 MongoDB에 경로 json 형식으로 저장할거니까 Long으로 id 한개만 받게 해두셈

@Component
@Service
@RequiredArgsConstructor
public class WalkRecommendationUseCase {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

걍 이 usecase들 사실 유즈케이스식 사용이 아니라서 이름 싹 다 Service로 바꾸자

Comment on lines +22 to +45
public WalkRouteRes createRoute(CreateWalkRouteReq req, String currentUserId) {
var places = req.places().stream()
.map(String::trim)
.filter(s -> !s.isEmpty())
.toList();
if (places.size() < 2) {
throw new IllegalArgumentException("장소는 2개 이상이어야 합니다.");
}
String routeKey = buildRouteKey(places);
WalkRoute route = WalkRoute.builder()
.rating(req.rating())
.createdAt(LocalDateTime.now())
.createdBy(currentUserId)
.routeKey(routeKey)
.build();
for (int i = 0; i < places.size(); i++) {
route.addPlace(places.get(i), i);
}
WalkRoute saved = walkRouteRepository.save(route);
return new WalkRouteRes(
saved.getPlaces().stream().map(p -> p.getPlaceName()).toList(),
saved.getRating()
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 AI 서버 연결할거라 어차피 바꿀거긴 한데 우리 places 기반으로 경로 생성하는게 아니라
사용자 현재 위도, 경도 받고 분위기 그런거 받아서 생성하게 할거임 과거 데이터 고려하는거까지는 좀 빡세고 일단 현재 좌표 입력 -> 그 좌표를 시작 좌표로 하는 경로 추천 이 플로우로 갈 듯
(실제 생성은 파이썬 서버에서 다 하고 스프링에서는 그냥 서빙만 하는 식으로 ㄱㄱ)

reason = "저녁산책은 분위기가 좋습니다.";
} else {
reason = "만약 이 부분이 실행되었다면 개발자에게 커피를 사주십시오.";
public WalkTimeRes recommendTime(WalkTimeReq req) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

잘한 듯? 나중에 구조만 맞춰서 산책로 생성 등등 AI 기능도 느낌으로 하면 될 듯

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 실행될일 없는부분이라 심심해서 나폴리탄 괴담 느낌으로 적어본건데 올라가졌네ㅋㅋ AI들어오면 구조 바꿔봄

Comment on lines +6 to +14
public record CreateWalkRouteReq(
@NotEmpty(message = "장소 리스트는 최소 2개 이상이어야 합니다.")
@Size(min = 2, message = "장소는 2개 이상 입력하세요.")
List<@NotBlank(message = "장소명은 비어 있을 수 없습니다.") String> places,

@Min(value = 1, message = "별점은 1 이상이어야 합니다.")
@Max(value = 5, message = "별점은 5 이하여야 합니다.")
int rating
) {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우리 산책 경로 생성할 때 딱히 장소 기반으로 입력받아서 만드는 건 아님.
유저의 현재 좌표(위도, 경도)를 입력받고 그 좌표를 시작점으로 하는 경로를 AI 서버 통해서 생성할거임. 그거 고려해서 dto 설계해주셈
(수정 요청)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants