Skip to content

6주차 미션 [루가]#12

Open
ochyeon wants to merge 31 commits into
mainfrom
luga/week6
Open

6주차 미션 [루가]#12
ochyeon wants to merge 31 commits into
mainfrom
luga/week6

Conversation

@ochyeon
Copy link
Copy Markdown
Collaborator

@ochyeon ochyeon commented May 7, 2026

📌 구현 결과

  1. 엔티티 설계 및 매핑
  • ERD 기반으로 User, Agreement, Restaurant, Region, Mission, UserMission, Review 엔티티 생성
  • @manytoone 등으로 연관관계 매핑
  1. Repository 생성
  • 각 엔티티에 대한 Repository 인터페이스 생성
  • 페이징 -> Slice를 반환하도록 @query로 직접 JPQL 작성
  1. Service 생성
  • Repository를 주입받아 DB 조회 및 저장하도록 로직 구현
  • 조회 -> @Transactinal(readOnly = true)
  • 변경 -> @Transactinal
  1. Controller 연결
  • 기존 하드코딩 되어있던 부분 제거
  • Service를 주입받아 실제 서비스 메서드 호출하도록 수정

[도메인 별 스웨거]

Mission 성공 처리 Mission 목록 조회 Home 지역별 미션 목록 Home 유저 정보 조회 User 회원 가입 Review 리뷰 작성
Mission_성공처리 Mission_목록 조회 Home_지역별 미션 조회 Home_유저 정보 조회 User_회원가입 Review_리뷰 작성

[DTO]
DTO

❓ 리뷰 요청

🤔 질문

💬

기타 공유 사항

ochyeon and others added 22 commits April 9, 2026 06:01
…(record 사용, 엔드포인트 수정 및 스웨거 명세 추가)
@yujining3827
Copy link
Copy Markdown
Collaborator

수고하셨습니다 ~!

Copy link
Copy Markdown
Collaborator

@ywkim1m ywkim1m left a comment

Choose a reason for hiding this comment

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

미션 수고하셨습니다!!

@KateteDeveloper
Copy link
Copy Markdown
Collaborator

미션 수고하셨습니다:)

Copy link
Copy Markdown
Member

@yangjiae12 yangjiae12 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~ dto만 record로 통일시키면 좋을 것 같아요

Comment on lines +34 to +46
List<MissionResDto.MissionDto> missions = slice.getContent().stream()
.map(um -> MissionResDto.MissionDto.builder()
.missionId(um.getMission().getId())
.title(um.getMission().getBody())
.point(um.getMission().getAward())
.status(um.getStatus())
.build())
.toList();

return MissionResDto.MissionListResDto.builder()
.missions(missions)
.hasNext(slice.hasNext())
.build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

비스 계층은 비즈니스 흐름을 제어하는 데 집중해야 하며, 객체 간 변환은 별도의 Converter 클래스로 위임하는 것이 좋습니다!

Comment on lines +27 to +28
User user = userRepository.findById(1L)
.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 유저입니다."));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

앞선 주차에 정의한 도메인별 Custom Exception를 활용하여 에러를 던지면 좋을 거 같아요

.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 유저입니다."));

MissionStatus missionStatus = MissionStatus.valueOf(status);
Slice<UserMission> slice = userMissionRepository.findByUserAndStatus(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Page 대신 Slice를 사용한 점이 좋은 것 같습니다! 이는 전체 데이터 개수를 세는 COUNT 쿼리를 생략할 수 있어, 데이터 양이 많아질수록 성능상 이점이 큽니다. 무한 스크롤 UI를 고려했을 때 적절한 선택이에요👍

Comment on lines +51 to +57
UserMission userMission = userMissionRepository.findById(userMissionId)
.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 미션입니다."));
userMission.complete();
return MissionResDto.MissionSuccessResDto.builder()
.missionId(userMission.getMission().getId())
.completedAt(userMission.getCompletedAt())
.build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

여기도 위와 같이 똑같이 수정해주세요!

Comment on lines +25 to +32
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class MissionListResDto {
private List<MissionDto> missions;
private Boolean hasNext;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

모든 도메인에서 공용으로 사용할 수 있는 페이징 DTO를 만들어 활용하면 좋을 거 같습니다!

Comment on lines +33 to +44
Review review = Review.builder()
.body(request.content())
.grade(request.rating())
.restaurant(restaurant)
.user(user)
.build();

Review saved = reviewRepository.save(review);
return ReviewResDto.CreateReviewResDto.builder()
.reviewId(saved.getId())
.createdAt(saved.getDate().atStartOfDay())
.build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

이전에 말한 것처럼 Converter로 분리해주시면 됩니다~


@Tag(name = "User", description = "유저 관련 API")
@RestController
@RequestMapping("/api")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

다른 도메인과 동일하게 /api/(도메인)의 형태로 쓰면 좋을 거 같습니다

Comment on lines +8 to +13
public static class SignupReqDto {
private String name;
private String email;
private String password;
private String phone;
private String address;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

각 dto에 제약조건을 걸면 좋을 것 같습니다!

Comment on lines +19 to +29
User user = User.builder()
.name(request.getName())
.email(request.getEmail())
.phone(request.getPhone())
.address(request.getAddress())
.build();
User saved = userRepository.save(user);
return UserResDto.SignupResDto.builder()
.userId(saved.getId())
.createdAt(saved.getCreatedAt())
.build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

이 부분도 컨버터로 분리해주세요!

Comment on lines +19 to +31
// Member
MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER4001", "사용자를 찾을 수 없음"),
MEMBER_ALREADY_EXISTS(HttpStatus.BAD_REQUEST, "MEMBER4002", "이미 존재하는 회원임"),

// Mission
MISSION_NOT_FOUND(HttpStatus.NOT_FOUND, "MISSION4001", "미션을 찾을 수 없음"),
MISSION_ALREADY_COMPLETED(HttpStatus.BAD_REQUEST, "MISSION4002", "이미 완료된 미션"),

// Review
REVIEW_NOT_FOUND(HttpStatus.NOT_FOUND, "REVIEW4001", "리뷰를 찾을 수 없음"),

// Home
REGION_NOT_FOUND(HttpStatus.NOT_FOUND, "HOME4001", "해당 지역을 찾을 수 없음");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

도메인별로 에러 핸들링하고 있기 때문에 해당 파일이 아닌 도메인별 ErrorStatus를 활용해주시면 될 것 같습니다

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.

5 participants