-
Notifications
You must be signed in to change notification settings - Fork 3
[feature] 동아리 한글 표시 이름 추가 -BE #1206
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
Merged
+51
−2
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
426cf0b
feat: @동아리 이름으로 요청받는 컨트롤러 추가
lepitaaar acc2d9c
feat: 동아리 이름 기반으로 동아리 상세정보 조회기능 추가
lepitaaar 6cf8397
feat: 동아리 이름 중복방지
lepitaaar 67e7dbc
fix: partialFilter 지원하지않은 표현식 수정
lepitaaar 6776fc5
feat: 동아리 이름으로 검색 controller endpoint 추가
lepitaaar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import moadong.user.payload.CustomUserDetails; | ||
| import org.bson.types.ObjectId; | ||
| import org.javers.core.Javers; | ||
| import org.springframework.dao.DuplicateKeyException; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
|
|
@@ -42,8 +43,9 @@ public class ClubProfileService { | |
| public void updateClubInfo(ClubInfoRequest request, CustomUserDetails user) { | ||
| Club club = clubRepository.findClubByUserId(user.getId()) | ||
| .orElseThrow(() -> new RestApiException(ErrorCode.CLUB_NOT_FOUND)); | ||
| validateClubNameUnique(club.getId(), request.name()); | ||
| club.update(request); | ||
| Club saved = clubRepository.save(club); | ||
| Club saved = saveClub(club); | ||
| javers.commit(user.getUsername(), saved); | ||
| } | ||
|
|
||
|
|
@@ -94,13 +96,24 @@ public ClubDetailedResponse getClubDetail(String clubId) { | |
| return new ClubDetailedResponse(clubDetailedResult); | ||
| } | ||
|
|
||
| public ClubDetailedResponse getClubDetailByClubName(String clubName) { | ||
| Club club = clubRepository.findClubByName(clubName) | ||
| .orElseThrow(() -> new RestApiException(ErrorCode.CLUB_NOT_FOUND)); | ||
|
|
||
| ClubDetailedResult clubDetailedResult = ClubDetailedResult.of( | ||
| club | ||
| ); | ||
| return new ClubDetailedResponse(clubDetailedResult); | ||
| } | ||
|
|
||
| @Transactional | ||
| public void updateClubInfoByClubId(String clubId, ClubInfoRequest request, CustomUserDetails user) { | ||
| ObjectId objectId = ObjectIdConverter.convertString(clubId); | ||
| Club club = clubRepository.findClubById(objectId) | ||
| .orElseThrow(() -> new RestApiException(ErrorCode.CLUB_NOT_FOUND)); | ||
| validateClubNameUnique(club.getId(), request.name()); | ||
| club.update(request); | ||
| Club saved = clubRepository.save(club); | ||
| Club saved = saveClub(club); | ||
| javers.commit(user.getUsername(), saved); | ||
| } | ||
|
|
||
|
|
@@ -128,4 +141,23 @@ public void updateClubRecruitmentInfoByClubId(String clubId, ClubRecruitmentInfo | |
| ); | ||
| } | ||
| } | ||
|
|
||
| private void validateClubNameUnique(String clubId, String name) { | ||
| if (name == null || name.isBlank()) { | ||
| return; | ||
| } | ||
|
|
||
| if (clubRepository.existsByNameAndIdNot(name, clubId)) { | ||
| throw new RestApiException(ErrorCode.CLUB_NAME_ALREADY_EXISTS); | ||
| } | ||
| } | ||
|
|
||
| // 레이스 컨디션을 위한 시큐어 코딩 | ||
| private Club saveClub(Club club) { | ||
| try { | ||
| return clubRepository.save(club); | ||
| } catch (DuplicateKeyException e) { | ||
| throw new RestApiException(ErrorCode.CLUB_NAME_ALREADY_EXISTS); | ||
| } | ||
|
Comment on lines
+156
to
+161
Member
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. DB 에서 막음으로써 레이스컨디션을 방지한것 좋습니다 |
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
이름이 비어있지 않은것만 만들겠다는 뜻이군요 굳굳