-
Notifications
You must be signed in to change notification settings - Fork 0
[Release] v2.0.3 릴리즈 #219
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
[Release] v2.0.3 릴리즈 #219
Changes from all commits
dc8d0b6
693d801
8971e2c
493f4b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| package ssu.eatssu.domain.user.department.persistence; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import ssu.eatssu.domain.user.department.entity.College; | ||
| import ssu.eatssu.domain.user.department.entity.Department; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface DepartmentRepository extends JpaRepository<Department, Long> { | ||
| Optional<Department> findByName(String name); | ||
|
|
||
| List<Department> findByCollege(College college); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,24 @@ | ||
| package ssu.eatssu.domain.user.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.Builder; | ||
| import ssu.eatssu.domain.user.department.entity.College; | ||
| import ssu.eatssu.domain.user.department.entity.Department; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public class DepartmentResponse { | ||
| private String departmentName; | ||
| @Builder | ||
| public record DepartmentResponse( | ||
| Long departmentId, String departmentName, Long collegeId, String collegeName | ||
| ) { | ||
| public static DepartmentResponse from(Department department) { | ||
| if (department == null) { | ||
| return new DepartmentResponse(null, null, null, null); | ||
| } | ||
| final College college = department.getCollege(); | ||
| return DepartmentResponse.builder() | ||
| .departmentId(department.getId()) | ||
| .departmentName(department.getName()) | ||
| .collegeId(college != null ? college.getId() : null) | ||
| .collegeName(college != null ? college.getName() : null) | ||
| .build(); | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package ssu.eatssu.domain.user.dto; | ||
|
|
||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record GetCollegeResponse( | ||
| Long id, | ||
| String name | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package ssu.eatssu.domain.user.dto; | ||
|
|
||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record GetDepartmentResponse(Long id, | ||
| String name) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,13 @@ | |
| import ssu.eatssu.domain.auth.security.CustomUserDetails; | ||
| import ssu.eatssu.domain.partnership.dto.PartnershipResponse; | ||
| import ssu.eatssu.domain.partnership.service.PartnershipService; | ||
| import ssu.eatssu.domain.review.service.ReviewServiceV2; | ||
| import ssu.eatssu.domain.slice.dto.SliceResponse; | ||
| import ssu.eatssu.domain.slice.service.SliceService; | ||
| import ssu.eatssu.domain.user.dto.DepartmentResponse; | ||
| import ssu.eatssu.domain.user.dto.GetCollegeResponse; | ||
| import ssu.eatssu.domain.user.dto.GetDepartmentResponse; | ||
| import ssu.eatssu.domain.user.dto.MyMealReviewResponse; | ||
| import ssu.eatssu.domain.user.dto.MyPageResponse; | ||
| import ssu.eatssu.domain.user.dto.MyReviewDetail; | ||
| import ssu.eatssu.domain.user.dto.NicknameUpdateRequest; | ||
|
|
@@ -48,6 +52,7 @@ public class UserController { | |
| private final UserService userService; | ||
| private final SliceService sliceService; | ||
| private final PartnershipService partnershipService; | ||
| private final ReviewServiceV2 reviewServiceV2; | ||
|
|
||
| @Operation(summary = "이메일 중복 체크", description = """ | ||
| 이메일 중복 체크 API 입니다.<br><br> | ||
|
|
@@ -180,4 +185,42 @@ public BaseResponse<List<PartnershipResponse>> getUserDepartmentPartnerships( | |
| public BaseResponse<DepartmentResponse> getDepartment(@AuthenticationPrincipal CustomUserDetails userDetails) { | ||
| return BaseResponse.success(userService.getDepartment(userDetails)); | ||
| } | ||
|
|
||
| @Operation(summary = "내가 쓴 리뷰 리스트 조회", description = "내가 쓴 리뷰 리스트를 조회하는 API V2 입니다.") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "내가 쓴 리뷰 리스트 조회 성공"), | ||
| @ApiResponse(responseCode = "404", description = "존재하지 않는 유저", content = @Content(schema = @Schema(implementation = BaseResponse.class))) | ||
| }) | ||
| @GetMapping("/v2/reviews") | ||
| public BaseResponse<SliceResponse<MyMealReviewResponse>> getMyReviews( | ||
| @Parameter(description = "마지막으로 조회된 reviewId값(첫 조회시 값 필요 없음)", in = ParameterIn.QUERY) @RequestParam(required = false) Long lastReviewId, | ||
| @ParameterObject @PageableDefault(size = 20, sort = "date", direction = Sort.Direction.DESC) Pageable pageable, | ||
| @AuthenticationPrincipal CustomUserDetails customUserDetails) { | ||
| SliceResponse<MyMealReviewResponse> myReviews = reviewServiceV2.findMyReviews(customUserDetails, | ||
| lastReviewId, | ||
| pageable); | ||
| return BaseResponse.success(myReviews); | ||
| } | ||
|
|
||
| @Operation(summary = "단과대 조회", description = "숭실대학교 단과대학 들을 조회하는 API입니다.(토큰 불필요)") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "단과대 리스트 조회 성공"), | ||
| @ApiResponse(responseCode = "404", description = "존재하지 않는 단과대", content = @Content(schema = @Schema(implementation = BaseResponse.class))) | ||
| }) | ||
| @GetMapping("/lookup/colleges") | ||
| public BaseResponse<List<GetCollegeResponse>> getColleges() { | ||
| List<GetCollegeResponse> getCollegeResponses = userService.getCollegeList(); | ||
| return BaseResponse.success(getCollegeResponses); | ||
| } | ||
|
|
||
| @Operation(summary = "단과대에 따른 학과 조회", description = "단과대학을 입력하면 단과대에 속한 숭실대학교 학과를 조회하는 API입니다.(토큰 불필요)") | ||
| @ApiResponses(value = { | ||
| @ApiResponse(responseCode = "200", description = "단과대 리스트 조회 성공"), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swagger 문서의 @ApiResponse(responseCode = "200", description = "단과대 리스트 조회 성공"),
@ApiResponse(responseCode = "400", description = "존재하지 않는 단과대 ID", content = @Content(schema = @Schema(implementation = BaseResponse.class))) |
||
| }) | ||
| @GetMapping("/lookup/departments") | ||
| public BaseResponse<List<GetDepartmentResponse>> getDepartments(@RequestParam Long collegeId) { | ||
| List<GetDepartmentResponse> getCollegeResponses = userService.getDepartmentList(collegeId); | ||
| return BaseResponse.success(getCollegeResponses); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,6 @@ public interface UserRepository extends JpaRepository<User, Long> { | |
| Optional<User> findByEmail(String email); | ||
|
|
||
| Optional<User> findByProviderId(String providerId); | ||
|
|
||
| Optional<User> findByNickname(String nickname); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,21 +10,27 @@ | |||||
| import ssu.eatssu.domain.auth.security.CustomUserDetails; | ||||||
| import ssu.eatssu.domain.review.entity.Review; | ||||||
| import ssu.eatssu.domain.user.config.UserProperties; | ||||||
| import ssu.eatssu.domain.user.department.entity.College; | ||||||
| import ssu.eatssu.domain.user.department.entity.Department; | ||||||
| import ssu.eatssu.domain.user.department.persistence.CollegeRepository; | ||||||
| import ssu.eatssu.domain.user.department.persistence.DepartmentRepository; | ||||||
| import ssu.eatssu.domain.user.dto.DepartmentResponse; | ||||||
| import ssu.eatssu.domain.user.dto.GetCollegeResponse; | ||||||
| import ssu.eatssu.domain.user.dto.GetDepartmentResponse; | ||||||
| import ssu.eatssu.domain.user.dto.MyPageResponse; | ||||||
| import ssu.eatssu.domain.user.dto.NicknameUpdateRequest; | ||||||
| import ssu.eatssu.domain.user.dto.UpdateDepartmentRequest; | ||||||
| import ssu.eatssu.domain.user.entity.User; | ||||||
| import ssu.eatssu.domain.user.repository.UserRepository; | ||||||
| import ssu.eatssu.global.handler.response.BaseException; | ||||||
|
|
||||||
| import java.util.List; | ||||||
| import java.util.UUID; | ||||||
|
|
||||||
| import static ssu.eatssu.global.handler.response.BaseResponseStatus.DUPLICATE_NICKNAME; | ||||||
| import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_DEPARTMENT; | ||||||
| import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_USER; | ||||||
| import static ssu.eatssu.global.handler.response.BaseResponseStatus.VALIDATION_ERROR; | ||||||
|
|
||||||
| @Slf4j | ||||||
| @Service | ||||||
|
|
@@ -37,6 +43,7 @@ public class UserService { | |||||
| private final PasswordEncoder passwordEncoder; | ||||||
| private final DepartmentRepository departmentRepository; | ||||||
| private final UserProperties userProperties; | ||||||
| private final CollegeRepository collegeRepository; | ||||||
|
|
||||||
| public User join(String email, OAuthProvider provider, String providerId) { | ||||||
| String credentials = createCredentials(provider, providerId); | ||||||
|
|
@@ -59,7 +66,7 @@ public void updateNickname(CustomUserDetails userDetails, NicknameUpdateRequest | |||||
| public MyPageResponse findMyPage(CustomUserDetails userDetails) { | ||||||
| User user = userRepository.findById(userDetails.getId()) | ||||||
| .orElseThrow(() -> new BaseException(NOT_FOUND_USER)); | ||||||
| return new MyPageResponse(user.getNickname(), user.getProvider()); | ||||||
| return MyPageResponse.from(user); | ||||||
| } | ||||||
|
|
||||||
| public boolean withdraw(CustomUserDetails userDetails) { | ||||||
|
|
@@ -98,7 +105,7 @@ private String createCredentials(OAuthProvider provider, String providerId) { | |||||
| public void registerDepartment(UpdateDepartmentRequest request, CustomUserDetails userDetails) { | ||||||
| User user = userRepository.findById(userDetails.getId()) | ||||||
| .orElseThrow(() -> new BaseException(NOT_FOUND_USER)); | ||||||
| Department department = departmentRepository.findByName(request.getDepartmentName()) | ||||||
| Department department = departmentRepository.findById(request.getDepartmentId()) | ||||||
| .orElseThrow(() -> new BaseException(NOT_FOUND_DEPARTMENT)); | ||||||
|
|
||||||
| user.updateDepartment(department); | ||||||
|
|
@@ -107,8 +114,27 @@ public void registerDepartment(UpdateDepartmentRequest request, CustomUserDetail | |||||
| public DepartmentResponse getDepartment(CustomUserDetails userDetails) { | ||||||
| User user = userRepository.findById(userDetails.getId()) | ||||||
| .orElseThrow(() -> new BaseException(NOT_FOUND_USER)); | ||||||
| Department department = user.getDepartment(); | ||||||
| return new DepartmentResponse(department != null ? department.getName() : ""); | ||||||
| return DepartmentResponse.from(user.getDepartment()); | ||||||
| } | ||||||
|
|
||||||
| public List<GetCollegeResponse> getCollegeList() { | ||||||
| List<College> colleges = collegeRepository.findAll(); | ||||||
| return colleges.stream().map(college -> GetCollegeResponse.builder() | ||||||
| .id(college.getId()) | ||||||
| .name(college.getName()) | ||||||
| .build()) | ||||||
| .toList(); | ||||||
| } | ||||||
|
|
||||||
| public List<GetDepartmentResponse> getDepartmentList(Long collegeId) { | ||||||
| College college = collegeRepository.findById(collegeId) | ||||||
| .orElseThrow(() -> new BaseException(VALIDATION_ERROR)); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| List<Department> departments = departmentRepository.findByCollege(college); | ||||||
| return departments.stream().map(department -> GetDepartmentResponse.builder() | ||||||
| .id(department.getId()) | ||||||
| .name(department.getName()) | ||||||
| .build()) | ||||||
| .toList(); | ||||||
| } | ||||||
|
|
||||||
| private boolean isForbiddenNickname(String nickname) { | ||||||
|
|
||||||
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.
Swagger 문서의
getCollegesAPI 응답 코드가 실제 구현과 다릅니다.userService.getCollegeList()는collegeRepository.findAll()을 호출하며, 결과가 없으면 빈 리스트를 반환하고 예외를 던지지 않습니다. 따라서 404 응답은 발생하지 않습니다. 혼동을 피하기 위해 404 관련@ApiResponse를 제거하는 것이 좋습니다.