Skip to content

6주차 미션 [카카]#9

Open
KateteDeveloper wants to merge 14 commits into
mainfrom
kaka/week6
Open

6주차 미션 [카카]#9
KateteDeveloper wants to merge 14 commits into
mainfrom
kaka/week6

Conversation

@KateteDeveloper
Copy link
Copy Markdown
Collaborator

📌 구현 결과

구현한 API 목록

1. 마이페이지 조회

  • GET /auth/v1/users/me?id={memberId}
  • 사용자 이름, 프로필 URL, 이메일, 휴대폰 번호, 포인트 반환
  • image

2. 내 미션 목록 조회 (진행중 + 진행완료)

  • GET /mission/v1/missions
  • Header: Authorization (memberId 임시)
  • CHALLENGING, COMPLETE 상태 필터링
  • 커서 기반 페이징 적용
  • image

3. 홈 화면 지역별 미션 목록 조회

  • GET /home/v1/missions?locationId={id}&page=0&size=10
  • 선택된 지역(Location)에서 도전 가능한 미션 목록
  • @query JOIN FETCH로 Store → Location 조인
  • 페이징 적용
  • image

4. 리뷰 작성

  • POST /review/v1/create/{storeId}
  • 가게에 별점 + 내용으로 리뷰 작성
  • image

refactor: DTO 클래스를 record 타입으로 변환 및 Enum 상수 추가

- Home, Mission, Member, Review 도메인의 DTO 클래스(@Getter, @builder)를 Java record로 리팩토링
- DTO 내부 클래스의 불필요한 'Class' 접미사 제거 (예: MyDataReqClass -> MyDataReq)
- Controller, Service, Converter 계층에 record 타입 변경 사항(생성자 및 접근자) 반영
- Gender, Term, SocialType Enum에 필요한 상수(MALE, FEMALE, REQUIRED, OPTIONAL 등) 추가
```
```text
refactor: 리뷰 생성 API 수정 (marketId PathVariable 적용 및 ID 타입 Long 변경)
```

**Breakdown of the changes covered:**
* **Controller**: Updated the review creation endpoint to accept `marketId` as a `@PathVariable` (`/v1/create/{marketId}`).
* **DTO**: Removed `marketId` and `regionId` from `CreateReviewReq` since `marketId` is now handled via the URL path.
* **Entity**: Changed the data types of `marketId` and `regionId` in the `Review` entity from `Integer` to `Long`.
* **Service & Converter**: Updated methods to pass `marketId` from the controller down to the entity builder.
…based on your examples:

```text
feat: update CreateReviewRes DTO and ReviewConverter, remove regionId from Review entity
```

**Here is a quick breakdown of the specific changes mapped in this commit:**
* **`Review.java`**: Removed the `regionId` field and its corresponding column mapping.
* **`ReviewResDTO.java`**: Populated the `CreateReviewRes` record with `reviewId`, `stars`, and `content` fields (previously an empty record).
* **`ReviewConverter.java`**: Updated the `toCreateReview` method to properly map the `Review` entity data to the newly updated `CreateReviewRes` DTO instead of returning an empty object.
```text
feat: enhance domain entities, introduce BaseEntity, and configure JPA mappings
```

**Breakdown of the specific changes covered in this commit:**

* **Global**:
  * Introduced an abstract `BaseEntity` class with JPA auditing (`createdAt`, `updateAt`, `deleatedAt`) to unify and automate timestamp management across the application.
* **Member Domain**:
  * Updated the `Member` entity to extend `BaseEntity` and added new fields for `detailAddress`, `socialUid`, and `socialType`.
  * Configured `Food` and `Term` entities, along with `MemberFood` and `MemberTerm` mapping entities to establish many-to-many relationships with the user.
  * Created the `FoodName` enum and updated the `Term` enum with new constants (AGE, SERVICE, PRIVACY, LOCATION, MARKETING).
* **Review Domain**:
  * Created a new `Reply` entity (extending `BaseEntity`).
  * Updated the `Review` entity to include a `@OneToOne` relationship with `Reply` and changed its ID generation strategy to `IDENTITY`.
* **Mission Domain**:
  * Refactored the `Mission` entity to extend `BaseEntity`, stripping out redundant explicitly defined timestamp and status fields.
  * Created the `MemberMission` mapping entity to manage the many-to-many relationship between users and missions, accompanied by a new `MissionStatus` enum (`IDLE`, `CHALLENGING`, `COMPLETE`).
- `Review.java`: 불필요한 `marketId` 필드를 삭제하고 `Store` 엔티티와의 `@ManyToOne` 연관관계 추가
- `StoreRepository.java`, `MemberMissionRepository.java`: 엔티티 조회를 위한 JpaRepository 인터페이스 신규 추가
- `ReviewService.java`, `ReviewConverter.java`: 리뷰 생성 시 전달받은 `storeId`로 `Store` 엔티티를 직접 조회하여 객체에 매핑하도록 로직 수정
- `MissionService.java`, `MissionConverter.java`: 사용자 미션 목록 조회 기준을 `Mission` 엔티티에서 `MemberMission` 매핑 엔티티로 변경
- `MissionResDTO.java`: `MissionList` DTO 내 `status` 필드 타입을 `String`에서 `MissionStatus` Enum 클래스로 변경
```
- MemberController: 마이페이지 조회 API(`/v1/users/me`)의 HTTP 메서드를 POST에서 GET으로 변경하고, @RequestBody(DTO) 대신 @RequestParam으로 `id`를 받도록 수정
- MemberService: `getInfo` 메서드 파라미터를 `MemberReqDTO.GetInfo` 객체에서 `Long memberId`로 변경
- Member Entity: `socialType` 필드 타입을 String에서 `SocialType` Enum으로 변경
- Term Entity 및 Enum: 기존 `Term` Enum 클래스명을 `TermName`으로 변경하고 엔티티의 `name` 필드 타입에 반영
- MemberTerm, MemberFood Entity: 잘못 임포트된 Spring Data의 `@Id` 어노테이션을 JPA(`jakarta.persistence.Id`)로 수정 및 불필요한 import 제거
- MissionRepository: 사용하지 않는 `findByMemberId` 메서드 삭제
```
- `MemberMissionRepository`에 `@Query`를 사용한 `findByMemberIdAndStatusIn` 커스텀 쿼리 메서드 추가
- N+1 문제를 방지하기 위해 `Mission`과 `Store` 엔티티를 `JOIN FETCH`로 함께 조회하도록 쿼리 작성
- `MissionService.getMissions()` 메서드에서 진행 중(`CHALLENGING`)이거나 완료(`COMPLETE`)된 미션만 조회하도록 상태 조건 필터링 추가
- `PageRequest` 객체를 사용해 데이터베이스 단에서 페이징 처리가 이루어지도록 로직을 개선하고, `hasNext` 판별 로직 수정
```
…회 기능 추가

