-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 8주차 미션 #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] 8주차 미션 #11
Conversation
ggamnunq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good
| List<UserPrefer> userPreferList = dto.preferCategory().stream() | ||
| .map(id -> { | ||
| // 선호 카테고리 존재 여부 검증 | ||
| PreferCategory preferCategory = preferCategoryRepository.findById(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런거는 메서드로 따로 빼둬도 될듯요? (취향차이이긴 함)
| .collect(Collectors.toList()); | ||
|
|
||
| // 모든 선호 음식 추가: DB 적용 | ||
| userPreferRepository.saveAll(userPreferList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스터디 때도 말했지만, 한 번에 많은 데이터 저장할 때 다량의 insert 쿼리 발생하는거 조심
| @RequiredArgsConstructor | ||
| public class MissionExistValidator implements ConstraintValidator<ExistMissions, Long> { | ||
|
|
||
| private final MissionRepository missionRepository; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repository 코드에는 웬만하면 service에서만 접근하게 하도록 하면 좋습니다.
관련 이슈
closed #10
작업한 내용
1. 가게 생성 API 구현
POST /api/v1/storesStoreReqDTO.CreateStoreDTOstoreName: 가게명storeAddress: 가게 주소storeType: 가게 유형 (Enum: KOREAN, CHINESE, JAPANESE, WESTERN, CHICKEN, SNACK, MEAT, DOSIRAK, YASICK, DESSERT, FAST_FOOD, ASIAN, ETC)regionName: 지역 이름StoreResDTO.CreateStoreDTOstoreId: 생성된 가게 IDcreatedAt: 생성 시간StoreController: REST API 엔드포인트 제공StoreCommandService/StoreCommandServiceImpl: 비즈니스 로직 처리StoreConverter: DTO ↔ Entity 변환StoreRepository: JPA RepositoryStoreSuccessCode.STORE_CREATED: 성공 응답 코드2. 가게 리뷰 추가 API 구현
POST /api/v1/reviewsReviewReqDTO.CreateReviewDTOstoreId: 가게 ID (Long,@ExistStoresValidation 적용)reviewText: 리뷰 내용score: 별점 (BigDecimal)ReviewResDTO.CreateReviewDTOreviewId: 생성된 리뷰 IDcreatedAt: 생성 시간ReviewController: REST API 엔드포인트 제공ReviewCommandService/ReviewCommandServiceImpl: 비즈니스 로직 처리ReviewConverter: DTO ↔ Entity 변환ReviewRepository: JPA RepositoryReviewSuccessCode.REVIEW_CREATED: 성공 응답 코드@ExistStores커스텀 Validation으로 가게 존재 여부를 자동 검증합니다3. 가게 미션 추가 API 구현
POST /api/v1/missionsMissionReqDTO.CreateMissionDTOstoreId: 가게 ID (Long,@ExistStoresValidation 적용)region: 지역 (Enum: SEOUL, BUSAN, DAEGU, INCHEON, GWANGJU, DAEJEON, ULSAN, GYEONGGI, GANGWON, CHUNGBUK, CHUNGNAM, JEONBUK, JEONNAM, GYEONGBUK, GYEONGNAM, JEJU)missionMoney: 미션 보상 금액 (Long)missionPoint: 미션 보상 포인트 (Long)MissionResDTO.CreateMissionDTOmissionId: 생성된 미션 IDcreatedAt: 생성 시간MissionController: REST API 엔드포인트 제공MissionCommandService/MissionCommandServiceImpl: 비즈니스 로직 처리MissionConverter: DTO ↔ Entity 변환MissionRepository: JPA RepositoryMissionSuccessCode.MISSION_CREATED: 성공 응답 코드@ExistStores커스텀 Validation으로 가게 존재 여부를 자동 검증합니다4. 도전 중인 미션에 추가 API 구현
POST /api/v1/missions/challengeMissionReqDTO.ChallengeMissionDTOmissionId: 미션 ID (Long,@ExistMissionsValidation 적용)MissionResDTO.ChallengeMissionDTOchallengeMissionId: 생성된 도전 미션 IDcreatedAt: 생성 시간MissionController: REST API 엔드포인트 제공MissionCommandService/MissionCommandServiceImpl: 비즈니스 로직 처리MissionConverter: DTO ↔ Entity 변환UserMissionRepository: JPA RepositoryMissionSuccessCode.MISSION_CHALLENGED: 성공 응답 코드@ExistMissions커스텀 Validation으로 미션 존재 여부를 자동 검증합니다UserMission엔티티에 저장합니다5. 회원가입 API 구현
POST /api/v1/members/signupMemberReqDTO.JoinDTOname: 회원 이름gender: 성별 (Enum: NONE, MALE, FEMALE)birth: 생년월일 (LocalDate)address: 주소specAddress: 상세 주소preferCategory: 선호 카테고리 ID 리스트 (List)MemberResDTO.JoinDTOmemberId: 생성된 회원 IDcreatedAt: 생성 시간MemberController: REST API 엔드포인트 제공MemberCommandService/MemberCommandServiceImpl: 비즈니스 로직 처리MemberConverter: DTO ↔ Entity 변환MemberRepository: JPA RepositoryUserPreferRepository: 선호 카테고리 저장용 RepositoryPreferCategoryRepository: 선호 카테고리 조회용 RepositoryMemberSuccessCode.MEMBER_CREATED: 성공 응답 코드CategoryException을 발생시킵니다@Transactional을 통해 회원 생성과 선호 카테고리 저장을 하나의 트랜잭션으로 처리합니다6. Swagger Config 구현
SwaggerConfig.javahttp://localhost:8080/swagger-ui/index.html7. 커스텀 Validation 어노테이션 구현
ReviewReqDTO.CreateReviewDTO.storeId,MissionReqDTO.CreateMissionDTO.storeIdStoreExistValidatorStoreErrorCode.STORE_NOT_FOUNDMissionReqDTO.ChallengeMissionDTO.missionIdMissionExistValidatorMissionErrorCode.MISSION_NOT_FOUND@Constraint(validatedBy = ...)어노테이션 정의ConstraintValidator인터페이스 구현PR Point 및 참고사항, 스크린샷
핵심 구현 사항
워크북 패턴 준수:
record사용 (ReqDTO, ResDTO)@Valid사용,ApiResponse.onSuccess()사용트랜잭션 관리:
@Transactional적용Validation 전략:
에러 처리:
StoreException,ReviewException,MissionException,MemberException,CategoryException)GlobalExceptionHandler를 통한 통일된 에러 응답참고사항
@Valid어노테이션을 통해 요청 데이터 검증을 수행합니다@ExistStores,@ExistMissions)을 통해 DB 존재 여부를 자동 검증합니다