Skip to content

Commit

Permalink
feat: group response swagger 설명 추가 (#47) (KAN-102)
Browse files Browse the repository at this point in the history
  • Loading branch information
seok019283501 committed Nov 1, 2024
1 parent 2d328f8 commit 5794f46
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public interface GroupApi {
Api<CctvInviteResponse> generateCctvInvite(@LoginMember Long userId);

@Operation(summary = "그룹 통합 정보를 조회합니다.")
Api<GroupTotalResponse> getGroupTotalData(Authentication authentication);
Api<GroupTotalResponse> getGroupTotalData(@LoginMember Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public Api<CctvInviteResponse> generateCctvInvite(@LoginMember Long userId) {
}

@GetMapping("/info-list")
public Api<GroupTotalResponse> getGroupTotalData(Authentication authentication) {
GroupTotalResponse groupTotalResponse = groupService.getGroupTotalData(authentication);
public Api<GroupTotalResponse> getGroupTotalData(@LoginMember Long userId) {
GroupTotalResponse groupTotalResponse = groupService.getGroupTotalData(userId);
return Api.success(GroupSuccessType.GET_GROUP_TOTAL_INFO, groupTotalResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class GroupEntity {
@Column(nullable = false)
private LocalDateTime createdAt;

@OneToMany(mappedBy = "group", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "group")
private List<CctvEntity> cctvs;

@OneToMany(mappedBy = "group", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "group")
private List<GroupUserEntity> groupUserEntities;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.ioteatime.meonghanyangserver.group.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;

public record CreateGroupResponse(Long groupId, String groupName, LocalDateTime createdAt) {}
@Schema(description = "그룹 생성 정보 응답")
public record CreateGroupResponse(
@NotNull Long groupId, @NotBlank String groupName, @NotNull LocalDateTime createdAt) {}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.ioteatime.meonghanyangserver.group.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;
import org.ioteatime.meonghanyangserver.cctv.dto.response.CctvInfoResponse;

@Schema(description = "그룹 통합 정보 응답")
public record GroupTotalResponse(
Long groupId,
String groupName,
LocalDateTime createdAt,
@NotNull Long groupId,
@NotBlank String groupName,
@NotNull LocalDateTime createdAt,
List<GroupUserInfoResponse> groupUser,
List<CctvInfoResponse> cctv) {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package org.ioteatime.meonghanyangserver.group.dto.response;

public record GroupUserInfoResponse(Long userId, String nickname) {}
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

@Schema(description = "그룹 유저 정보 응답")
public record GroupUserInfoResponse(@NotNull Long userId, @NotBlank String nickname) {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public interface GroupUserRepository {

Optional<GroupUserEntity> findByUserId(Long userId);

Optional<GroupUserEntity> findGroupUser(UserEntity userEntity);
Optional<GroupUserEntity> findGroupUser(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ public Optional<GroupUserEntity> findByUserId(Long userId) {
}

@Override
public Optional<GroupUserEntity> findGroupUser(UserEntity userEntity) {
Optional<GroupUserEntity> groupUserEntity =
jpaGroupUserRepository.findByUserId(userEntity.getId());
public Optional<GroupUserEntity> findGroupUser(Long userId) {
Optional<GroupUserEntity> groupUserEntity = jpaGroupUserRepository.findByUserId(userId);

return groupUserEntity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ public CreateGroupResponse createGroup(Authentication authentication) {
return GroupResponseMapper.from(newGroupEntity);
}

public GroupTotalResponse getGroupTotalData(Authentication authentication) {
CustomUserDetail userDetails = (CustomUserDetail) authentication.getPrincipal();

UserEntity userEntity = userDetails.getUserEntity();
public GroupTotalResponse getGroupTotalData(Long userId) {

GroupUserEntity groupUserEntity = groupUserService.getGroupUser(userEntity);
GroupUserEntity groupUserEntity = groupUserService.getGroupUser(userId);

GroupEntity groupEntity = groupUserEntity.getGroup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public CctvInviteResponse generateCctvInvite(Long userId) {
return new CctvInviteResponse(groupUserEntity.getGroup().getId(), kvsChannelName);
}

public GroupUserEntity getGroupUser(UserEntity userEntity) {
public GroupUserEntity getGroupUser(Long userId) {
GroupUserEntity groupUserEntity =
groupUserRepository
.findGroupUser(userEntity)
.findGroupUser(userId)
.orElseThrow(
() -> new NotFoundException(GroupErrorType.GROUP_USER_NOT_FOUND));
return groupUserEntity;
Expand Down

0 comments on commit 5794f46

Please sign in to comment.