Skip to content

Commit

Permalink
Merge pull request #99 from Na-o-man/feature/#94/additional-shareGrou…
Browse files Browse the repository at this point in the history
…p-AgendaPhoto

[FEAT] shareGroup, AgendaPhoto 추가 기능 개발
  • Loading branch information
bflykky authored Aug 12, 2024
2 parents e77a45e + dab0fa4 commit 544154e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public AgendaPhotoResponse.AgendaPhotoInfo toAgendaPhotoInfo(AgendaPhoto agendaP
return AgendaPhotoResponse.AgendaPhotoInfo
.builder()
.agendaPhotoId(agendaPhoto.getId())
.url(agendaPhoto.getPhoto().getUrl())
.url(agendaPhoto.getPhoto() != null ? agendaPhoto.getPhoto().getUrl() : null)
.build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public ResultResponse<ShareGroupResponse.ShareGroupDetailInfo> getShareGroupDeta
@Parameter(name = "inviteCode", description = "참여하려는 공유그룹의 초대 코드")
})
public ResultResponse<ShareGroupResponse.ShareGroupDetailInfo> getShareGroupByInviteCode(@RequestParam String inviteCode) {

// 만약 inviteCode가 URL 형태라면, 마지막 슬래시 이후의 부분만 추출
if (inviteCode.contains("/")) {
inviteCode = inviteCode.substring(inviteCode.lastIndexOf("/") + 1);
}

ShareGroup shareGroup = shareGroupService.findShareGroup(inviteCode);
List<Profile> profileList = shareGroupService.findProfileListByShareGroupId(shareGroup.getId());

Expand Down Expand Up @@ -101,6 +107,20 @@ public ResultResponse<ShareGroupResponse.InviteInfo> getInviteCode(@PathVariable
shareGroupConverter.toInviteInfo(shareGroup));
}

@GetMapping("/my/shareGroupNameList") //안건 뷰에서 공유 그룹 목록을 알기 위해 호출하는 API
@Operation(summary = "내가 참여한 공유그룹 이름의 목록 조회", description = "내가 참여한 공유그룹 이름의 목록을 페이징 처리하여 조회하는 API입니다. 안건 목록 뷰에서 사용해 주세요.")
@Parameters(value = {
@Parameter(name = "page", description = "조회할 페이지를 입력해 주세요.(0번부터 시작)"),
@Parameter(name = "size", description = "한 페이지에 나타낼 공유그룹 이름 개수를 입력해주세요.")
})
public ResultResponse<ShareGroupResponse.PagedShareGroupNameInfo> getMyShareGroupNameList(@LoginMember Member member,
@PageableDefault(size = 10, sort = "createdAt", direction = Sort.Direction.DESC)
@Parameter(hidden = true) Pageable pageable) {
Page<ShareGroup> shareGroupList = shareGroupService.getMyShareGroupList(member, pageable);
return ResultResponse.of(ShareGroupResultCode.SHARE_GROUP_INFO_LIST,
shareGroupConverter.toPagedShareGroupNameInfo(shareGroupList));
}

