-
Notifications
You must be signed in to change notification settings - Fork 0
[Release] v2.0.2 릴리즈 #217
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.2 릴리즈 #217
Changes from all commits
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 = "단과대 리스트 조회 성공"), | ||||||||||
| }) | ||||||||||
| @GetMapping("/lookup/departments") | ||||||||||
| public BaseResponse<List<GetDepartmentResponse>> getDepartments(@RequestParam Long collegeId) { | ||||||||||
| List<GetDepartmentResponse> getCollegeResponses = userService.getDepartmentList(collegeId); | ||||||||||
| return BaseResponse.success(getCollegeResponses); | ||||||||||
|
Comment on lines
+222
to
+223
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
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| } | ||||||||||
| 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(); | ||
|
Comment on lines
+122
to
+126
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. |
||
| } | ||
|
|
||
| public List<GetDepartmentResponse> getDepartmentList(Long collegeId) { | ||
| College college = collegeRepository.findById(collegeId) | ||
| .orElseThrow(() -> new BaseException(VALIDATION_ERROR)); | ||
|
Comment on lines
+130
to
+131
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.
College college = collegeRepository.findById(collegeId)
.orElseThrow(() -> new BaseException(NOT_FOUND_COLLEGE)); |
||
| List<Department> departments = departmentRepository.findByCollege(college); | ||
| return departments.stream().map(department -> GetDepartmentResponse.builder() | ||
| .id(department.getId()) | ||
| .name(department.getName()) | ||
| .build()) | ||
| .toList(); | ||
|
Comment on lines
+133
to
+137
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. |
||
| } | ||
|
|
||
| private boolean isForbiddenNickname(String nickname) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -59,6 +59,7 @@ public enum BaseResponseStatus { | |||||
| NOT_FOUND_DEPARTMENT(false, HttpStatus.NOT_FOUND, 40409, "해당 학과를 찾을 수 없습니다."), | ||||||
| NOT_FOUND_PARTNERSHIP(false, HttpStatus.NOT_FOUND, 40410, "해당 제휴를 찾을 수 없습니다."), | ||||||
| NOT_FOUND_PARTNERSHIP_RESTAURANT(false, HttpStatus.NOT_FOUND, 40411, "해당 제휴 식당을 찾을 수 없습니다."), | ||||||
| INVALID_NICKNAME(false,HttpStatus.NOT_FOUND,40412,"잘못된 닉네임입니다."), | ||||||
|
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
|
||||||
|
|
||||||
| /** | ||||||
| * 405 METHOD_NOT_ALLOWED 지원하지 않은 method 호출 | ||||||
|
|
||||||
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.
from정적 팩토리 메서드 내에서department와college객체의 null 여부를 확인하고 값을 할당하는 로직이 여러 번 반복되고 있습니다. 이 로직을 개선하여 코드의 가독성과 유지보수성을 높일 수 있습니다.if문을 사용하여 null 체크를 한 번만 수행하고, 빌더에 값을 설정하는 방식으로 리팩토링하는 것을 제안합니다.