Skip to content

Commit

Permalink
fix: category update 에러 & group user 검색 예외 처리 (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
baebae02 authored Mar 24, 2024
2 parents db1e2e2 + 6b77385 commit 537d8b8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ public ApiResponseDto<?> deleteGroup(
@GetMapping("/{groupId}/member/search")
public ApiResponseDto<List<GroupMemberResponseDto>> searchGroupMembers(
@PathVariable Long groupId,
@Parameter(hidden = true) @AuthenticationPrincipal User user,
@RequestParam(required = false) String name) {
return ApiResponseDto.success(SuccessStatus.GET_MEMBER_LIST_SUCCESS,
groupService.searchGroupMembers(groupId, name));
groupService.searchGroupMembers(groupId, name, user.getUsername()));
}

@Operation(summary = "그룹 알림 설정")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import com.uspray.uspray.DTO.group.response.GroupMemberResponseDto;
import com.uspray.uspray.DTO.group.response.GroupResponseDto;

import java.util.List;

public interface GroupRepositoryCustom {

List<GroupResponseDto> findGroupListByMemberId(String userId);

List<GroupMemberResponseDto> findGroupMembersByGroupAndNameLike(Long groupId, String name);
List<GroupMemberResponseDto> findGroupMembersByGroupAndNameLikeExceptUser(Long groupId,
String name, String username);

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public List<GroupResponseDto> findGroupListByMemberId(String userId) {
}

@Override
public List<GroupMemberResponseDto> findGroupMembersByGroupAndNameLike(Long groupId,
String name) {
public List<GroupMemberResponseDto> findGroupMembersByGroupAndNameLikeExceptUser(Long groupId,
String name, String username) {

BooleanBuilder builder = new BooleanBuilder();

Expand All @@ -65,6 +65,7 @@ public List<GroupMemberResponseDto> findGroupMembersByGroupAndNameLike(Long grou
.from(member)
.join(member.groupMemberList, groupMember)
.where(builder)
.where(member.userId.ne(username))
.fetch();
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/uspray/uspray/service/CategoryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ public CategoryResponseDto updateCategory(String username, Long categoryId,
CategoryRequestDto categoryRequestDto) {
Category category = categoryRepository.getCategoryByIdAndMember(categoryId,
memberRepository.getMemberByUserId(username));
categoryRepository.checkDuplicate(categoryRequestDto.getName(), category.getMember(),
CategoryType.valueOf(categoryRequestDto.getType().toUpperCase()));
if (categoryRequestDto.getName() != null) {
categoryRepository.checkDuplicate(categoryRequestDto.getName(), category.getMember(),
CategoryType.valueOf(categoryRequestDto.getType().toUpperCase()));
}
category.update(categoryRequestDto);
return CategoryResponseDto.of(category);
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/uspray/uspray/service/GroupService.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public GroupListResponseDto getGroupList(String username) {
}

@Transactional(readOnly = true)
public List<GroupMemberResponseDto> searchGroupMembers(Long groupId, String name) {
List<GroupMemberResponseDto> groupMemberResponseDtoList = groupRepository.findGroupMembersByGroupAndNameLike(
groupId, name);
public List<GroupMemberResponseDto> searchGroupMembers(Long groupId, String targetName,
String username) {
List<GroupMemberResponseDto> groupMemberResponseDtoList = groupRepository.findGroupMembersByGroupAndNameLikeExceptUser(
groupId, targetName, username);
for (GroupMemberResponseDto dto : groupMemberResponseDtoList) {
dto.setUserId(MaskingUtil.maskUserId(dto.getUserId()));
}
Expand Down

0 comments on commit 537d8b8

Please sign in to comment.