@PostMapping("/join")
@Operation(summary = "공유그룹 참여 API", description = "특정 공유그룹에 참여하는 API입니다.")
public ResultResponse<ShareGroupResponse.ShareGroupId> joinShareGroup(@Valid @RequestBody ShareGroupRequest.JoinShareGroupRequest request,
Expand All @@ -122,4 +142,4 @@ public ResultResponse<ShareGroupResponse.ShareGroupId> deleteShareGroup(@PathVar
shareGroupConverter.toShareGroupId(deletedShareGroup));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.umc.naoman.domain.shareGroup.dto.ShareGroupRequest;
import com.umc.naoman.domain.shareGroup.dto.ShareGroupResponse;
import com.umc.naoman.domain.shareGroup.dto.ShareGroupResponse.PagedShareGroupInfo;
import com.umc.naoman.domain.shareGroup.dto.ShareGroupResponse.PagedShareGroupNameInfo;
import com.umc.naoman.domain.shareGroup.dto.ShareGroupResponse.ShareGroupDetailInfo;
import com.umc.naoman.domain.shareGroup.dto.ShareGroupResponse.ShareGroupInfo;
import com.umc.naoman.domain.shareGroup.entity.Profile;
Expand Down Expand Up @@ -32,6 +33,7 @@ public ShareGroupInfo toShareGroupInfo(ShareGroup shareGroup) {
.image(shareGroup.getImage())
.memberCount(shareGroup.getMemberCount())
.inviteUrl(BASE_URL + shareGroup.getInviteCode())
.inviteCode(shareGroup.getInviteCode())
.createdAt(shareGroup.getCreatedAt())
.build();
}
Expand Down Expand Up @@ -95,4 +97,29 @@ public PagedShareGroupInfo toPagedShareGroupInfo(Page<ShareGroup> shareGroupList
.isLast(shareGroupList.isLast())
.build();
}

// 그룹 이름 DTO
public ShareGroupResponse.ShareGroupNameInfo toShareGroupNameInfo(ShareGroup shareGroup) {
return ShareGroupResponse.ShareGroupNameInfo.builder()
.shareGroupId(shareGroup.getId())
.name(shareGroup.getName())
.build();
}

// 내가 참여한 공유 그룹 이름 목록 반환 DTO
public PagedShareGroupNameInfo toPagedShareGroupNameInfo(Page<ShareGroup> shareGroupList) {
// 각 공유 그룹에 대한 상세 정보를 가져오기 (DetailInfo response 재사용)
List<ShareGroupResponse.ShareGroupNameInfo> shareGroupNameInfoList = shareGroupList
.stream()
.map(this::toShareGroupNameInfo)
.toList();

return PagedShareGroupNameInfo.builder()
.shareGroupNameInfoList(shareGroupNameInfoList) // 만든 info 리스트
.page(shareGroupList.getNumber())
.totalElements(shareGroupList.getTotalElements())
.isFirst(shareGroupList.isFirst())
.isLast(shareGroupList.isLast())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public static class ShareGroupInfo {
private String name; //공유그룹 이름 반환
private String image; //공유그룹 대표 이미지 반환. 처음 공유 그룹 생성 시에는 null
private int memberCount; //공유 그룹의 프로필 개수
private String inviteUrl; //공유그룹 초대 코드 반환
private String inviteUrl; //공유그룹 초대 url 반환
private String inviteCode; //공유그룹 초대 코드 반환

@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDateTime createdAt;
Expand All @@ -47,6 +48,27 @@ public static class PagedShareGroupInfo {
private boolean isLast; // 마지막 페이지 여부
}

@Getter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public static class ShareGroupNameInfo {
private Long shareGroupId;
private String name; //공유그룹 이름 반환
}

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class PagedShareGroupNameInfo {
private List<ShareGroupNameInfo> shareGroupNameInfoList; //공유그룹 상세 정보 리스트
private int page; // 페이지 번호
private long totalElements; // 해당 조건에 부합하는 요소의 총 개수
private boolean isFirst; // 첫 페이지 여부
private boolean isLast; // 마지막 페이지 여부
}

@Getter
@Builder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public ShareGroup createShareGroup(ShareGroupRequest.createShareGroupRequest req
.name(memberName)
.role(role) // 역할 설정
.shareGroup(savedShareGroup)
.image(i == 0 ? member.getImage() : null) // 공유그룹장의 프로필 이미지
.joinedAt(i == 0 ? LocalDateTime.now() : null) // 첫 번째 멤버만 joinedAt 설정
.member(i == 0 ? member : null) // 첫 번째 멤버에만 현재 사용자의 member 설정
.build();
Expand Down

0 comments on commit 544154e

Please sign in to comment.