- HomeController: 미션 목록 조회 API(`/v1/missions`)에 특정 지역 필터링을 위한 `@RequestParam Long locationId` 파라미터 추가
- HomeService: 기존 전체 조회(findAll) 임시 로직을 제거하고, `Pageable`과 `locationId`를 활용해 해당 지역의 미션만 조회하도록 로직 변경
- HomeService: 다음 페이지 존재 여부(hasNext) 판단 기준을 `missions.size() == size`로 수정하여 페이지네이션 로직 개선
- MissionRepository: 스토어(store)와 위치(location) 정보를 페치 조인(JOIN FETCH)하여, 전달받은 `locationId`와 일치하는 미션 목록을 최신순(ORDER BY m.id DESC)으로 반환하는 `findByLocationId` 쿼리 메서드 추가
```
@ochyeon
Copy link
Copy Markdown
Collaborator

ochyeon commented May 7, 2026

수고하셨습니다!

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.

미션 수고하셨습니다!!

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.

수고하셨습니다!

Comment thread kaka/src/main/java/com/umc/umc10th/kaka/domain/home/service/HomeService.java Outdated
Comment thread kaka/src/main/java/com/umc/umc10th/kaka/domain/home/service/HomeService.java Outdated
Comment thread kaka/src/main/java/com/umc/umc10th/kaka/domain/member/service/MemberService.java Outdated
Comment thread kaka/src/main/java/com/umc/umc10th/kaka/domain/member/service/MemberService.java Outdated
Comment thread kaka/src/main/java/com/umc/umc10th/kaka/domain/review/service/ReviewService.java Outdated
- MissionRepository의 findByLocationId 메서드 반환 타입을 List에서 Slice로 변경
- HomeService의 getMissions 메서드에서 리스트 크기로 다음 페이지 존재 여부를 수동 계산하던 방식을 Slice의 hasNext() 메서드를 활용하도록 수정
```
- HomeService의 getMyData 메서드 내 임시로 사용하던 RuntimeException("멤버 없음")을 커스텀 예외인 MemberException으로 교체
- 예외 발생 시 MemberErrorCode.MEMBER_NOT_FOUND 에러 코드를 사용하도록 수정
```
- SignUpReqDTO의 SignUpReqBody 레코드 내 필드에 @notblank, @Email, @pattern, @NotNull 등 유효성 검증 어노테이션 추가
- MemberController의 getSignUp 엔드포인트에서 요청 객체를 검증하도록 @Valid 어노테이션 적용
- MemberService에 있던 Member 엔티티 빌더 생성 로직을 MemberConverter.toMember()로 이동하여 계층 역할 분리
- MissionConverter.toCompleteMission() 응답 시 하드코딩된 완료 메시지를 Service 단에서 파라미터로 전달받도록 메서드 시그니처 수정
```
- MemberMissionRepository: findByMemberIdAndStatusIn 메서드 반환 타입을 List에서 Slice로 변경
- MissionService: Slice 객체의 hasNext()를 활용하도록 페이징 처리 로직 수정
- MissionService: completeMission() 수행 시 완료 상태(COMPLETE)의 MemberMission을 DB에 저장하는 로직 추가
- MissionService: 하드코딩된 성공 응답 메시지를 MissionSuccessCode.OK 상수 값으로 대체
- MissionConverter: Mission 엔티티를 MemberMission으로 변환하는 toMemberMission() 메서드 추가
- Store: location 필드의 @manytoone 연관관계에 지연 로딩(FetchType.LAZY) 속성 적용
```
- mission 패키지에 위치하던 Store 관련 클래스(Store, Location, StoreRepository)를 store 패키지로 이동 및 관련 import 구문 수정
- ReviewReqDTO.CreateReviewReq DTO에 커스텀 별점 검증(@ValidStars) 및 내용 글자 수 검증(@notblank, @SiZe) 어노테이션 추가
- 별점 입력을 0.5 단위, 0.5~5.0 범위로 검증하는 커스텀 어노테이션(@ValidStars) 및 검증 로직(ValidStarsValidator) 추가
- Review 엔티티에 Member 엔티티와의 @manytoone 연관관계(member_id) 매핑 추가
- Store 전용 커스텀 예외(StoreException) 및 에러 코드(StoreErrorCode)를 추가하고, ReviewService의 Store 조회 로직에 적용
```
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.

4 participants